parent
2d4ca8f99a
commit
4d5052bebd
|
@ -23,7 +23,7 @@ class SymbolFinder extends NodeVisitorAbstract
|
||||||
/**
|
/**
|
||||||
* @var LanguageServer\Protocol\SymbolInformation[]
|
* @var LanguageServer\Protocol\SymbolInformation[]
|
||||||
*/
|
*/
|
||||||
public $symbols;
|
public $symbols = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
|
@ -46,8 +46,24 @@ 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 = $kind;
|
||||||
$symbol->name = (string)$node->name;
|
$symbol->name = (string)$node->name;
|
||||||
$symbol->location = new Location(
|
$symbol->location = new Location(
|
||||||
$this->uri,
|
$this->uri,
|
||||||
|
|
|
@ -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_,
|
||||||
|
|
Loading…
Reference in New Issue