Fix lint issue
parent
164c4589e4
commit
9a40d925f8
|
@ -1,10 +1,12 @@
|
||||||
<?php
|
<?php
|
||||||
declare(strict_types = 1);
|
declare(strict_types = 1);
|
||||||
|
|
||||||
namespace LanguageServer\ContentRetriever;
|
namespace LanguageServer\FilesFinder;
|
||||||
|
|
||||||
use LanguageServer\LanguageClient;
|
use LanguageServer\LanguageClient;
|
||||||
use Sabre\Event\Promise;
|
use Sabre\Event\Promise;
|
||||||
|
use Sabre\Uri;
|
||||||
|
use Webmozart\Glob\Glob;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves file content from the client through a textDocument/xcontent request
|
* Retrieves file content from the client through a textDocument/xcontent request
|
||||||
|
@ -31,13 +33,13 @@ class ClientFilesFinder implements FilesFinder
|
||||||
* @param string $glob
|
* @param string $glob
|
||||||
* @return Promise <string[]> The URIs
|
* @return Promise <string[]> The URIs
|
||||||
*/
|
*/
|
||||||
private function find(string $glob): Promise
|
public function find(string $glob): Promise
|
||||||
{
|
{
|
||||||
return $this->client->workspace->xfiles()->then(function (array $textDocuments) {
|
return $this->client->workspace->xfiles()->then(function (array $textDocuments) use ($glob) {
|
||||||
$uris = [];
|
$uris = [];
|
||||||
foreach ($textDocuments as $textDocument) {
|
foreach ($textDocuments as $textDocument) {
|
||||||
$path = Uri\parse($textDocument->uri)['path'];
|
$path = Uri\parse($textDocument->uri)['path'];
|
||||||
if (Glob::match($path, $pattern)) {
|
if (Glob::match($path, $glob)) {
|
||||||
$uris[] = $textDocument->uri;
|
$uris[] = $textDocument->uri;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,15 +3,16 @@ declare(strict_types = 1);
|
||||||
|
|
||||||
namespace LanguageServer\FilesFinder;
|
namespace LanguageServer\FilesFinder;
|
||||||
|
|
||||||
use Sabre\Event\Promise;
|
|
||||||
use function LanguageServer\{uriToPath, timeout};
|
|
||||||
use Webmozart\Glob\Iterator\GlobIterator;
|
use Webmozart\Glob\Iterator\GlobIterator;
|
||||||
|
use Sabre\Event\Promise;
|
||||||
|
use function Sabre\Event\coroutine;
|
||||||
|
use function LanguageServer\{pathToUri, timeout};
|
||||||
|
|
||||||
class FileSystemFindFinder implements FilesFinder
|
class FileSystemFilesFinder implements FilesFinder
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Returns all files in the workspace that match a glob.
|
* Returns all files in the workspace that match a glob.
|
||||||
* If the client does not support workspace/files, it falls back to searching the file system directly.
|
* If the client does not support workspace/xfiles, it falls back to searching the file system directly.
|
||||||
*
|
*
|
||||||
* @param string $glob
|
* @param string $glob
|
||||||
* @return Promise <string[]>
|
* @return Promise <string[]>
|
||||||
|
@ -20,7 +21,7 @@ class FileSystemFindFinder implements FilesFinder
|
||||||
{
|
{
|
||||||
return coroutine(function () use ($glob) {
|
return coroutine(function () use ($glob) {
|
||||||
$uris = [];
|
$uris = [];
|
||||||
foreach (new GlobIterator($pattern) as $path) {
|
foreach (new GlobIterator($glob) as $path) {
|
||||||
$uris[] = pathToUri($path);
|
$uris[] = pathToUri($path);
|
||||||
yield timeout();
|
yield timeout();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
<?php
|
<?php
|
||||||
declare(strict_types = 1);
|
declare(strict_types = 1);
|
||||||
|
|
||||||
namespace LanguageServer\ContentRetriever;
|
namespace LanguageServer\FilesFinder;
|
||||||
|
|
||||||
use Sabre\Event\Promise;
|
use Sabre\Event\Promise;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface for retrieving the content of a text document
|
* Interface for finding files in the workspace
|
||||||
*/
|
*/
|
||||||
interface FilesFinder
|
interface FilesFinder
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Returns all files in the workspace that match a glob.
|
* Returns all files in the workspace that match a glob.
|
||||||
* If the client does not support workspace/files, it falls back to searching the file system directly.
|
* If the client does not support workspace/xfiles, it falls back to searching the file system directly.
|
||||||
*
|
*
|
||||||
* @param string $glob
|
* @param string $glob
|
||||||
* @return Promise <string[]>
|
* @return Promise <string[]>
|
||||||
|
|
|
@ -15,6 +15,7 @@ use LanguageServer\Protocol\{
|
||||||
CompletionOptions
|
CompletionOptions
|
||||||
};
|
};
|
||||||
use LanguageServer\FilesFinder\{FilesFinder, ClientFilesFinder, FileSystemFilesFinder};
|
use LanguageServer\FilesFinder\{FilesFinder, ClientFilesFinder, FileSystemFilesFinder};
|
||||||
|
use LanguageServer\ContentRetriever\{ContentRetriever, ClientContentRetriever, FileSystemContentRetriever};
|
||||||
use AdvancedJsonRpc;
|
use AdvancedJsonRpc;
|
||||||
use Sabre\Event\{Loop, Promise};
|
use Sabre\Event\{Loop, Promise};
|
||||||
use function Sabre\Event\coroutine;
|
use function Sabre\Event\coroutine;
|
||||||
|
@ -44,11 +45,6 @@ class LanguageServer extends AdvancedJsonRpc\Dispatcher
|
||||||
public $completionItem;
|
public $completionItem;
|
||||||
public $codeLens;
|
public $codeLens;
|
||||||
|
|
||||||
/**
|
|
||||||
* ClientCapabilities
|
|
||||||
*/
|
|
||||||
private $clientCapabilities;
|
|
||||||
|
|
||||||
private $protocolReader;
|
private $protocolReader;
|
||||||
private $protocolWriter;
|
private $protocolWriter;
|
||||||
private $client;
|
private $client;
|
||||||
|
@ -66,6 +62,11 @@ class LanguageServer extends AdvancedJsonRpc\Dispatcher
|
||||||
*/
|
*/
|
||||||
private $filesFinder;
|
private $filesFinder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var ContentRetriever
|
||||||
|
*/
|
||||||
|
private $contentRetrieverFinder;
|
||||||
|
|
||||||
public function __construct(ProtocolReader $reader, ProtocolWriter $writer)
|
public function __construct(ProtocolReader $reader, ProtocolWriter $writer)
|
||||||
{
|
{
|
||||||
parent::__construct($this, '/');
|
parent::__construct($this, '/');
|
||||||
|
@ -111,11 +112,6 @@ class LanguageServer extends AdvancedJsonRpc\Dispatcher
|
||||||
});
|
});
|
||||||
$this->protocolWriter = $writer;
|
$this->protocolWriter = $writer;
|
||||||
$this->client = new LanguageClient($reader, $writer);
|
$this->client = new LanguageClient($reader, $writer);
|
||||||
if ($this->clientCapabilities->xfilesProvider) {
|
|
||||||
$this->filesFinder = new ClientFilesFinder($this->client);
|
|
||||||
} else {
|
|
||||||
$this->filesFinder = new FileSystemFilesFinder;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -129,8 +125,20 @@ class LanguageServer extends AdvancedJsonRpc\Dispatcher
|
||||||
public function initialize(ClientCapabilities $capabilities, string $rootPath = null, int $processId = null): InitializeResult
|
public function initialize(ClientCapabilities $capabilities, string $rootPath = null, int $processId = null): InitializeResult
|
||||||
{
|
{
|
||||||
$this->rootPath = $rootPath;
|
$this->rootPath = $rootPath;
|
||||||
$this->clientCapabilities = $capabilities;
|
|
||||||
$this->project = new Project($this->client, $capabilities);
|
if ($capabilities->xfilesProvider) {
|
||||||
|
$this->filesFinder = new ClientFilesFinder($this->client);
|
||||||
|
} else {
|
||||||
|
$this->filesFinder = new FileSystemFilesFinder;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($capabilities->xcontentProvider) {
|
||||||
|
$this->contentRetriever = new ClientContentRetriever($this->client);
|
||||||
|
} else {
|
||||||
|
$this->contentRetriever = new FileSystemContentRetriever;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->project = new Project($this->client, $this->contentRetriever);
|
||||||
$this->textDocument = new Server\TextDocument($this->project, $this->client);
|
$this->textDocument = new Server\TextDocument($this->project, $this->client);
|
||||||
$this->workspace = new Server\Workspace($this->project, $this->client);
|
$this->workspace = new Server\Workspace($this->project, $this->client);
|
||||||
|
|
||||||
|
@ -193,29 +201,29 @@ class LanguageServer extends AdvancedJsonRpc\Dispatcher
|
||||||
{
|
{
|
||||||
return coroutine(function () {
|
return coroutine(function () {
|
||||||
$pattern = Path::makeAbsolute('**/*.php', $this->rootPath);
|
$pattern = Path::makeAbsolute('**/*.php', $this->rootPath);
|
||||||
$textDocuments = yield $this->filesFinder->find($pattern);
|
$uris = yield $this->filesFinder->find($pattern);
|
||||||
$count = count($textDocuments);
|
$count = count($uris);
|
||||||
|
|
||||||
$startTime = microtime(true);
|
$startTime = microtime(true);
|
||||||
|
|
||||||
foreach ($textDocuments as $i => $textDocument) {
|
foreach ($uris as $i => $uri) {
|
||||||
// Give LS to the chance to handle requests while indexing
|
// Give LS to the chance to handle requests while indexing
|
||||||
yield timeout();
|
yield timeout();
|
||||||
$this->client->window->logMessage(
|
$this->client->window->logMessage(
|
||||||
MessageType::LOG,
|
MessageType::LOG,
|
||||||
"Parsing file $i/$count: {$textDocument->uri}"
|
"Parsing file $i/$count: {$uri}"
|
||||||
);
|
);
|
||||||
try {
|
try {
|
||||||
yield $this->project->loadDocument($textDocument->uri);
|
yield $this->project->loadDocument($uri);
|
||||||
} catch (ContentTooLargeException $e) {
|
} catch (ContentTooLargeException $e) {
|
||||||
$this->client->window->logMessage(
|
$this->client->window->logMessage(
|
||||||
MessageType::INFO,
|
MessageType::INFO,
|
||||||
"Ignoring file {$textDocument->uri} because it exceeds size limit of {$e->limit} bytes ({$e->size})"
|
"Ignoring file {$uri} because it exceeds size limit of {$e->limit} bytes ({$e->size})"
|
||||||
);
|
);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->client->window->logMessage(
|
$this->client->window->logMessage(
|
||||||
MessageType::ERROR,
|
MessageType::ERROR,
|
||||||
"Error parsing file {$textDocument->uri}: " . (string)$e
|
"Error parsing file {$uri}: " . (string)$e
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -228,5 +236,4 @@ class LanguageServer extends AdvancedJsonRpc\Dispatcher
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ namespace LanguageServer;
|
||||||
|
|
||||||
use LanguageServer\Protocol\{SymbolInformation, TextDocumentIdentifier, ClientCapabilities};
|
use LanguageServer\Protocol\{SymbolInformation, TextDocumentIdentifier, ClientCapabilities};
|
||||||
use phpDocumentor\Reflection\DocBlockFactory;
|
use phpDocumentor\Reflection\DocBlockFactory;
|
||||||
use LanguageServer\ContentRetriever\{ContentRetriever, ClientContentRetriever, FileSystemContentRetriever};
|
use LanguageServer\ContentRetriever\ContentRetriever;
|
||||||
use Sabre\Event\Promise;
|
use Sabre\Event\Promise;
|
||||||
use function Sabre\Event\coroutine;
|
use function Sabre\Event\coroutine;
|
||||||
|
|
||||||
|
@ -61,13 +61,6 @@ class Project
|
||||||
*/
|
*/
|
||||||
private $client;
|
private $client;
|
||||||
|
|
||||||
/**
|
|
||||||
* The client's capabilities
|
|
||||||
*
|
|
||||||
* @var ClientCapabilities
|
|
||||||
*/
|
|
||||||
private $clientCapabilities;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The content retriever
|
* The content retriever
|
||||||
*
|
*
|
||||||
|
@ -75,18 +68,13 @@ class Project
|
||||||
*/
|
*/
|
||||||
private $contentRetriever;
|
private $contentRetriever;
|
||||||
|
|
||||||
public function __construct(LanguageClient $client, ClientCapabilities $clientCapabilities)
|
public function __construct(LanguageClient $client, ContentRetriever $contentRetriever)
|
||||||
{
|
{
|
||||||
$this->client = $client;
|
$this->client = $client;
|
||||||
$this->clientCapabilities = $clientCapabilities;
|
|
||||||
$this->parser = new Parser;
|
$this->parser = new Parser;
|
||||||
$this->docBlockFactory = DocBlockFactory::createInstance();
|
$this->docBlockFactory = DocBlockFactory::createInstance();
|
||||||
$this->definitionResolver = new DefinitionResolver($this);
|
$this->definitionResolver = new DefinitionResolver($this);
|
||||||
if ($clientCapabilities->xcontentProvider) {
|
$this->contentRetriever = $contentRetriever;
|
||||||
$this->contentRetriever = new ClientContentRetriever($client);
|
|
||||||
} else {
|
|
||||||
$this->contentRetriever = new FileSystemContentRetriever;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -7,6 +7,7 @@ use PHPUnit\Framework\TestCase;
|
||||||
use PhpParser\{NodeTraverser, Node};
|
use PhpParser\{NodeTraverser, Node};
|
||||||
use PhpParser\NodeVisitor\NameResolver;
|
use PhpParser\NodeVisitor\NameResolver;
|
||||||
use LanguageServer\{LanguageClient, Project, PhpDocument, Parser, DefinitionResolver};
|
use LanguageServer\{LanguageClient, Project, PhpDocument, Parser, DefinitionResolver};
|
||||||
|
use LanguageServer\ContentRetriever\FileSystemContentRetriever;
|
||||||
use LanguageServer\Protocol\ClientCapabilities;
|
use LanguageServer\Protocol\ClientCapabilities;
|
||||||
use LanguageServer\Tests\MockProtocolStream;
|
use LanguageServer\Tests\MockProtocolStream;
|
||||||
use LanguageServer\NodeVisitor\{ReferencesAdder, DefinitionCollector};
|
use LanguageServer\NodeVisitor\{ReferencesAdder, DefinitionCollector};
|
||||||
|
@ -17,7 +18,7 @@ class DefinitionCollectorTest extends TestCase
|
||||||
public function testCollectsSymbols()
|
public function testCollectsSymbols()
|
||||||
{
|
{
|
||||||
$client = new LanguageClient(new MockProtocolStream, new MockProtocolStream);
|
$client = new LanguageClient(new MockProtocolStream, new MockProtocolStream);
|
||||||
$project = new Project($client, new ClientCapabilities);
|
$project = new Project($client, new FileSystemContentRetriever);
|
||||||
$parser = new Parser;
|
$parser = new Parser;
|
||||||
$uri = pathToUri(realpath(__DIR__ . '/../../fixtures/symbols.php'));
|
$uri = pathToUri(realpath(__DIR__ . '/../../fixtures/symbols.php'));
|
||||||
$document = $project->loadDocument($uri)->wait();
|
$document = $project->loadDocument($uri)->wait();
|
||||||
|
@ -57,7 +58,7 @@ class DefinitionCollectorTest extends TestCase
|
||||||
public function testDoesNotCollectReferences()
|
public function testDoesNotCollectReferences()
|
||||||
{
|
{
|
||||||
$client = new LanguageClient(new MockProtocolStream, new MockProtocolStream);
|
$client = new LanguageClient(new MockProtocolStream, new MockProtocolStream);
|
||||||
$project = new Project($client, new ClientCapabilities);
|
$project = new Project($client, new FileSystemContentRetriever);
|
||||||
$parser = new Parser;
|
$parser = new Parser;
|
||||||
$uri = pathToUri(realpath(__DIR__ . '/../../fixtures/references.php'));
|
$uri = pathToUri(realpath(__DIR__ . '/../../fixtures/references.php'));
|
||||||
$document = $project->loadDocument($uri)->wait();
|
$document = $project->loadDocument($uri)->wait();
|
||||||
|
|
|
@ -7,6 +7,7 @@ use PHPUnit\Framework\TestCase;
|
||||||
use LanguageServer\Tests\MockProtocolStream;
|
use LanguageServer\Tests\MockProtocolStream;
|
||||||
use LanguageServer\{LanguageClient, Project};
|
use LanguageServer\{LanguageClient, Project};
|
||||||
use LanguageServer\NodeVisitor\NodeAtPositionFinder;
|
use LanguageServer\NodeVisitor\NodeAtPositionFinder;
|
||||||
|
use LanguageServer\ContentRetriever\FileSystemContentRetriever;
|
||||||
use LanguageServer\Protocol\{SymbolKind, Position, ClientCapabilities};
|
use LanguageServer\Protocol\{SymbolKind, Position, ClientCapabilities};
|
||||||
use PhpParser\Node;
|
use PhpParser\Node;
|
||||||
|
|
||||||
|
@ -20,7 +21,7 @@ class PhpDocumentTest extends TestCase
|
||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
$client = new LanguageClient(new MockProtocolStream, new MockProtocolStream);
|
$client = new LanguageClient(new MockProtocolStream, new MockProtocolStream);
|
||||||
$this->project = new Project($client, new ClientCapabilities);
|
$this->project = new Project($client, new FileSystemContentRetriever);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testParsesVariableVariables()
|
public function testParsesVariableVariables()
|
||||||
|
|
|
@ -6,6 +6,7 @@ namespace LanguageServer\Tests\Server;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use LanguageServer\Tests\MockProtocolStream;
|
use LanguageServer\Tests\MockProtocolStream;
|
||||||
use LanguageServer\{Server, Client, LanguageClient, Project, PhpDocument};
|
use LanguageServer\{Server, Client, LanguageClient, Project, PhpDocument};
|
||||||
|
use LanguageServer\ContentRetriever\FileSystemContentRetriever;
|
||||||
use LanguageServer\Protocol\{
|
use LanguageServer\Protocol\{
|
||||||
TextDocumentItem,
|
TextDocumentItem,
|
||||||
TextDocumentIdentifier,
|
TextDocumentIdentifier,
|
||||||
|
@ -27,7 +28,7 @@ class ProjectTest extends TestCase
|
||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
$client = new LanguageClient(new MockProtocolStream, new MockProtocolStream);
|
$client = new LanguageClient(new MockProtocolStream, new MockProtocolStream);
|
||||||
$this->project = new Project($client, new ClientCapabilities);
|
$this->project = new Project($client, new FileSystemContentRetriever);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetOrLoadDocumentLoadsDocument()
|
public function testGetOrLoadDocumentLoadsDocument()
|
||||||
|
|
|
@ -6,6 +6,7 @@ namespace LanguageServer\Tests\Server;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use LanguageServer\Tests\MockProtocolStream;
|
use LanguageServer\Tests\MockProtocolStream;
|
||||||
use LanguageServer\{Server, LanguageClient, Project};
|
use LanguageServer\{Server, LanguageClient, Project};
|
||||||
|
use LanguageServer\ContentRetriever\FileSystemContentRetriever;
|
||||||
use LanguageServer\Protocol\{Position, Location, Range, ClientCapabilities};
|
use LanguageServer\Protocol\{Position, Location, Range, ClientCapabilities};
|
||||||
use function LanguageServer\pathToUri;
|
use function LanguageServer\pathToUri;
|
||||||
use Sabre\Event\Promise;
|
use Sabre\Event\Promise;
|
||||||
|
@ -44,7 +45,7 @@ abstract class ServerTestCase extends TestCase
|
||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
$client = new LanguageClient(new MockProtocolStream, new MockProtocolStream);
|
$client = new LanguageClient(new MockProtocolStream, new MockProtocolStream);
|
||||||
$this->project = new Project($client, new ClientCapabilities);
|
$this->project = new Project($client, new FileSystemContentRetriever);
|
||||||
$this->textDocument = new Server\TextDocument($this->project, $client);
|
$this->textDocument = new Server\TextDocument($this->project, $client);
|
||||||
$this->workspace = new Server\Workspace($this->project, $client);
|
$this->workspace = new Server\Workspace($this->project, $client);
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ namespace LanguageServer\Tests\Server\TextDocument;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use LanguageServer\Tests\MockProtocolStream;
|
use LanguageServer\Tests\MockProtocolStream;
|
||||||
use LanguageServer\{Server, LanguageClient, Project, CompletionProvider};
|
use LanguageServer\{Server, LanguageClient, Project, CompletionProvider};
|
||||||
|
use LanguageServer\ContentRetriever\FileSystemContentRetriever;
|
||||||
use LanguageServer\Protocol\{
|
use LanguageServer\Protocol\{
|
||||||
TextDocumentIdentifier,
|
TextDocumentIdentifier,
|
||||||
TextEdit,
|
TextEdit,
|
||||||
|
@ -33,7 +34,7 @@ class CompletionTest extends TestCase
|
||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
$client = new LanguageClient(new MockProtocolStream, new MockProtocolStream);
|
$client = new LanguageClient(new MockProtocolStream, new MockProtocolStream);
|
||||||
$this->project = new Project($client, new ClientCapabilities);
|
$this->project = new Project($client, new FileSystemContentRetriever);
|
||||||
$this->project->loadDocument(pathToUri(__DIR__ . '/../../../fixtures/global_symbols.php'))->wait();
|
$this->project->loadDocument(pathToUri(__DIR__ . '/../../../fixtures/global_symbols.php'))->wait();
|
||||||
$this->project->loadDocument(pathToUri(__DIR__ . '/../../../fixtures/symbols.php'))->wait();
|
$this->project->loadDocument(pathToUri(__DIR__ . '/../../../fixtures/symbols.php'))->wait();
|
||||||
$this->textDocument = new Server\TextDocument($this->project, $client);
|
$this->textDocument = new Server\TextDocument($this->project, $client);
|
||||||
|
|
|
@ -6,6 +6,7 @@ namespace LanguageServer\Tests\Server\TextDocument\Definition;
|
||||||
use LanguageServer\Tests\MockProtocolStream;
|
use LanguageServer\Tests\MockProtocolStream;
|
||||||
use LanguageServer\Tests\Server\ServerTestCase;
|
use LanguageServer\Tests\Server\ServerTestCase;
|
||||||
use LanguageServer\{Server, LanguageClient, Project};
|
use LanguageServer\{Server, LanguageClient, Project};
|
||||||
|
use LanguageServer\ContentRetriever\FileSystemContentRetriever;
|
||||||
use LanguageServer\Protocol\{TextDocumentIdentifier, Position, Range, Location, ClientCapabilities};
|
use LanguageServer\Protocol\{TextDocumentIdentifier, Position, Range, Location, ClientCapabilities};
|
||||||
use Sabre\Event\Promise;
|
use Sabre\Event\Promise;
|
||||||
|
|
||||||
|
@ -14,7 +15,7 @@ class GlobalFallbackTest extends ServerTestCase
|
||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
$client = new LanguageClient(new MockProtocolStream, new MockProtocolStream);
|
$client = new LanguageClient(new MockProtocolStream, new MockProtocolStream);
|
||||||
$project = new Project($client, new ClientCapabilities);
|
$project = new Project($client, new FileSystemContentRetriever);
|
||||||
$this->textDocument = new Server\TextDocument($project, $client);
|
$this->textDocument = new Server\TextDocument($project, $client);
|
||||||
$project->openDocument('global_fallback', file_get_contents(__DIR__ . '/../../../../fixtures/global_fallback.php'));
|
$project->openDocument('global_fallback', file_get_contents(__DIR__ . '/../../../../fixtures/global_fallback.php'));
|
||||||
$project->openDocument('global_symbols', file_get_contents(__DIR__ . '/../../../../fixtures/global_symbols.php'));
|
$project->openDocument('global_symbols', file_get_contents(__DIR__ . '/../../../../fixtures/global_symbols.php'));
|
||||||
|
|
|
@ -6,6 +6,7 @@ namespace LanguageServer\Tests\Server\TextDocument;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use LanguageServer\Tests\MockProtocolStream;
|
use LanguageServer\Tests\MockProtocolStream;
|
||||||
use LanguageServer\{Server, Client, LanguageClient, Project};
|
use LanguageServer\{Server, Client, LanguageClient, Project};
|
||||||
|
use LanguageServer\ContentRetriever\FileSystemContentRetriever;
|
||||||
use LanguageServer\Protocol\{
|
use LanguageServer\Protocol\{
|
||||||
TextDocumentIdentifier,
|
TextDocumentIdentifier,
|
||||||
TextDocumentItem,
|
TextDocumentItem,
|
||||||
|
@ -21,7 +22,7 @@ class DidChangeTest extends TestCase
|
||||||
public function test()
|
public function test()
|
||||||
{
|
{
|
||||||
$client = new LanguageClient(new MockProtocolStream, new MockProtocolStream);
|
$client = new LanguageClient(new MockProtocolStream, new MockProtocolStream);
|
||||||
$project = new Project($client, new ClientCapabilities);
|
$project = new Project($client, new FileSystemContentRetriever);
|
||||||
$textDocument = new Server\TextDocument($project, $client);
|
$textDocument = new Server\TextDocument($project, $client);
|
||||||
$phpDocument = $project->openDocument('whatever', "<?php\necho 'Hello, World'\n");
|
$phpDocument = $project->openDocument('whatever', "<?php\necho 'Hello, World'\n");
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ namespace LanguageServer\Tests\Server\TextDocument;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use LanguageServer\Tests\MockProtocolStream;
|
use LanguageServer\Tests\MockProtocolStream;
|
||||||
use LanguageServer\{Server, Client, LanguageClient, Project};
|
use LanguageServer\{Server, Client, LanguageClient, Project};
|
||||||
|
use LanguageServer\ContentRetriever\FileSystemContentRetriever;
|
||||||
use LanguageServer\Protocol\{TextDocumentItem, TextDocumentIdentifier, ClientCapabilities};
|
use LanguageServer\Protocol\{TextDocumentItem, TextDocumentIdentifier, ClientCapabilities};
|
||||||
use Exception;
|
use Exception;
|
||||||
|
|
||||||
|
@ -14,7 +15,7 @@ class DidCloseTest extends TestCase
|
||||||
public function test()
|
public function test()
|
||||||
{
|
{
|
||||||
$client = new LanguageClient(new MockProtocolStream, new MockProtocolStream);
|
$client = new LanguageClient(new MockProtocolStream, new MockProtocolStream);
|
||||||
$project = new Project($client, new ClientCapabilities);
|
$project = new Project($client, new FileSystemContentRetriever);
|
||||||
$textDocument = new Server\TextDocument($project, $client);
|
$textDocument = new Server\TextDocument($project, $client);
|
||||||
$phpDocument = $project->openDocument('whatever', 'hello world');
|
$phpDocument = $project->openDocument('whatever', 'hello world');
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ namespace LanguageServer\Tests\Server\TextDocument;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use LanguageServer\Tests\MockProtocolStream;
|
use LanguageServer\Tests\MockProtocolStream;
|
||||||
use LanguageServer\{Server, Client, LanguageClient, Project};
|
use LanguageServer\{Server, Client, LanguageClient, Project};
|
||||||
|
use LanguageServer\ContentRetriever\FileSystemContentRetriever;
|
||||||
use LanguageServer\Protocol\{
|
use LanguageServer\Protocol\{
|
||||||
TextDocumentIdentifier,
|
TextDocumentIdentifier,
|
||||||
TextDocumentItem,
|
TextDocumentItem,
|
||||||
|
@ -27,14 +28,14 @@ class FormattingTest extends TestCase
|
||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
$client = new LanguageClient(new MockProtocolStream, new MockProtocolStream);
|
$client = new LanguageClient(new MockProtocolStream, new MockProtocolStream);
|
||||||
$project = new Project($client, new ClientCapabilities);
|
$project = new Project($client, new FileSystemContentRetriever);
|
||||||
$this->textDocument = new Server\TextDocument($project, $client);
|
$this->textDocument = new Server\TextDocument($project, $client);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFormatting()
|
public function testFormatting()
|
||||||
{
|
{
|
||||||
$client = new LanguageClient(new MockProtocolStream, new MockProtocolStream);
|
$client = new LanguageClient(new MockProtocolStream, new MockProtocolStream);
|
||||||
$project = new Project($client, new ClientCapabilities);
|
$project = new Project($client, new FileSystemContentRetriever);
|
||||||
$textDocument = new Server\TextDocument($project, $client);
|
$textDocument = new Server\TextDocument($project, $client);
|
||||||
$path = realpath(__DIR__ . '/../../../fixtures/format.php');
|
$path = realpath(__DIR__ . '/../../../fixtures/format.php');
|
||||||
$uri = pathToUri($path);
|
$uri = pathToUri($path);
|
||||||
|
|
|
@ -6,6 +6,7 @@ namespace LanguageServer\Tests\Server\TextDocument;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use LanguageServer\Tests\MockProtocolStream;
|
use LanguageServer\Tests\MockProtocolStream;
|
||||||
use LanguageServer\{Server, Client, LanguageClient, Project, ClientHandler};
|
use LanguageServer\{Server, Client, LanguageClient, Project, ClientHandler};
|
||||||
|
use LanguageServer\ContentRetriever\FileSystemContentRetriever;
|
||||||
use LanguageServer\Protocol\{TextDocumentIdentifier, TextDocumentItem, DiagnosticSeverity, ClientCapabilities};
|
use LanguageServer\Protocol\{TextDocumentIdentifier, TextDocumentItem, DiagnosticSeverity, ClientCapabilities};
|
||||||
use Sabre\Event\Promise;
|
use Sabre\Event\Promise;
|
||||||
use JsonMapper;
|
use JsonMapper;
|
||||||
|
@ -35,7 +36,7 @@ class ParseErrorsTest extends TestCase
|
||||||
return Promise\resolve(null);
|
return Promise\resolve(null);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
$project = new Project($client, new ClientCapabilities);
|
$project = new Project($client, new FileSystemContentRetriever);
|
||||||
$this->textDocument = new Server\TextDocument($project, $client);
|
$this->textDocument = new Server\TextDocument($project, $client);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ namespace LanguageServer\Tests\Server\TextDocument\References;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use LanguageServer\Tests\MockProtocolStream;
|
use LanguageServer\Tests\MockProtocolStream;
|
||||||
use LanguageServer\{Server, LanguageClient, Project};
|
use LanguageServer\{Server, LanguageClient, Project};
|
||||||
|
use LanguageServer\ContentRetriever\FileSystemContentRetriever;
|
||||||
use LanguageServer\Protocol\{TextDocumentIdentifier, Position, ReferenceContext, Location, Range, ClientCapabilities};
|
use LanguageServer\Protocol\{TextDocumentIdentifier, Position, ReferenceContext, Location, Range, ClientCapabilities};
|
||||||
use LanguageServer\Tests\Server\ServerTestCase;
|
use LanguageServer\Tests\Server\ServerTestCase;
|
||||||
|
|
||||||
|
@ -14,7 +15,7 @@ class GlobalFallbackTest extends ServerTestCase
|
||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
$client = new LanguageClient(new MockProtocolStream, new MockProtocolStream);
|
$client = new LanguageClient(new MockProtocolStream, new MockProtocolStream);
|
||||||
$project = new Project($client, new ClientCapabilities);
|
$project = new Project($client, new FileSystemContentRetriever);
|
||||||
$this->textDocument = new Server\TextDocument($project, $client);
|
$this->textDocument = new Server\TextDocument($project, $client);
|
||||||
$project->openDocument('global_fallback', file_get_contents(__DIR__ . '/../../../../fixtures/global_fallback.php'));
|
$project->openDocument('global_fallback', file_get_contents(__DIR__ . '/../../../../fixtures/global_fallback.php'));
|
||||||
$project->openDocument('global_symbols', file_get_contents(__DIR__ . '/../../../../fixtures/global_symbols.php'));
|
$project->openDocument('global_symbols', file_get_contents(__DIR__ . '/../../../../fixtures/global_symbols.php'));
|
||||||
|
|
Loading…
Reference in New Issue