1
0
Fork 0

Add test for nested method call

pull/155/head
Felix Becker 2016-11-18 10:11:11 +01:00
parent f20a62f21c
commit d764b7d6cc
4 changed files with 26 additions and 4 deletions

View File

@ -34,3 +34,6 @@ use function test_function;
if ($abc instanceof TestInterface) {
}
// Nested expression
$obj->testProperty->testMethod();

View File

@ -34,3 +34,6 @@ use function TestNamespace\test_function;
if ($abc instanceof TestInterface) {
}
// Nested expressions
$obj->testProperty->testMethod();

View File

@ -118,7 +118,8 @@ abstract class ServerTestCase extends TestCase
],
'TestNamespace\\TestClass::testProperty' => [
0 => new Location($symbolsUri, new Range(new Position(59, 8), new Position(59, 27))), // $this->testProperty = $testParameter;
1 => new Location($referencesUri, new Range(new Position( 6, 5), new Position( 6, 23)))
1 => new Location($referencesUri, new Range(new Position( 6, 5), new Position( 6, 23))), // echo $obj->testProperty;
2 => new Location($referencesUri, new Range(new Position(38, 0), new Position(38, 18))) // $obj->testProperty->testMethod();
],
'TestNamespace\\TestClass::staticTestProperty' => [
0 => new Location($referencesUri, new Range(new Position( 8, 5), new Position( 8, 35)))
@ -127,7 +128,8 @@ abstract class ServerTestCase extends TestCase
0 => new Location($referencesUri, new Range(new Position( 7, 0), new Position( 7, 29)))
],
'TestNamespace\\TestClass::testMethod()' => [
0 => new Location($referencesUri, new Range(new Position( 5, 0), new Position( 5, 18)))
0 => new Location($referencesUri, new Range(new Position( 5, 0), new Position( 5, 18))), // $obj->testMethod();
1 => new Location($referencesUri, new Range(new Position(38, 0), new Position(38, 32))) // $obj->testProperty->testMethod();
],
'TestNamespace\\test_function()' => [
0 => new Location($referencesUri, new Range(new Position(10, 0), new Position(10, 13))),
@ -158,7 +160,8 @@ abstract class ServerTestCase extends TestCase
],
'TestClass::testProperty' => [
0 => new Location($globalSymbolsUri, new Range(new Position(59, 8), new Position(59, 27))), // $this->testProperty = $testParameter;
1 => new Location($globalReferencesUri, new Range(new Position( 6, 5), new Position( 6, 23)))
1 => new Location($globalReferencesUri, new Range(new Position( 6, 5), new Position( 6, 23))), // echo $obj->testProperty;
2 => new Location($globalReferencesUri, new Range(new Position(38, 0), new Position(38, 18))) // $obj->testProperty->testMethod();
],
'TestClass::staticTestProperty' => [
0 => new Location($globalReferencesUri, new Range(new Position( 8, 5), new Position( 8, 35)))
@ -167,7 +170,8 @@ abstract class ServerTestCase extends TestCase
0 => new Location($globalReferencesUri, new Range(new Position( 7, 0), new Position( 7, 29)))
],
'TestClass::testMethod()' => [
0 => new Location($globalReferencesUri, new Range(new Position( 5, 0), new Position( 5, 18)))
0 => new Location($globalReferencesUri, new Range(new Position( 5, 0), new Position( 5, 18))), // $obj->testMethod();
1 => new Location($globalReferencesUri, new Range(new Position(38, 0), new Position(38, 32))) // $obj->testProperty->testMethod();
],
'test_function()' => [
0 => new Location($globalReferencesUri, new Range(new Position(10, 0), new Position(10, 13))),

View File

@ -292,4 +292,16 @@ class GlobalTest extends ServerTestCase
)->wait();
$this->assertEquals($this->getDefinitionLocation('TestInterface'), $result);
}
public function testDefinitionForNestedMethodCall()
{
// $obj->testProperty->testMethod();
// Get definition for testMethod
$reference = $this->getReferenceLocations('TestClass::testMethod()')[1];
$result = $this->textDocument->definition(
new TextDocumentIdentifier($reference->uri),
$reference->range->end
)->wait();
$this->assertEquals($this->getDefinitionLocation('TestClass::testMethod()'), $result);
}
}