Definition for instanceof class (#117)
parent
8a354ba1af
commit
867196babf
|
@ -30,3 +30,7 @@ $fn = function() use ($var) {
|
||||||
echo TEST_CONST;
|
echo TEST_CONST;
|
||||||
|
|
||||||
use function test_function;
|
use function test_function;
|
||||||
|
|
||||||
|
if ($abc instanceof TestInterface) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -30,3 +30,7 @@ $fn = function() use ($var) {
|
||||||
echo TEST_CONST;
|
echo TEST_CONST;
|
||||||
|
|
||||||
use function TestNamespace\test_function;
|
use function TestNamespace\test_function;
|
||||||
|
|
||||||
|
if ($abc instanceof TestInterface) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -35,6 +35,7 @@ function getReferencedFqn(Node $node)
|
||||||
|| $parent instanceof Node\Expr\StaticCall
|
|| $parent instanceof Node\Expr\StaticCall
|
||||||
|| $parent instanceof Node\Expr\ClassConstFetch
|
|| $parent instanceof Node\Expr\ClassConstFetch
|
||||||
|| $parent instanceof Node\Expr\StaticPropertyFetch
|
|| $parent instanceof Node\Expr\StaticPropertyFetch
|
||||||
|
|| $parent instanceof Node\Expr\Instanceof_
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
// For extends, implements, type hints and classes of classes of static calls use the name directly
|
// For extends, implements, type hints and classes of classes of static calls use the name directly
|
||||||
|
|
|
@ -106,7 +106,8 @@ abstract class ServerTestCase extends TestCase
|
||||||
],
|
],
|
||||||
'TestNamespace\\TestInterface' => [
|
'TestNamespace\\TestInterface' => [
|
||||||
0 => new Location($symbolsUri, new Range(new Position(20, 27), new Position(20, 40))), // class TestClass implements TestInterface
|
0 => new Location($symbolsUri, new Range(new Position(20, 27), new Position(20, 40))), // class TestClass implements TestInterface
|
||||||
1 => new Location($symbolsUri, new Range(new Position(57, 48), new Position(57, 61))) // public function testMethod($testParameter): TestInterface
|
1 => new Location($symbolsUri, new Range(new Position(57, 48), new Position(57, 61))), // public function testMethod($testParameter): TestInterface
|
||||||
|
2 => new Location($referencesUri, new Range(new Position(33, 20), new Position(33, 33))) // if ($abc instanceof TestInterface)
|
||||||
],
|
],
|
||||||
'TestNamespace\\TestClass::TEST_CLASS_CONST' => [
|
'TestNamespace\\TestClass::TEST_CLASS_CONST' => [
|
||||||
0 => new Location($symbolsUri, new Range(new Position(48, 13), new Position(48, 35))), // echo self::TEST_CLASS_CONSTANT
|
0 => new Location($symbolsUri, new Range(new Position(48, 13), new Position(48, 35))), // echo self::TEST_CLASS_CONSTANT
|
||||||
|
@ -145,7 +146,8 @@ abstract class ServerTestCase extends TestCase
|
||||||
],
|
],
|
||||||
'TestInterface' => [
|
'TestInterface' => [
|
||||||
0 => new Location($globalSymbolsUri, new Range(new Position(20, 27), new Position(20, 40))), // class TestClass implements TestInterface
|
0 => new Location($globalSymbolsUri, new Range(new Position(20, 27), new Position(20, 40))), // class TestClass implements TestInterface
|
||||||
1 => new Location($globalSymbolsUri, new Range(new Position(57, 48), new Position(57, 61))) // public function testMethod($testParameter): TestInterface
|
1 => new Location($globalSymbolsUri, new Range(new Position(57, 48), new Position(57, 61))), // public function testMethod($testParameter): TestInterface
|
||||||
|
2 => new Location($globalReferencesUri, new Range(new Position(33, 20), new Position(33, 33))) // if ($abc instanceof TestInterface)
|
||||||
],
|
],
|
||||||
'TestClass::TEST_CLASS_CONST' => [
|
'TestClass::TEST_CLASS_CONST' => [
|
||||||
0 => new Location($globalSymbolsUri, new Range(new Position(48, 13), new Position(48, 35))), // echo self::TEST_CLASS_CONSTANT
|
0 => new Location($globalSymbolsUri, new Range(new Position(48, 13), new Position(48, 35))), // echo self::TEST_CLASS_CONSTANT
|
||||||
|
|
|
@ -211,4 +211,13 @@ class GlobalTest extends ServerTestCase
|
||||||
$result = $this->textDocument->definition(new TextDocumentIdentifier($reference->uri), $reference->range->start);
|
$result = $this->textDocument->definition(new TextDocumentIdentifier($reference->uri), $reference->range->start);
|
||||||
$this->assertEquals($this->getDefinitionLocation('test_function()'), $result);
|
$this->assertEquals($this->getDefinitionLocation('test_function()'), $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testDefinitionForInstanceOf()
|
||||||
|
{
|
||||||
|
// if ($abc instanceof TestInterface) {
|
||||||
|
// Get definition for TestInterface
|
||||||
|
$reference = $this->getReferenceLocations('TestInterface')[2];
|
||||||
|
$result = $this->textDocument->definition(new TextDocumentIdentifier($reference->uri), $reference->range->start);
|
||||||
|
$this->assertEquals($this->getDefinitionLocation('TestInterface'), $result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue