1
0
Fork 0
pull/15/merge
Levan Gabeskiria 2016-09-08 19:07:53 +00:00 committed by GitHub
commit 581f4017b2
2 changed files with 18 additions and 20 deletions

View File

@ -21,9 +21,9 @@ class SymbolFinder extends NodeVisitorAbstract
]; ];
/** /**
* @var LanguageServer\Protocol\SymbolInformation[] * @var \LanguageServer\Protocol\SymbolInformation[]
*/ */
public $symbols; public $symbols = [];
/** /**
* @var string * @var string
@ -46,6 +46,22 @@ class SymbolFinder extends NodeVisitorAbstract
if (!isset(self::NODE_SYMBOL_KIND_MAP[$class])) { if (!isset(self::NODE_SYMBOL_KIND_MAP[$class])) {
return; 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 = new SymbolInformation();
$symbol->kind = self::NODE_SYMBOL_KIND_MAP[$class]; $symbol->kind = self::NODE_SYMBOL_KIND_MAP[$class];
$symbol->name = (string)$node->name; $symbol->name = (string)$node->name;

View File

@ -96,24 +96,6 @@ class TextDocumentTest extends TestCase
], ],
'containerName' => null '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', 'name' => 'TestTrait',
'kind' => SymbolKind::CLASS_, 'kind' => SymbolKind::CLASS_,