Fix definition for method return type (#76)
parent
b16674d394
commit
a19d225a7a
|
@ -55,7 +55,7 @@ class TestClass implements TestInterface
|
||||||
* @param TestClass $testParameter Lorem sunt velit incididunt mollit
|
* @param TestClass $testParameter Lorem sunt velit incididunt mollit
|
||||||
* @return TestClass
|
* @return TestClass
|
||||||
*/
|
*/
|
||||||
public function testMethod($testParameter)
|
public function testMethod($testParameter): TestInterface
|
||||||
{
|
{
|
||||||
$this->testProperty = $testParameter;
|
$this->testProperty = $testParameter;
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ class TestClass implements TestInterface
|
||||||
* @param TestClass $testParameter Lorem sunt velit incididunt mollit
|
* @param TestClass $testParameter Lorem sunt velit incididunt mollit
|
||||||
* @return TestClass
|
* @return TestClass
|
||||||
*/
|
*/
|
||||||
public function testMethod($testParameter)
|
public function testMethod($testParameter): TestInterface
|
||||||
{
|
{
|
||||||
$this->testProperty = $testParameter;
|
$this->testProperty = $testParameter;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ function getReferencedFqn(Node $node)
|
||||||
$node instanceof Node\Name && (
|
$node instanceof Node\Name && (
|
||||||
$parent instanceof Node\Stmt\ClassLike
|
$parent instanceof Node\Stmt\ClassLike
|
||||||
|| $parent instanceof Node\Param
|
|| $parent instanceof Node\Param
|
||||||
|| $parent instanceof Node\Stmt\Function_
|
|| $parent instanceof Node\FunctionLike
|
||||||
|| $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
|
||||||
|
|
|
@ -104,7 +104,8 @@ abstract class ServerTestCase extends TestCase
|
||||||
6 => new Location($useUri, new Range(new Position( 4, 4), new Position( 4, 27))), // use TestNamespace\TestClass;
|
6 => new Location($useUri, new Range(new Position( 4, 4), new Position( 4, 27))), // use TestNamespace\TestClass;
|
||||||
],
|
],
|
||||||
'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
|
||||||
],
|
],
|
||||||
'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
|
||||||
|
@ -141,7 +142,8 @@ abstract class ServerTestCase extends TestCase
|
||||||
5 => new Location($globalReferencesUri, new Range(new Position(21, 37), new Position(21, 46))), // function whatever(TestClass $param): TestClass
|
5 => new Location($globalReferencesUri, new Range(new Position(21, 37), new Position(21, 46))), // function whatever(TestClass $param): TestClass
|
||||||
],
|
],
|
||||||
'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
|
||||||
],
|
],
|
||||||
'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
|
||||||
|
|
|
@ -165,6 +165,15 @@ class GlobalTest extends ServerTestCase
|
||||||
$this->assertEquals($this->getDefinitionLocation('TestClass'), $result);
|
$this->assertEquals($this->getDefinitionLocation('TestClass'), $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testDefinitionForMethodReturnTypeHints()
|
||||||
|
{
|
||||||
|
// public function testMethod($testParameter): TestInterface
|
||||||
|
// Get definition for TestInterface
|
||||||
|
$reference = $this->getReferenceLocations('TestInterface')[1];
|
||||||
|
$result = $this->textDocument->definition(new TextDocumentIdentifier($reference->uri), $reference->range->start);
|
||||||
|
$this->assertEquals($this->getDefinitionLocation('TestInterface'), $result);
|
||||||
|
}
|
||||||
|
|
||||||
public function testDefinitionForParams()
|
public function testDefinitionForParams()
|
||||||
{
|
{
|
||||||
// echo $param;
|
// echo $param;
|
||||||
|
|
|
@ -30,7 +30,7 @@ class HoverTest extends ServerTestCase
|
||||||
$reference = $this->getReferenceLocations('TestClass::testMethod()')[0];
|
$reference = $this->getReferenceLocations('TestClass::testMethod()')[0];
|
||||||
$result = $this->textDocument->hover(new TextDocumentIdentifier($reference->uri), $reference->range->end);
|
$result = $this->textDocument->hover(new TextDocumentIdentifier($reference->uri), $reference->range->end);
|
||||||
$this->assertEquals(new Hover([
|
$this->assertEquals(new Hover([
|
||||||
new MarkedString('php', "<?php\npublic function testMethod(\$testParameter)"),
|
new MarkedString('php', "<?php\npublic function testMethod(\$testParameter) : \TestInterface"),
|
||||||
'Non culpa nostrud mollit esse sunt laboris in irure ullamco cupidatat amet.'
|
'Non culpa nostrud mollit esse sunt laboris in irure ullamco cupidatat amet.'
|
||||||
], $reference->range), $result);
|
], $reference->range), $result);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue