Resolving node ancestor in the CompletionProvider, so it's resolved outside the loop
parent
a54fcf9d14
commit
d1bdcbd173
|
@ -237,6 +237,7 @@ class CompletionProvider
|
|||
$this->definitionResolver->resolveExpressionNodeToType($node->dereferencableExpression)
|
||||
);
|
||||
$start = microtime(true);
|
||||
$isInMethodDeclaration = null !== $node->getFirstAncestor(\Microsoft\PhpParser\Node\MethodDeclaration::class);
|
||||
// Add the object access operator to only get members of all parents
|
||||
$prefixes = [];
|
||||
foreach ($this->expandParentFqns($fqns) as $prefix) {
|
||||
|
@ -248,8 +249,8 @@ class CompletionProvider
|
|||
foreach ($prefixes as $prefix) {
|
||||
if (substr($fqn, 0, strlen($prefix)) === $prefix &&
|
||||
$def->isMember &&
|
||||
$def->isVisible($prefix, $prefixes[0], $node)) {
|
||||
$list->items[] = CompletionItem::fromDefinition($def);
|
||||
$def->isVisible($prefix, $prefixes[0], $isInMethodDeclaration)) {
|
||||
$list->items[] = CompletionItemFactory::fromDefinition($def);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -136,13 +136,15 @@ class Definition
|
|||
|
||||
/**
|
||||
* Checks the definition's visibility.
|
||||
* @param string $match Owner of the FQNS
|
||||
* @param string $caller Descendant of the FQNS owner
|
||||
* @param bool $isInMethodDeclaration checking if the call is from inside a
|
||||
* method
|
||||
* @return bool
|
||||
*/
|
||||
public function isVisible(string $match, string $caller, \Microsoft\PhpParser\Node $node): bool
|
||||
public function isVisible(string $match, string $caller, bool $isInMethodDeclaration): bool
|
||||
{
|
||||
$ancestor = $node->getFirstAncestor(\Microsoft\PhpParser\Node\MethodDeclaration::class);
|
||||
|
||||
if ($ancestor) {
|
||||
if ($isInMethodDeclaration) {
|
||||
if ($match !== $caller && $this->isPrivate()) {
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue