Skip to content

Commit

Permalink
Resolve expressions recursively (#155)
Browse files Browse the repository at this point in the history
* Add Definition class
* Add recursive DefinitionResolver
* Cache hover
  • Loading branch information
felixfbecker authored Nov 18, 2016
1 parent c19aedc commit 33211c6
Show file tree
Hide file tree
Showing 20 changed files with 1,061 additions and 465 deletions.
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@
"LanguageServer\\": "src/"
},
"files" : [
"src/utils.php",
"src/Fqn.php"
"src/utils.php"
]
},
"autoload-dev": {
Expand Down
4 changes: 4 additions & 0 deletions fixtures/global_references.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,7 @@ function whatever(TestClass $param): TestClass {
if ($abc instanceof TestInterface) {

}

// Nested expression
$obj->testProperty->testMethod();
TestClass::$staticTestProperty[123]->testProperty;
2 changes: 1 addition & 1 deletion fixtures/global_symbols.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class TestClass implements TestInterface
/**
* Lorem excepteur officia sit anim velit veniam enim.
*
* @var TestClass
* @var TestClass[]
*/
public static $staticTestProperty;

Expand Down
4 changes: 4 additions & 0 deletions fixtures/references.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,7 @@ function whatever(TestClass $param): TestClass {
if ($abc instanceof TestInterface) {

}

// Nested expressions
$obj->testProperty->testMethod();
TestClass::$staticTestProperty[123]->testProperty;
2 changes: 1 addition & 1 deletion fixtures/symbols.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class TestClass implements TestInterface
/**
* Lorem excepteur officia sit anim velit veniam enim.
*
* @var TestClass
* @var TestClass[]
*/
public static $staticTestProperty;

Expand Down
62 changes: 62 additions & 0 deletions src/Definition.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php
declare(strict_types = 1);

namespace LanguageServer;

use PhpParser\Node;
use phpDocumentor\Reflection\{Types, Type, Fqsen, TypeResolver};
use LanguageServer\Protocol\SymbolInformation;
use Exception;

/**
* Class used to represent symbols
*/
class Definition
{
/**
* The fully qualified name of the symbol, if it has one
*
* Examples of FQNs:
* - testFunction()
* - TestNamespace\TestClass
* - TestNamespace\TestClass::TEST_CONSTANT
* - TestNamespace\TestClass::staticTestProperty
* - TestNamespace\TestClass::testProperty
* - TestNamespace\TestClass::staticTestMethod()
* - TestNamespace\TestClass::testMethod()
*
* @var string|null
*/
public $fqn;

/**
* @var Protocol\SymbolInformation
*/
public $symbolInformation;

/**
* The type a reference to this symbol will resolve to.
* For properties and constants, this is the type of the property/constant.
* For functions and methods, this is the return type.
* For any other declaration it will be null.
* Can also be a compound type.
* If it is unknown, will be Types\Mixed.
*
* @var \phpDocumentor\Type|null
*/
public $type;

/**
* The first line of the declaration, for use in textDocument/hover
*
* @var string
*/
public $declarationLine;

/**
* A documentation string, for use in textDocument/hover
*
* @var string
*/
public $documentation;
}
Loading

0 comments on commit 33211c6

Please sign in to comment.