Open zodiark23 opened 7 years ago
Hey @zodiark23,
We did a quick check and this issue looks very darn similar to
This could be a coincidence, but if any of these issues solves your problem then I did a good job :smile:
If not, the maintainers will get to this issue shortly.
Cheers, Your Friendly Neighborhood ProBot
I also face the same issue, and in the first glance i feel that there is no check specifically to check the access modifiers. May be it is there which i couldn't understand. I am trying to implement this. If I complete will ask to merge.
Hi, I was checking this issue and I came up with a solution. I added this to the \LanguageServer\Definition class /**
@return bool
*/
public function isVisible(string $match, string $caller, \Microsoft\PhpParser\Node $node): bool
{
$ancestor = $node->getFirstAncestor(\Microsoft\PhpParser\Node\MethodDeclaration::class);
if ($ancestor) {
if ($match !== $caller && $this->isPrivate()) {
return false;
}
} else if ($this->isProtected() || $this->isPrivate()) {
return false;
}
return true;
}
private function isPrivate(): bool { return 'private' === substr($this->declarationLine, 0, 7); }
private function isProtected(): bool { return 'protected' === substr($this->declarationLine, 0, 9); }
Also, the \LanguageServer\CompletionProvider must be modified too.
Line: 245
// Collect all definitions that match any of the prefixes
foreach ($this->index->getDefinitions() as $fqn => $def) {
foreach ($prefixes as $prefix) {
if (substr($fqn, 0, strlen($prefix)) === $prefix &&
$def->isMember &&
$def->isVisible($prefix, $prefixes[0], $node)) {
$list->items[] = CompletionItem::fromDefinition($def);
}
}
}
@gnoe want to submit a pull request? https://help.github.com/articles/creating-a-pull-request/
@felixfbecker, yes, I am going to do it!
Just like said in the title it also suggest the methods that is declared private/public
Here is the class implementing it
Although
php
will also throw an error for this might be better if the intellisense won't suggest anymore.