Symbol test refactor (#92)
* Don't use json_decode in symbol tests * Remove custom setUp() * Use getDefinitionLocation() * TextDocumentTestCase -> ServerTestCase * Refactor Workspace\SymbolTestpull/93/head
parent
cdcfaf7849
commit
6b6ec8c105
|
@ -73,4 +73,18 @@ class SymbolInformation
|
|||
}
|
||||
return $symbol;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param int $kind
|
||||
* @param Location $location
|
||||
* @param string $containerName
|
||||
*/
|
||||
public function __construct($name = null, $kind = null, $location = null, $containerName = null)
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->kind = $kind;
|
||||
$this->location = $location;
|
||||
$this->containerName = $containerName;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace LanguageServer\Tests\Server\TextDocument;
|
||||
namespace LanguageServer\Tests\Server;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use LanguageServer\Tests\MockProtocolStream;
|
||||
|
@ -9,13 +9,18 @@ use LanguageServer\{Server, LanguageClient, Project};
|
|||
use LanguageServer\Protocol\{Position, Location, Range};
|
||||
use function LanguageServer\pathToUri;
|
||||
|
||||
abstract class TextDocumentTestCase extends TestCase
|
||||
abstract class ServerTestCase extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var Server\TextDocument
|
||||
*/
|
||||
protected $textDocument;
|
||||
|
||||
/**
|
||||
* @var Server\Workspace
|
||||
*/
|
||||
protected $workspace;
|
||||
|
||||
/**
|
||||
* @var Project
|
||||
*/
|
||||
|
@ -40,12 +45,13 @@ abstract class TextDocumentTestCase extends TestCase
|
|||
$client = new LanguageClient(new MockProtocolStream());
|
||||
$this->project = new Project($client);
|
||||
$this->textDocument = new Server\TextDocument($this->project, $client);
|
||||
$this->workspace = new Server\Workspace($this->project, $client);
|
||||
|
||||
$globalSymbolsUri = pathToUri(realpath(__DIR__ . '/../../../fixtures/global_symbols.php'));
|
||||
$globalReferencesUri = pathToUri(realpath(__DIR__ . '/../../../fixtures/global_references.php'));
|
||||
$symbolsUri = pathToUri(realpath(__DIR__ . '/../../../fixtures/symbols.php'));
|
||||
$referencesUri = pathToUri(realpath(__DIR__ . '/../../../fixtures/references.php'));
|
||||
$useUri = pathToUri(realpath(__DIR__ . '/../../../fixtures/use.php'));
|
||||
$globalSymbolsUri = pathToUri(realpath(__DIR__ . '/../../fixtures/global_symbols.php'));
|
||||
$globalReferencesUri = pathToUri(realpath(__DIR__ . '/../../fixtures/global_references.php'));
|
||||
$symbolsUri = pathToUri(realpath(__DIR__ . '/../../fixtures/symbols.php'));
|
||||
$referencesUri = pathToUri(realpath(__DIR__ . '/../../fixtures/references.php'));
|
||||
$useUri = pathToUri(realpath(__DIR__ . '/../../fixtures/use.php'));
|
||||
|
||||
$this->project->loadDocument($symbolsUri);
|
||||
$this->project->loadDocument($referencesUri);
|
||||
|
@ -58,6 +64,7 @@ abstract class TextDocumentTestCase extends TestCase
|
|||
// Global
|
||||
'TEST_CONST' => new Location($globalSymbolsUri, new Range(new Position( 4, 6), new Position(4, 22))),
|
||||
'TestClass' => new Location($globalSymbolsUri, new Range(new Position( 6, 0), new Position(21, 1))),
|
||||
'TestTrait' => new Location($globalSymbolsUri, new Range(new Position(23, 0), new Position(26, 1))),
|
||||
'TestInterface' => new Location($globalSymbolsUri, new Range(new Position(28, 0), new Position(31, 1))),
|
||||
'TestClass::TEST_CLASS_CONST' => new Location($globalSymbolsUri, new Range(new Position( 8, 10), new Position(8, 32))),
|
||||
'TestClass::testProperty' => new Location($globalSymbolsUri, new Range(new Position(10, 11), new Position(10, 24))),
|
||||
|
@ -65,17 +72,20 @@ abstract class TextDocumentTestCase extends TestCase
|
|||
'TestClass::staticTestMethod()' => new Location($globalSymbolsUri, new Range(new Position(12, 4), new Position(15, 5))),
|
||||
'TestClass::testMethod()' => new Location($globalSymbolsUri, new Range(new Position(17, 4), new Position(20, 5))),
|
||||
'test_function()' => new Location($globalSymbolsUri, new Range(new Position(33, 0), new Position(36, 1))),
|
||||
'whatever()' => new Location($globalReferencesUri, new Range(new Position(15, 0), new Position(17, 1))),
|
||||
|
||||
// Namespaced
|
||||
'TestNamespace\\TEST_CONST' => new Location($symbolsUri, new Range(new Position( 4, 6), new Position(4, 22))),
|
||||
'TestNamespace\\TestClass' => new Location($symbolsUri, new Range(new Position( 6, 0), new Position(21, 1))),
|
||||
'TestNamespace\\TestInterface' => new Location($symbolsUri, new Range(new Position(28, 0), new Position(31, 1))),
|
||||
'TestNamespace\\TestTrait' => new Location($symbolsUri, new Range(new Position(23, 0), new Position(26, 1))),
|
||||
'TestNamespace\\TestClass::TEST_CLASS_CONST' => new Location($symbolsUri, new Range(new Position( 8, 10), new Position(8, 32))),
|
||||
'TestNamespace\\TestClass::testProperty' => new Location($symbolsUri, new Range(new Position(10, 11), new Position(10, 24))),
|
||||
'TestNamespace\\TestClass::staticTestProperty' => new Location($symbolsUri, new Range(new Position( 9, 18), new Position(9, 37))),
|
||||
'TestNamespace\\TestClass::staticTestMethod()' => new Location($symbolsUri, new Range(new Position(12, 4), new Position(15, 5))),
|
||||
'TestNamespace\\TestClass::testMethod()' => new Location($symbolsUri, new Range(new Position(17, 4), new Position(20, 5))),
|
||||
'TestNamespace\\test_function()' => new Location($symbolsUri, new Range(new Position(33, 0), new Position(36, 1)))
|
||||
'TestNamespace\\test_function()' => new Location($symbolsUri, new Range(new Position(33, 0), new Position(36, 1))),
|
||||
'TestNamespace\\whatever()' => new Location($referencesUri, new Range(new Position(15, 0), new Position(17, 1)))
|
||||
];
|
||||
|
||||
$this->referenceLocations = [
|
|
@ -4,11 +4,11 @@ declare(strict_types = 1);
|
|||
namespace LanguageServer\Tests\Server\TextDocument\Definition;
|
||||
|
||||
use LanguageServer\Tests\MockProtocolStream;
|
||||
use LanguageServer\Tests\Server\TextDocument\TextDocumentTestCase;
|
||||
use LanguageServer\Tests\Server\ServerTestCase;
|
||||
use LanguageServer\{Server, LanguageClient, Project};
|
||||
use LanguageServer\Protocol\{TextDocumentIdentifier, Position, Range, Location};
|
||||
|
||||
class GlobalFallbackTest extends TextDocumentTestCase
|
||||
class GlobalFallbackTest extends ServerTestCase
|
||||
{
|
||||
public function setUp()
|
||||
{
|
||||
|
|
|
@ -3,11 +3,11 @@ declare(strict_types = 1);
|
|||
|
||||
namespace LanguageServer\Tests\Server\TextDocument\Definition;
|
||||
|
||||
use LanguageServer\Tests\Server\TextDocument\TextDocumentTestCase;
|
||||
use LanguageServer\Tests\Server\ServerTestCase;
|
||||
use LanguageServer\Protocol\{TextDocumentIdentifier, Position, Location, Range};
|
||||
use function LanguageServer\pathToUri;
|
||||
|
||||
class GlobalTest extends TextDocumentTestCase
|
||||
class GlobalTest extends ServerTestCase
|
||||
{
|
||||
public function testDefinitionFileBeginning() {
|
||||
// |<?php
|
||||
|
|
|
@ -3,211 +3,30 @@ declare(strict_types = 1);
|
|||
|
||||
namespace LanguageServer\Tests\Server\TextDocument;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use LanguageServer\Tests\Server\ServerTestCase;
|
||||
use LanguageServer\Tests\MockProtocolStream;
|
||||
use LanguageServer\{Server, LanguageClient, Project};
|
||||
use LanguageServer\Protocol\{TextDocumentIdentifier, SymbolKind};
|
||||
use LanguageServer\Protocol\{TextDocumentIdentifier, SymbolInformation, SymbolKind, Position, Location, Range};
|
||||
use function LanguageServer\pathToUri;
|
||||
|
||||
class DocumentSymbolTest extends TestCase
|
||||
class DocumentSymbolTest extends ServerTestCase
|
||||
{
|
||||
/**
|
||||
* @var Server\TextDocument
|
||||
*/
|
||||
private $textDocument;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$client = new LanguageClient(new MockProtocolStream());
|
||||
$project = new Project($client);
|
||||
$this->textDocument = new Server\TextDocument($project, $client);
|
||||
$project->openDocument('symbols', file_get_contents(__DIR__ . '/../../../fixtures/symbols.php'));
|
||||
}
|
||||
|
||||
public function test()
|
||||
{
|
||||
// Request symbols
|
||||
$result = $this->textDocument->documentSymbol(new TextDocumentIdentifier('symbols'));
|
||||
$uri = pathToUri(realpath(__DIR__ . '/../../../fixtures/symbols.php'));
|
||||
$result = $this->textDocument->documentSymbol(new TextDocumentIdentifier($uri));
|
||||
$this->assertEquals([
|
||||
[
|
||||
'name' => 'TEST_CONST',
|
||||
'kind' => SymbolKind::CONSTANT,
|
||||
'location' => [
|
||||
'uri' => 'symbols',
|
||||
'range' => [
|
||||
'start' => [
|
||||
'line' => 4,
|
||||
'character' => 6
|
||||
],
|
||||
'end' => [
|
||||
'line' => 4,
|
||||
'character' => 22
|
||||
]
|
||||
]
|
||||
],
|
||||
'containerName' => 'TestNamespace'
|
||||
],
|
||||
[
|
||||
'name' => 'TestClass',
|
||||
'kind' => SymbolKind::CLASS_,
|
||||
'location' => [
|
||||
'uri' => 'symbols',
|
||||
'range' => [
|
||||
'start' => [
|
||||
'line' => 6,
|
||||
'character' => 0
|
||||
],
|
||||
'end' => [
|
||||
'line' => 21,
|
||||
'character' => 1
|
||||
]
|
||||
]
|
||||
],
|
||||
'containerName' => 'TestNamespace'
|
||||
],
|
||||
[
|
||||
'name' => 'TEST_CLASS_CONST',
|
||||
'kind' => SymbolKind::CONSTANT,
|
||||
'location' => [
|
||||
'uri' => 'symbols',
|
||||
'range' => [
|
||||
'start' => [
|
||||
'line' => 8,
|
||||
'character' => 10
|
||||
],
|
||||
'end' => [
|
||||
'line' => 8,
|
||||
'character' => 32
|
||||
]
|
||||
]
|
||||
],
|
||||
'containerName' => 'TestNamespace\\TestClass'
|
||||
],
|
||||
[
|
||||
'name' => 'staticTestProperty',
|
||||
'kind' => SymbolKind::FIELD,
|
||||
'location' => [
|
||||
'uri' => 'symbols',
|
||||
'range' => [
|
||||
'start' => [
|
||||
'line' => 9,
|
||||
'character' => 18
|
||||
],
|
||||
'end' => [
|
||||
'line' => 9,
|
||||
'character' => 37
|
||||
]
|
||||
]
|
||||
],
|
||||
'containerName' => 'TestNamespace\\TestClass'
|
||||
],
|
||||
[
|
||||
'name' => 'testProperty',
|
||||
'kind' => SymbolKind::FIELD,
|
||||
'location' => [
|
||||
'uri' => 'symbols',
|
||||
'range' => [
|
||||
'start' => [
|
||||
'line' => 10,
|
||||
'character' => 11
|
||||
],
|
||||
'end' => [
|
||||
'line' => 10,
|
||||
'character' => 24
|
||||
]
|
||||
]
|
||||
],
|
||||
'containerName' => 'TestNamespace\\TestClass'
|
||||
],
|
||||
[
|
||||
'name' => 'staticTestMethod',
|
||||
'kind' => SymbolKind::METHOD,
|
||||
'location' => [
|
||||
'uri' => 'symbols',
|
||||
'range' => [
|
||||
'start' => [
|
||||
'line' => 12,
|
||||
'character' => 4
|
||||
],
|
||||
'end' => [
|
||||
'line' => 15,
|
||||
'character' => 5
|
||||
]
|
||||
]
|
||||
],
|
||||
'containerName' => 'TestNamespace\\TestClass'
|
||||
],
|
||||
[
|
||||
'name' => 'testMethod',
|
||||
'kind' => SymbolKind::METHOD,
|
||||
'location' => [
|
||||
'uri' => 'symbols',
|
||||
'range' => [
|
||||
'start' => [
|
||||
'line' => 17,
|
||||
'character' => 4
|
||||
],
|
||||
'end' => [
|
||||
'line' => 20,
|
||||
'character' => 5
|
||||
]
|
||||
]
|
||||
],
|
||||
'containerName' => 'TestNamespace\\TestClass'
|
||||
],
|
||||
[
|
||||
'name' => 'TestTrait',
|
||||
'kind' => SymbolKind::CLASS_,
|
||||
'location' => [
|
||||
'uri' => 'symbols',
|
||||
'range' => [
|
||||
'start' => [
|
||||
'line' => 23,
|
||||
'character' => 0
|
||||
],
|
||||
'end' => [
|
||||
'line' => 26,
|
||||
'character' => 1
|
||||
]
|
||||
]
|
||||
],
|
||||
'containerName' => 'TestNamespace'
|
||||
],
|
||||
[
|
||||
'name' => 'TestInterface',
|
||||
'kind' => SymbolKind::INTERFACE,
|
||||
'location' => [
|
||||
'uri' => 'symbols',
|
||||
'range' => [
|
||||
'start' => [
|
||||
'line' => 28,
|
||||
'character' => 0
|
||||
],
|
||||
'end' => [
|
||||
'line' => 31,
|
||||
'character' => 1
|
||||
]
|
||||
]
|
||||
],
|
||||
'containerName' => 'TestNamespace'
|
||||
],
|
||||
[
|
||||
'name' => 'test_function',
|
||||
'kind' => SymbolKind::FUNCTION,
|
||||
'location' => [
|
||||
'uri' => 'symbols',
|
||||
'range' => [
|
||||
'start' => [
|
||||
'line' => 33,
|
||||
'character' => 0
|
||||
],
|
||||
'end' => [
|
||||
'line' => 36,
|
||||
'character' => 1
|
||||
]
|
||||
]
|
||||
],
|
||||
'containerName' => 'TestNamespace'
|
||||
]
|
||||
], json_decode(json_encode($result), true));
|
||||
new SymbolInformation('TEST_CONST', SymbolKind::CONSTANT, $this->getDefinitionLocation('TestNamespace\\TEST_CONST'), 'TestNamespace'),
|
||||
new SymbolInformation('TestClass', SymbolKind::CLASS_, $this->getDefinitionLocation('TestNamespace\\TestClass'), 'TestNamespace'),
|
||||
new SymbolInformation('TEST_CLASS_CONST', SymbolKind::CONSTANT, $this->getDefinitionLocation('TestNamespace\\TestClass::TEST_CLASS_CONST'), 'TestNamespace\\TestClass'),
|
||||
new SymbolInformation('staticTestProperty', SymbolKind::FIELD, $this->getDefinitionLocation('TestNamespace\\TestClass::staticTestProperty'), 'TestNamespace\\TestClass'),
|
||||
new SymbolInformation('testProperty', SymbolKind::FIELD, $this->getDefinitionLocation('TestNamespace\\TestClass::testProperty'), 'TestNamespace\\TestClass'),
|
||||
new SymbolInformation('staticTestMethod', SymbolKind::METHOD, $this->getDefinitionLocation('TestNamespace\\TestClass::staticTestMethod()'), 'TestNamespace\\TestClass'),
|
||||
new SymbolInformation('testMethod', SymbolKind::METHOD, $this->getDefinitionLocation('TestNamespace\\TestClass::testMethod()'), 'TestNamespace\\TestClass'),
|
||||
new SymbolInformation('TestTrait', SymbolKind::CLASS_, $this->getDefinitionLocation('TestNamespace\\TestTrait'), 'TestNamespace'),
|
||||
new SymbolInformation('TestInterface', SymbolKind::INTERFACE, $this->getDefinitionLocation('TestNamespace\\TestInterface'), 'TestNamespace'),
|
||||
new SymbolInformation('test_function', SymbolKind::FUNCTION, $this->getDefinitionLocation('TestNamespace\\test_function()'), 'TestNamespace'),
|
||||
], $result);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,9 +7,9 @@ use PHPUnit\Framework\TestCase;
|
|||
use LanguageServer\Tests\MockProtocolStream;
|
||||
use LanguageServer\{Server, LanguageClient, Project};
|
||||
use LanguageServer\Protocol\{TextDocumentIdentifier, Position, ReferenceContext, Location, Range};
|
||||
use LanguageServer\Tests\Server\TextDocument\TextDocumentTestCase;
|
||||
use LanguageServer\Tests\Server\ServerTestCase;
|
||||
|
||||
class GlobalFallbackTest extends TextDocumentTestCase
|
||||
class GlobalFallbackTest extends ServerTestCase
|
||||
{
|
||||
public function setUp()
|
||||
{
|
||||
|
|
|
@ -4,10 +4,10 @@ declare(strict_types = 1);
|
|||
namespace LanguageServer\Tests\Server\TextDocument\References;
|
||||
|
||||
use LanguageServer\Protocol\{TextDocumentIdentifier, Position, ReferenceContext, Location, Range};
|
||||
use LanguageServer\Tests\Server\TextDocument\TextDocumentTestCase;
|
||||
use LanguageServer\Tests\Server\ServerTestCase;
|
||||
use function LanguageServer\pathToUri;
|
||||
|
||||
class GlobalTest extends TextDocumentTestCase
|
||||
class GlobalTest extends ServerTestCase
|
||||
{
|
||||
public function testReferencesForClassLike()
|
||||
{
|
||||
|
|
|
@ -3,245 +3,45 @@ declare(strict_types = 1);
|
|||
|
||||
namespace LanguageServer\Tests\Server\Workspace;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use LanguageServer\Tests\MockProtocolStream;
|
||||
use LanguageServer\Tests\Server\ServerTestCase;
|
||||
use LanguageServer\{Server, Client, LanguageClient, Project, PhpDocument};
|
||||
use LanguageServer\Protocol\{TextDocumentItem, TextDocumentIdentifier, SymbolKind, DiagnosticSeverity, FormattingOptions};
|
||||
use LanguageServer\Protocol\{TextDocumentItem, TextDocumentIdentifier, SymbolInformation, SymbolKind, DiagnosticSeverity, FormattingOptions};
|
||||
use AdvancedJsonRpc\{Request as RequestBody, Response as ResponseBody};
|
||||
use function LanguageServer\pathToUri;
|
||||
|
||||
class SymbolTest extends TestCase
|
||||
class SymbolTest extends ServerTestCase
|
||||
{
|
||||
/**
|
||||
* @var LanguageServer\Workspace $workspace
|
||||
*/
|
||||
private $workspace;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $symbolsUri;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $referencesUri;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$client = new LanguageClient(new MockProtocolStream());
|
||||
$project = new Project($client);
|
||||
$this->workspace = new Server\Workspace($project, $client);
|
||||
$this->symbolsUri = pathToUri(realpath(__DIR__ . '/../../../fixtures/symbols.php'));
|
||||
$this->referencesUri = pathToUri(realpath(__DIR__ . '/../../../fixtures/references.php'));
|
||||
$project->loadDocument($this->symbolsUri);
|
||||
$project->loadDocument($this->referencesUri);
|
||||
}
|
||||
|
||||
public function testEmptyQueryReturnsAllSymbols()
|
||||
{
|
||||
// Request symbols
|
||||
$result = $this->workspace->symbol('');
|
||||
$this->assertEquals([
|
||||
[
|
||||
'name' => 'TEST_CONST',
|
||||
'kind' => SymbolKind::CONSTANT,
|
||||
'location' => [
|
||||
'uri' => $this->symbolsUri,
|
||||
'range' => [
|
||||
'start' => [
|
||||
'line' => 4,
|
||||
'character' => 6
|
||||
],
|
||||
'end' => [
|
||||
'line' => 4,
|
||||
'character' => 22
|
||||
]
|
||||
]
|
||||
],
|
||||
'containerName' => 'TestNamespace'
|
||||
],
|
||||
[
|
||||
'name' => 'TestClass',
|
||||
'kind' => SymbolKind::CLASS_,
|
||||
'location' => [
|
||||
'uri' => $this->symbolsUri,
|
||||
'range' => [
|
||||
'start' => [
|
||||
'line' => 6,
|
||||
'character' => 0
|
||||
],
|
||||
'end' => [
|
||||
'line' => 21,
|
||||
'character' => 1
|
||||
]
|
||||
]
|
||||
],
|
||||
'containerName' => 'TestNamespace'
|
||||
],
|
||||
[
|
||||
'name' => 'TEST_CLASS_CONST',
|
||||
'kind' => SymbolKind::CONSTANT,
|
||||
'location' => [
|
||||
'uri' => $this->symbolsUri,
|
||||
'range' => [
|
||||
'start' => [
|
||||
'line' => 8,
|
||||
'character' => 10
|
||||
],
|
||||
'end' => [
|
||||
'line' => 8,
|
||||
'character' => 32
|
||||
]
|
||||
]
|
||||
],
|
||||
'containerName' => 'TestNamespace\\TestClass'
|
||||
],
|
||||
[
|
||||
'name' => 'staticTestProperty',
|
||||
'kind' => SymbolKind::FIELD,
|
||||
'location' => [
|
||||
'uri' => $this->symbolsUri,
|
||||
'range' => [
|
||||
'start' => [
|
||||
'line' => 9,
|
||||
'character' => 18
|
||||
],
|
||||
'end' => [
|
||||
'line' => 9,
|
||||
'character' => 37
|
||||
]
|
||||
]
|
||||
],
|
||||
'containerName' => 'TestNamespace\\TestClass'
|
||||
],
|
||||
[
|
||||
'name' => 'testProperty',
|
||||
'kind' => SymbolKind::FIELD,
|
||||
'location' => [
|
||||
'uri' => $this->symbolsUri,
|
||||
'range' => [
|
||||
'start' => [
|
||||
'line' => 10,
|
||||
'character' => 11
|
||||
],
|
||||
'end' => [
|
||||
'line' => 10,
|
||||
'character' => 24
|
||||
]
|
||||
]
|
||||
],
|
||||
'containerName' => 'TestNamespace\\TestClass'
|
||||
],
|
||||
[
|
||||
'name' => 'staticTestMethod',
|
||||
'kind' => SymbolKind::METHOD,
|
||||
'location' => [
|
||||
'uri' => $this->symbolsUri,
|
||||
'range' => [
|
||||
'start' => [
|
||||
'line' => 12,
|
||||
'character' => 4
|
||||
],
|
||||
'end' => [
|
||||
'line' => 15,
|
||||
'character' => 5
|
||||
]
|
||||
]
|
||||
],
|
||||
'containerName' => 'TestNamespace\\TestClass'
|
||||
],
|
||||
[
|
||||
'name' => 'testMethod',
|
||||
'kind' => SymbolKind::METHOD,
|
||||
'location' => [
|
||||
'uri' => $this->symbolsUri,
|
||||
'range' => [
|
||||
'start' => [
|
||||
'line' => 17,
|
||||
'character' => 4
|
||||
],
|
||||
'end' => [
|
||||
'line' => 20,
|
||||
'character' => 5
|
||||
]
|
||||
]
|
||||
],
|
||||
'containerName' => 'TestNamespace\\TestClass'
|
||||
],
|
||||
[
|
||||
'name' => 'TestTrait',
|
||||
'kind' => SymbolKind::CLASS_,
|
||||
'location' => [
|
||||
'uri' => $this->symbolsUri,
|
||||
'range' => [
|
||||
'start' => [
|
||||
'line' => 23,
|
||||
'character' => 0
|
||||
],
|
||||
'end' => [
|
||||
'line' => 26,
|
||||
'character' => 1
|
||||
]
|
||||
]
|
||||
],
|
||||
'containerName' => 'TestNamespace'
|
||||
],
|
||||
[
|
||||
'name' => 'TestInterface',
|
||||
'kind' => SymbolKind::INTERFACE,
|
||||
'location' => [
|
||||
'uri' => $this->symbolsUri,
|
||||
'range' => [
|
||||
'start' => [
|
||||
'line' => 28,
|
||||
'character' => 0
|
||||
],
|
||||
'end' => [
|
||||
'line' => 31,
|
||||
'character' => 1
|
||||
]
|
||||
]
|
||||
],
|
||||
'containerName' => 'TestNamespace'
|
||||
],
|
||||
[
|
||||
'name' => 'test_function',
|
||||
'kind' => SymbolKind::FUNCTION,
|
||||
'location' => [
|
||||
'uri' => $this->symbolsUri,
|
||||
'range' => [
|
||||
'start' => [
|
||||
'line' => 33,
|
||||
'character' => 0
|
||||
],
|
||||
'end' => [
|
||||
'line' => 36,
|
||||
'character' => 1
|
||||
]
|
||||
]
|
||||
],
|
||||
'containerName' => 'TestNamespace'
|
||||
],
|
||||
[
|
||||
'name' => 'whatever',
|
||||
'kind' => SymbolKind::FUNCTION,
|
||||
'location' => [
|
||||
'uri' => $this->referencesUri,
|
||||
'range' => [
|
||||
'start' => [
|
||||
'line' => 15,
|
||||
'character' => 0
|
||||
],
|
||||
'end' => [
|
||||
'line' => 17,
|
||||
'character' => 1
|
||||
]
|
||||
]
|
||||
],
|
||||
'containerName' => 'TestNamespace'
|
||||
]
|
||||
], json_decode(json_encode($result), true));
|
||||
// Namespaced
|
||||
new SymbolInformation('TEST_CONST', SymbolKind::CONSTANT, $this->getDefinitionLocation('TestNamespace\\TEST_CONST'), 'TestNamespace'),
|
||||
new SymbolInformation('TestClass', SymbolKind::CLASS_, $this->getDefinitionLocation('TestNamespace\\TestClass'), 'TestNamespace'),
|
||||
new SymbolInformation('TEST_CLASS_CONST', SymbolKind::CONSTANT, $this->getDefinitionLocation('TestNamespace\\TestClass::TEST_CLASS_CONST'), 'TestNamespace\\TestClass'),
|
||||
new SymbolInformation('staticTestProperty', SymbolKind::FIELD, $this->getDefinitionLocation('TestNamespace\\TestClass::staticTestProperty'), 'TestNamespace\\TestClass'),
|
||||
new SymbolInformation('testProperty', SymbolKind::FIELD, $this->getDefinitionLocation('TestNamespace\\TestClass::testProperty'), 'TestNamespace\\TestClass'),
|
||||
new SymbolInformation('staticTestMethod', SymbolKind::METHOD, $this->getDefinitionLocation('TestNamespace\\TestClass::staticTestMethod()'), 'TestNamespace\\TestClass'),
|
||||
new SymbolInformation('testMethod', SymbolKind::METHOD, $this->getDefinitionLocation('TestNamespace\\TestClass::testMethod()'), 'TestNamespace\\TestClass'),
|
||||
new SymbolInformation('TestTrait', SymbolKind::CLASS_, $this->getDefinitionLocation('TestNamespace\\TestTrait'), 'TestNamespace'),
|
||||
new SymbolInformation('TestInterface', SymbolKind::INTERFACE, $this->getDefinitionLocation('TestNamespace\\TestInterface'), 'TestNamespace'),
|
||||
new SymbolInformation('test_function', SymbolKind::FUNCTION, $this->getDefinitionLocation('TestNamespace\\test_function()'), 'TestNamespace'),
|
||||
new SymbolInformation('whatever', SymbolKind::FUNCTION, $this->getDefinitionLocation('TestNamespace\\whatever()'), 'TestNamespace'),
|
||||
// Global
|
||||
new SymbolInformation('TEST_CONST', SymbolKind::CONSTANT, $this->getDefinitionLocation('TEST_CONST'), ''),
|
||||
new SymbolInformation('TestClass', SymbolKind::CLASS_, $this->getDefinitionLocation('TestClass'), ''),
|
||||
new SymbolInformation('TEST_CLASS_CONST', SymbolKind::CONSTANT, $this->getDefinitionLocation('TestClass::TEST_CLASS_CONST'), 'TestClass'),
|
||||
new SymbolInformation('staticTestProperty', SymbolKind::FIELD, $this->getDefinitionLocation('TestClass::staticTestProperty'), 'TestClass'),
|
||||
new SymbolInformation('testProperty', SymbolKind::FIELD, $this->getDefinitionLocation('TestClass::testProperty'), 'TestClass'),
|
||||
new SymbolInformation('staticTestMethod', SymbolKind::METHOD, $this->getDefinitionLocation('TestClass::staticTestMethod()'), 'TestClass'),
|
||||
new SymbolInformation('testMethod', SymbolKind::METHOD, $this->getDefinitionLocation('TestClass::testMethod()'), 'TestClass'),
|
||||
new SymbolInformation('TestTrait', SymbolKind::CLASS_, $this->getDefinitionLocation('TestTrait'), ''),
|
||||
new SymbolInformation('TestInterface', SymbolKind::INTERFACE, $this->getDefinitionLocation('TestInterface'), ''),
|
||||
new SymbolInformation('test_function', SymbolKind::FUNCTION, $this->getDefinitionLocation('test_function()'), ''),
|
||||
new SymbolInformation('whatever', SymbolKind::FUNCTION, $this->getDefinitionLocation('whatever()'), '')
|
||||
], $result);
|
||||
}
|
||||
|
||||
public function testQueryFiltersResults()
|
||||
|
@ -249,42 +49,10 @@ class SymbolTest extends TestCase
|
|||
// Request symbols
|
||||
$result = $this->workspace->symbol('testmethod');
|
||||
$this->assertEquals([
|
||||
[
|
||||
'name' => 'staticTestMethod',
|
||||
'kind' => SymbolKind::METHOD,
|
||||
'location' => [
|
||||
'uri' => $this->symbolsUri,
|
||||
'range' => [
|
||||
'start' => [
|
||||
'line' => 12,
|
||||
'character' => 4
|
||||
],
|
||||
'end' => [
|
||||
'line' => 15,
|
||||
'character' => 5
|
||||
]
|
||||
]
|
||||
],
|
||||
'containerName' => 'TestNamespace\\TestClass'
|
||||
],
|
||||
[
|
||||
'name' => 'testMethod',
|
||||
'kind' => SymbolKind::METHOD,
|
||||
'location' => [
|
||||
'uri' => $this->symbolsUri,
|
||||
'range' => [
|
||||
'start' => [
|
||||
'line' => 17,
|
||||
'character' => 4
|
||||
],
|
||||
'end' => [
|
||||
'line' => 20,
|
||||
'character' => 5
|
||||
]
|
||||
]
|
||||
],
|
||||
'containerName' => 'TestNamespace\\TestClass'
|
||||
]
|
||||
], json_decode(json_encode($result), true));
|
||||
new SymbolInformation('staticTestMethod', SymbolKind::METHOD, $this->getDefinitionLocation('TestNamespace\\TestClass::staticTestMethod()'), 'TestNamespace\\TestClass'),
|
||||
new SymbolInformation('testMethod', SymbolKind::METHOD, $this->getDefinitionLocation('TestNamespace\\TestClass::testMethod()'), 'TestNamespace\\TestClass'),
|
||||
new SymbolInformation('staticTestMethod', SymbolKind::METHOD, $this->getDefinitionLocation('TestClass::staticTestMethod()'), 'TestClass'),
|
||||
new SymbolInformation('testMethod', SymbolKind::METHOD, $this->getDefinitionLocation('TestClass::testMethod()'), 'TestClass')
|
||||
], $result);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue