Merge branch 'master' into content-retriever
commit
e9d931c21a
|
@ -4,12 +4,10 @@ declare(strict_types = 1);
|
||||||
namespace LanguageServer;
|
namespace LanguageServer;
|
||||||
|
|
||||||
use PhpParser\Node;
|
use PhpParser\Node;
|
||||||
use phpDocumentor\Reflection\Types;
|
|
||||||
use LanguageServer\Protocol\{
|
use LanguageServer\Protocol\{
|
||||||
TextEdit,
|
TextEdit,
|
||||||
Range,
|
Range,
|
||||||
Position,
|
Position,
|
||||||
SymbolKind,
|
|
||||||
CompletionList,
|
CompletionList,
|
||||||
CompletionItem,
|
CompletionItem,
|
||||||
CompletionItemKind
|
CompletionItemKind
|
||||||
|
@ -134,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
|
||||||
|
@ -155,10 +152,6 @@ class CompletionProvider
|
||||||
$prefix .= '::$';
|
$prefix .= '::$';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
$fqn = $this->definitionResolver->resolveReferenceNodeToFqn($node);
|
|
||||||
$prefixes = $fqn !== null ? [$fqn] : [];
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($this->project->getDefinitions() as $fqn => $def) {
|
foreach ($this->project->getDefinitions() as $fqn => $def) {
|
||||||
foreach ($prefixes as $prefix) {
|
foreach ($prefixes as $prefix) {
|
||||||
|
|
|
@ -254,10 +254,25 @@ class CompletionTest extends TestCase
|
||||||
new Position(2, 13)
|
new Position(2, 13)
|
||||||
)->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(
|
||||||
|
'staticTestProperty',
|
||||||
|
CompletionItemKind::PROPERTY,
|
||||||
|
'\TestClass[]',
|
||||||
|
'Lorem excepteur officia sit anim velit veniam enim.',
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
'$staticTestProperty'
|
||||||
|
),
|
||||||
new CompletionItem(
|
new CompletionItem(
|
||||||
'staticTestMethod',
|
'staticTestMethod',
|
||||||
CompletionItemKind::METHOD,
|
CompletionItemKind::METHOD,
|
||||||
'mixed', // Method return type
|
'mixed',
|
||||||
'Do magna consequat veniam minim proident eiusmod incididunt aute proident.'
|
'Do magna consequat veniam minim proident eiusmod incididunt aute proident.'
|
||||||
)
|
)
|
||||||
], true), $items);
|
], true), $items);
|
||||||
|
@ -277,6 +292,21 @@ class CompletionTest extends TestCase
|
||||||
CompletionItemKind::VARIABLE,
|
CompletionItemKind::VARIABLE,
|
||||||
'int',
|
'int',
|
||||||
'Anim labore veniam consectetur laboris minim quis aute aute esse nulla ad.'
|
'Anim labore veniam consectetur laboris minim quis aute aute esse nulla ad.'
|
||||||
|
),
|
||||||
|
new CompletionItem(
|
||||||
|
'staticTestProperty',
|
||||||
|
CompletionItemKind::PROPERTY,
|
||||||
|
'\TestClass[]',
|
||||||
|
'Lorem excepteur officia sit anim velit veniam enim.',
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
'$staticTestProperty'
|
||||||
|
),
|
||||||
|
new CompletionItem(
|
||||||
|
'staticTestMethod',
|
||||||
|
CompletionItemKind::METHOD,
|
||||||
|
'mixed',
|
||||||
|
'Do magna consequat veniam minim proident eiusmod incididunt aute proident.'
|
||||||
)
|
)
|
||||||
], true), $items);
|
], true), $items);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue