🚀 Fix weird results ❤️
parent
a0f61ebe8c
commit
578ad76530
|
@ -9,7 +9,7 @@ namespace HELLO {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
\He
|
\HE
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
|
@ -122,6 +122,19 @@ class Index implements ReadableIndex, \Serializable
|
||||||
*/
|
*/
|
||||||
public function setDefinition(string $fqn, Definition $definition)
|
public function setDefinition(string $fqn, Definition $definition)
|
||||||
{
|
{
|
||||||
|
if($fqn === null) {
|
||||||
|
try {
|
||||||
|
throw new \Exception;
|
||||||
|
} catch(\Exception $e) {
|
||||||
|
echo PHP_EOL;
|
||||||
|
var_dump($fqn);
|
||||||
|
echo PHP_EOL;
|
||||||
|
var_dump($definition);
|
||||||
|
echo PHP_EOL;
|
||||||
|
echo $e->getTraceAsString();
|
||||||
|
echo PHP_EOL;
|
||||||
|
}
|
||||||
|
}
|
||||||
$this->definitions[$fqn] = $definition;
|
$this->definitions[$fqn] = $definition;
|
||||||
$this->emit('definition-added');
|
$this->emit('definition-added');
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,18 @@ class SymbolInformation
|
||||||
{
|
{
|
||||||
$parent = $node->getAttribute('parentNode');
|
$parent = $node->getAttribute('parentNode');
|
||||||
$symbol = new self;
|
$symbol = new self;
|
||||||
if ($node instanceof Node\Stmt\Class_|| $node instanceof Node\Stmt\Trait_) {
|
|
||||||
|
if (
|
||||||
|
$node instanceof Node\Expr\FuncCall
|
||||||
|
&& $node->name instanceof Node\Name
|
||||||
|
&& (string)$node->name === 'define'
|
||||||
|
&& isset($node->args[0])
|
||||||
|
&& $node->args[0]->value instanceof Node\Scalar\String_
|
||||||
|
) {
|
||||||
|
// constants with define()
|
||||||
|
$symbol->kind = SymbolKind::CONSTANT;
|
||||||
|
$symbol->name = (string)$node->args[0]->value->value;
|
||||||
|
} elseif ($node instanceof Node\Stmt\Class_|| $node instanceof Node\Stmt\Trait_) {
|
||||||
$symbol->kind = SymbolKind::CLASS_;
|
$symbol->kind = SymbolKind::CLASS_;
|
||||||
} else if ($node instanceof Node\Stmt\Interface_) {
|
} else if ($node instanceof Node\Stmt\Interface_) {
|
||||||
$symbol->kind = SymbolKind::INTERFACE;
|
$symbol->kind = SymbolKind::INTERFACE;
|
||||||
|
@ -84,16 +95,6 @@ class SymbolInformation
|
||||||
$symbol->name = $node->var;
|
$symbol->name = $node->var;
|
||||||
} else if (isset($node->name)) {
|
} else if (isset($node->name)) {
|
||||||
$symbol->name = (string)$node->name;
|
$symbol->name = (string)$node->name;
|
||||||
} else if (
|
|
||||||
$node instanceof Node\Expr\FuncCall
|
|
||||||
&& $node->name instanceof Node\Name
|
|
||||||
&& (string)$node->name === 'define'
|
|
||||||
&& isset($node->args[0])
|
|
||||||
&& $node->args[0]->value instanceof Node\Scalar\String_
|
|
||||||
) {
|
|
||||||
// constants with define()
|
|
||||||
$symbol->kind = SymbolKind::CONSTANT;
|
|
||||||
$symbol->name = (string)$node->args[0]->value->value;
|
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,7 @@ abstract class ServerTestCase extends TestCase
|
||||||
$this->definitionLocations = [
|
$this->definitionLocations = [
|
||||||
|
|
||||||
// Global
|
// Global
|
||||||
'TEST_PROPERTY' => new Location($globalSymbolsUri, new Range(new Position(106, 4), new Position(106, 31))),
|
'TEST_PROPERTY' => new Location($globalSymbolsUri, new Range(new Position(106, 0), new Position(106, 30))),
|
||||||
'TEST_CONST' => new Location($globalSymbolsUri, new Range(new Position( 9, 6), new Position( 9, 22))),
|
'TEST_CONST' => new Location($globalSymbolsUri, new Range(new Position( 9, 6), new Position( 9, 22))),
|
||||||
'TestClass' => new Location($globalSymbolsUri, new Range(new Position(20, 0), new Position(61, 1))),
|
'TestClass' => new Location($globalSymbolsUri, new Range(new Position(20, 0), new Position(61, 1))),
|
||||||
'ChildClass' => new Location($globalSymbolsUri, new Range(new Position(99, 0), new Position(99, 37))),
|
'ChildClass' => new Location($globalSymbolsUri, new Range(new Position(99, 0), new Position(99, 37))),
|
||||||
|
|
|
@ -55,6 +55,7 @@ class SymbolTest extends ServerTestCase
|
||||||
new SymbolInformation('TestInterface', SymbolKind::INTERFACE, $this->getDefinitionLocation('TestInterface'), ''),
|
new SymbolInformation('TestInterface', SymbolKind::INTERFACE, $this->getDefinitionLocation('TestInterface'), ''),
|
||||||
new SymbolInformation('test_function', SymbolKind::FUNCTION, $this->getDefinitionLocation('test_function()'), ''),
|
new SymbolInformation('test_function', SymbolKind::FUNCTION, $this->getDefinitionLocation('test_function()'), ''),
|
||||||
new SymbolInformation('ChildClass', SymbolKind::CLASS_, $this->getDefinitionLocation('ChildClass'), ''),
|
new SymbolInformation('ChildClass', SymbolKind::CLASS_, $this->getDefinitionLocation('ChildClass'), ''),
|
||||||
|
new SymbolInformation('define', SymbolKind::CONSTANT, $this->getDefinitionLocation('TEST_PROPERTY'), ''),
|
||||||
new SymbolInformation('whatever', SymbolKind::FUNCTION, $this->getDefinitionLocation('whatever()'), ''),
|
new SymbolInformation('whatever', SymbolKind::FUNCTION, $this->getDefinitionLocation('whatever()'), ''),
|
||||||
|
|
||||||
new SymbolInformation('SecondTestNamespace', SymbolKind::NAMESPACE, $this->getDefinitionLocation('SecondTestNamespace'), '')
|
new SymbolInformation('SecondTestNamespace', SymbolKind::NAMESPACE, $this->getDefinitionLocation('SecondTestNamespace'), '')
|
||||||
|
|
Loading…
Reference in New Issue