1
0
Fork 0

Add more symbols to symbol test

* constants
* static properties
* static methods
pull/49/head
Felix Becker 2016-10-08 13:14:42 +02:00
parent 063c7f9ad2
commit 658a27f5a5
3 changed files with 92 additions and 11 deletions

View File

@ -2,10 +2,19 @@
namespace TestNamespace; namespace TestNamespace;
const TEST_CONST = 123;
class TestClass class TestClass
{ {
const TEST_CLASS_CONST = 123;
public static $staticTestProperty;
public $testProperty; public $testProperty;
public static function staticTestMethod()
{
}
public function testMethod($testParameter) public function testMethod($testParameter)
{ {
$testVariable = 123; $testVariable = 123;

View File

@ -59,7 +59,7 @@ class SymbolFinder extends NodeVisitorAbstract
public function enterNode(Node $node) public function enterNode(Node $node)
{ {
$this->nodeStack[] = $node; $this->nodeStack[] = $node;
$containerName = end($this->nameStack); $containerName = empty($this->nameStack) ? null : end($this->nameStack);
// If we enter a named node, push its name onto name stack. // If we enter a named node, push its name onto name stack.
// Else push the current name onto stack. // Else push the current name onto stack.

View File

@ -44,6 +44,24 @@ class TextDocumentTest extends TestCase
], ],
'containerName' => null 'containerName' => null
], ],
[
'name' => 'TEST_CONST',
'kind' => SymbolKind::CONSTANT,
'location' => [
'uri' => 'whatever',
'range' => [
'start' => [
'line' => 4,
'character' => 6
],
'end' => [
'line' => 4,
'character' => 22
]
]
],
'containerName' => 'TestNamespace'
],
[ [
'name' => 'TestClass', 'name' => 'TestClass',
'kind' => SymbolKind::CLASS_, 'kind' => SymbolKind::CLASS_,
@ -51,17 +69,53 @@ class TextDocumentTest extends TestCase
'uri' => 'whatever', 'uri' => 'whatever',
'range' => [ 'range' => [
'start' => [ 'start' => [
'line' => 4, 'line' => 6,
'character' => 0 'character' => 0
], ],
'end' => [ 'end' => [
'line' => 12, 'line' => 21,
'character' => 1 'character' => 1
] ]
] ]
], ],
'containerName' => 'TestNamespace' 'containerName' => 'TestNamespace'
], ],
[
'name' => 'TEST_CLASS_CONST',
'kind' => SymbolKind::CONSTANT,
'location' => [
'uri' => 'whatever',
'range' => [
'start' => [
'line' => 8,
'character' => 10
],
'end' => [
'line' => 8,
'character' => 32
]
]
],
'containerName' => 'TestNamespace\\TestClass'
],
[
'name' => 'staticTestProperty',
'kind' => SymbolKind::PROPERTY,
'location' => [
'uri' => 'whatever',
'range' => [
'start' => [
'line' => 9,
'character' => 18
],
'end' => [
'line' => 9,
'character' => 37
]
]
],
'containerName' => 'TestNamespace\\TestClass'
],
[ [
'name' => 'testProperty', 'name' => 'testProperty',
'kind' => SymbolKind::PROPERTY, 'kind' => SymbolKind::PROPERTY,
@ -69,17 +123,35 @@ class TextDocumentTest extends TestCase
'uri' => 'whatever', 'uri' => 'whatever',
'range' => [ 'range' => [
'start' => [ 'start' => [
'line' => 6, 'line' => 10,
'character' => 11 'character' => 11
], ],
'end' => [ 'end' => [
'line' => 6, 'line' => 10,
'character' => 24 'character' => 24
] ]
] ]
], ],
'containerName' => 'TestNamespace\\TestClass' 'containerName' => 'TestNamespace\\TestClass'
], ],
[
'name' => 'staticTestMethod',
'kind' => SymbolKind::METHOD,
'location' => [
'uri' => 'whatever',
'range' => [
'start' => [
'line' => 12,
'character' => 4
],
'end' => [
'line' => 15,
'character' => 5
]
]
],
'containerName' => 'TestNamespace\\TestClass'
],
[ [
'name' => 'testMethod', 'name' => 'testMethod',
'kind' => SymbolKind::METHOD, 'kind' => SymbolKind::METHOD,
@ -87,11 +159,11 @@ class TextDocumentTest extends TestCase
'uri' => 'whatever', 'uri' => 'whatever',
'range' => [ 'range' => [
'start' => [ 'start' => [
'line' => 8, 'line' => 17,
'character' => 4 'character' => 4
], ],
'end' => [ 'end' => [
'line' => 11, 'line' => 20,
'character' => 5 'character' => 5
] ]
] ]
@ -105,11 +177,11 @@ class TextDocumentTest extends TestCase
'uri' => 'whatever', 'uri' => 'whatever',
'range' => [ 'range' => [
'start' => [ 'start' => [
'line' => 14, 'line' => 23,
'character' => 0 'character' => 0
], ],
'end' => [ 'end' => [
'line' => 17, 'line' => 26,
'character' => 1 'character' => 1
] ]
] ]
@ -123,11 +195,11 @@ class TextDocumentTest extends TestCase
'uri' => 'whatever', 'uri' => 'whatever',
'range' => [ 'range' => [
'start' => [ 'start' => [
'line' => 19, 'line' => 28,
'character' => 0 'character' => 0
], ],
'end' => [ 'end' => [
'line' => 22, 'line' => 31,
'character' => 1 'character' => 1
] ]
] ]