parent
dfc80a5c66
commit
0c758ec815
|
@ -73,6 +73,8 @@ class SymbolFinder extends NodeVisitorAbstract
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->nameStack[] = $containerName;
|
$this->nameStack[] = $containerName;
|
||||||
|
// We are not interested in unnamed nodes, return
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$class = get_class($node);
|
$class = get_class($node);
|
||||||
|
|
|
@ -0,0 +1,70 @@
|
||||||
|
<?php
|
||||||
|
declare(strict_types = 1);
|
||||||
|
|
||||||
|
namespace LanguageServer\Tests\Server;
|
||||||
|
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use LanguageServer\Tests\MockProtocolStream;
|
||||||
|
use LanguageServer\{LanguageClient, Project};
|
||||||
|
use LanguageServer\Protocol\SymbolKind;
|
||||||
|
|
||||||
|
class PhpDocumentTest extends TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var Project $project
|
||||||
|
*/
|
||||||
|
private $project;
|
||||||
|
|
||||||
|
public function setUp()
|
||||||
|
{
|
||||||
|
$this->project = new Project(new LanguageClient(new MockProtocolStream()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testParsesVariableVariables()
|
||||||
|
{
|
||||||
|
$document = $this->project->getDocument('whatever');
|
||||||
|
|
||||||
|
$document->updateContent("<?php\n$\$a = 'foo';\n\$bar = 'baz';\n");
|
||||||
|
|
||||||
|
$symbols = $document->getSymbols();
|
||||||
|
|
||||||
|
$this->assertEquals([
|
||||||
|
[
|
||||||
|
'name' => 'a',
|
||||||
|
'kind' => SymbolKind::VARIABLE,
|
||||||
|
'location' => [
|
||||||
|
'uri' => 'whatever',
|
||||||
|
'range' => [
|
||||||
|
'start' => [
|
||||||
|
'line' => 1,
|
||||||
|
'character' => 0
|
||||||
|
],
|
||||||
|
'end' => [
|
||||||
|
'line' => 1,
|
||||||
|
'character' => 3
|
||||||
|
]
|
||||||
|
]
|
||||||
|
],
|
||||||
|
'containerName' => null
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => 'bar',
|
||||||
|
'kind' => SymbolKind::VARIABLE,
|
||||||
|
'location' => [
|
||||||
|
'uri' => 'whatever',
|
||||||
|
'range' => [
|
||||||
|
'start' => [
|
||||||
|
'line' => 2,
|
||||||
|
'character' => 0
|
||||||
|
],
|
||||||
|
'end' => [
|
||||||
|
'line' => 2,
|
||||||
|
'character' => 4
|
||||||
|
]
|
||||||
|
]
|
||||||
|
],
|
||||||
|
'containerName' => null
|
||||||
|
]
|
||||||
|
], json_decode(json_encode($symbols), true));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue