1
0
Fork 0
php-language-server/src/NodeVisitor/DefinitionCollector.php

29 lines
658 B
PHP
Raw Normal View History

2016-10-08 12:59:08 +00:00
<?php
declare(strict_types = 1);
2016-10-09 14:03:56 +00:00
namespace LanguageServer\NodeVisitor;
2016-10-08 12:59:08 +00:00
use PhpParser\{NodeVisitorAbstract, Node};
/**
* Collects definitions of classes, interfaces, traits, methods, properties and constants
* Depends on ReferencesAdder and NameResolver
*/
class DefinitionCollector extends NodeVisitorAbstract
{
/**
* Map from fully qualified name (FQN) to Node
*
* @var Node[]
*/
public $definitions = [];
public function enterNode(Node $node)
{
$fqn = $node->getAttribute('ownerDocument')->getDefinedFqn($node);
if ($fqn !== null) {
$this->definitions[$fqn] = $node;
2016-10-08 12:59:08 +00:00
}
}
}