parent
2d4ca8f99a
commit
4d5052bebd
|
@ -23,7 +23,7 @@ class SymbolFinder extends NodeVisitorAbstract
|
|||
/**
|
||||
* @var LanguageServer\Protocol\SymbolInformation[]
|
||||
*/
|
||||
public $symbols;
|
||||
public $symbols = [];
|
||||
|
||||
/**
|
||||
* @var string
|
||||
|
@ -46,8 +46,24 @@ class SymbolFinder extends NodeVisitorAbstract
|
|||
if (!isset(self::NODE_SYMBOL_KIND_MAP[$class])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$symbol = end($this->symbols);
|
||||
$kind = self::NODE_SYMBOL_KIND_MAP[$class];
|
||||
|
||||
// exclude variable symbols that are defined in methods and functions.
|
||||
if ($symbol && $kind === SymbolKind::VARIABLE &&
|
||||
($symbol->kind === SymbolKind::METHOD || $symbol->kind === SymbolKind::FUNCTION)
|
||||
) {
|
||||
if (
|
||||
$node->getAttribute('startLine') - 1 > $symbol->location->range->start->line &&
|
||||
$node->getAttribute('endLine') - 1 < $symbol->location->range->end->line
|
||||
) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$symbol = new SymbolInformation();
|
||||
$symbol->kind = self::NODE_SYMBOL_KIND_MAP[$class];
|
||||
$symbol->kind = $kind;
|
||||
$symbol->name = (string)$node->name;
|
||||
$symbol->location = new Location(
|
||||
$this->uri,
|
||||
|
|
|
@ -96,24 +96,6 @@ class TextDocumentTest extends TestCase
|
|||
],
|
||||
'containerName' => null
|
||||
],
|
||||
[
|
||||
'name' => 'testVariable',
|
||||
'kind' => SymbolKind::VARIABLE,
|
||||
'location' => [
|
||||
'uri' => 'whatever',
|
||||
'range' => [
|
||||
'start' => [
|
||||
'line' => 10,
|
||||
'character' => 8
|
||||
],
|
||||
'end' => [
|
||||
'line' => 10,
|
||||
'character' => 20
|
||||
]
|
||||
]
|
||||
],
|
||||
'containerName' => null
|
||||
],
|
||||
[
|
||||
'name' => 'TestTrait',
|
||||
'kind' => SymbolKind::CLASS_,
|
||||
|
|
Loading…
Reference in New Issue