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)
|
$this->definitionResolver->resolveExpressionNodeToType($node->dereferencableExpression)
|
||||||
);
|
);
|
||||||
$start = microtime(true);
|
$start = microtime(true);
|
||||||
|
$isInMethodDeclaration = null !== $node->getFirstAncestor(\Microsoft\PhpParser\Node\MethodDeclaration::class);
|
||||||
// Add the object access operator to only get members of all parents
|
// Add the object access operator to only get members of all parents
|
||||||
$prefixes = [];
|
$prefixes = [];
|
||||||
foreach ($this->expandParentFqns($fqns) as $prefix) {
|
foreach ($this->expandParentFqns($fqns) as $prefix) {
|
||||||
|
@ -248,8 +249,8 @@ class CompletionProvider
|
||||||
foreach ($prefixes as $prefix) {
|
foreach ($prefixes as $prefix) {
|
||||||
if (substr($fqn, 0, strlen($prefix)) === $prefix &&
|
if (substr($fqn, 0, strlen($prefix)) === $prefix &&
|
||||||
$def->isMember &&
|
$def->isMember &&
|
||||||
$def->isVisible($prefix, $prefixes[0], $node)) {
|
$def->isVisible($prefix, $prefixes[0], $isInMethodDeclaration)) {
|
||||||
$list->items[] = CompletionItem::fromDefinition($def);
|
$list->items[] = CompletionItemFactory::fromDefinition($def);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -136,13 +136,15 @@ class Definition
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks the definition's visibility.
|
* 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
|
* @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 ($isInMethodDeclaration) {
|
||||||
|
|
||||||
if ($ancestor) {
|
|
||||||
if ($match !== $caller && $this->isPrivate()) {
|
if ($match !== $caller && $this->isPrivate()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue