Skip to content
This repository was archived by the owner on Mar 6, 2022. It is now read-only.

WorseNamedParameterCompletor: ignored when completing a variable #59

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Microsoft\PhpParser\Node\Expression\MemberAccessExpression;
use Microsoft\PhpParser\Node\Expression\ObjectCreationExpression;
use Microsoft\PhpParser\Node\Expression\ScopedPropertyAccessExpression;
use Microsoft\PhpParser\Node\Expression\Variable;
use Microsoft\PhpParser\Node\QualifiedName;
use Phpactor\Completion\Bridge\TolerantParser\TolerantCompletor;
use Phpactor\Completion\Bridge\TolerantParser\Helper\NodeQuery;
Expand Down Expand Up @@ -58,6 +59,10 @@ public function complete(Node $node, TextDocument $source, ByteOffset $offset):
return true;
}

if ($node instanceof Variable) {
return true;
}

if ($creation instanceof ObjectCreationExpression) {
return yield from $this->fromObjectCreation($creation);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ public function priority(?TextDocumentUri $one, ?TextDocumentUri $two): int

$range = Suggestion::PRIORITY_LOW - Suggestion::PRIORITY_MEDIUM;

return Suggestion::PRIORITY_MEDIUM + $range - $range * $similarity;
return (int) (Suggestion::PRIORITY_MEDIUM + $range - $range * $similarity);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ public function provideComplete(): Generator
]
];

yield 'Ignore when completing a variable' => [
'<?php class A{function bee(string $one){}} $a = new A(); $a->bee($o<>',
[
]
];

yield 'Method call in partial method call' => [
'<?php class B {function boo(): B{}}' .
'class A{function bee(string $one){}} $b=new B();$a=new A(); $a->bee($b->boo()-><>',
Expand Down