Not all class members are proposed in completion
parent
10fb3c92e0
commit
9124b52904
|
@ -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
|
||||||
|
@ -156,8 +154,12 @@ class CompletionProvider
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$fqn = $this->definitionResolver->resolveReferenceNodeToFqn($node);
|
$prefix = $this->definitionResolver->resolveReferenceNodeToFqn($node);
|
||||||
$prefixes = $fqn !== null ? [$fqn] : [];
|
$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) {
|
||||||
|
|
|
@ -200,6 +200,12 @@ 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,
|
||||||
|
@ -208,6 +214,12 @@ 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);
|
||||||
}
|
}
|
||||||
|
@ -254,10 +266,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 +304,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