1
0
Fork 0

Fix existing tests

pull/165/head
Felix Becker 2016-11-22 22:48:11 +01:00
parent d66cc763bc
commit 8f30819a17
1 changed files with 8 additions and 8 deletions

View File

@ -56,19 +56,16 @@ class CompletionProvider
|| $node instanceof Node\Expr\StaticPropertyFetch || $node instanceof Node\Expr\StaticPropertyFetch
|| $node instanceof Node\Expr\ClassConstFetch || $node instanceof Node\Expr\ClassConstFetch
) { ) {
$nodeToResolve = $node;
if (!is_string($node->name)) { if (!is_string($node->name)) {
// If the name is an Error node, just filter by the class // If the name is an Error node, just filter by the class
if ($node instanceof Node\Expr\MethodCall || $node instanceof Node\Expr\PropertyFetch) { if ($node instanceof Node\Expr\MethodCall || $node instanceof Node\Expr\PropertyFetch) {
$nodeToResolve = $node->var; // For instances, resolve the variable type
} else {
$nodeToResolve = $node->class;
}
}
$prefixes = DefinitionResolver::getFqnsFromType( $prefixes = DefinitionResolver::getFqnsFromType(
$this->definitionResolver->resolveExpressionNodeToType($nodeToResolve) $this->definitionResolver->resolveExpressionNodeToType($node->var)
); );
if (!is_string($node->name)) { } else {
$prefixes = [is_string($node->class) ? $node->class : ''];
}
// If we are just filtering by the class, add the appropiate operator to the prefix // If we are just filtering by the class, add the appropiate operator to the prefix
// to filter the type of symbol // to filter the type of symbol
foreach ($prefixes as &$prefix) { foreach ($prefixes as &$prefix) {
@ -80,7 +77,10 @@ class CompletionProvider
$prefix .= '::$'; $prefix .= '::$';
} }
} }
} else {
$prefixes = [$this->definitionResolver->resolveReferenceNodeToFqn($node)];
} }
foreach ($this->project->getDefinitions() as $fqn => $def) { foreach ($this->project->getDefinitions() as $fqn => $def) {
foreach ($prefixes as $prefix) { foreach ($prefixes as $prefix) {
if (substr($fqn, 0, strlen($prefix)) === $prefix && !$def->isGlobal) { if (substr($fqn, 0, strlen($prefix)) === $prefix && !$def->isGlobal) {