1
0
Fork 0

Improved version

pull/207/head
Michal Niewrzal 2016-12-07 20:09:07 +01:00
parent 9124b52904
commit b03b7c1954
2 changed files with 17 additions and 38 deletions

View File

@ -132,7 +132,6 @@ class CompletionProvider
|| $node instanceof Node\Expr\StaticPropertyFetch || $node instanceof Node\Expr\StaticPropertyFetch
|| $node instanceof Node\Expr\ClassConstFetch || $node instanceof Node\Expr\ClassConstFetch
) { ) {
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) {
// For instances, resolve the variable type // For instances, resolve the variable type
@ -140,7 +139,7 @@ class CompletionProvider
$this->definitionResolver->resolveExpressionNodeToType($node->var) $this->definitionResolver->resolveExpressionNodeToType($node->var)
); );
} else { } else {
$prefixes = [$node->class instanceof Node\Name ? (string)$node->class : '']; $prefixes = [$node->class instanceof \PhpParser\Node\Name ? (string)$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
@ -153,14 +152,6 @@ class CompletionProvider
$prefix .= '::$'; $prefix .= '::$';
} }
} }
} else {
$prefix = $this->definitionResolver->resolveReferenceNodeToFqn($node);
$index = ($index = strpos($prefix, '->')) ? $index : strpos($prefix, '::');
if ($index) {
$prefix = substr($prefix, 0, $index + 2);
}
$prefixes = $prefix !== null ? [$prefix] : [];
}
foreach ($this->project->getDefinitions() as $fqn => $def) { foreach ($this->project->getDefinitions() as $fqn => $def) {
foreach ($prefixes as $prefix) { foreach ($prefixes as $prefix) {

View File

@ -200,12 +200,6 @@ class CompletionTest extends TestCase
new Position(2, 14) new Position(2, 14)
)->wait(); )->wait();
$this->assertEquals(new CompletionList([ $this->assertEquals(new CompletionList([
new CompletionItem(
'TEST_CLASS_CONST',
CompletionItemKind::VARIABLE,
'int',
'Anim labore veniam consectetur laboris minim quis aute aute esse nulla ad.'
),
new CompletionItem( new CompletionItem(
'staticTestProperty', 'staticTestProperty',
CompletionItemKind::PROPERTY, CompletionItemKind::PROPERTY,
@ -214,12 +208,6 @@ class CompletionTest extends TestCase
null, null,
null, null,
'$staticTestProperty' '$staticTestProperty'
),
new CompletionItem(
'staticTestMethod',
CompletionItemKind::METHOD,
'mixed',
'Do magna consequat veniam minim proident eiusmod incididunt aute proident.'
) )
], true), $items); ], true), $items);
} }