felixfbecker / php-language-server

PHP Implementation of the VS Code Language Server Protocol 🆚↔🖥
ISC License
1.15k stars 185 forks source link

Intellisense autocomplete also suggests private or protected method and properties #469

Open zodiark23 opened 7 years ago

zodiark23 commented 7 years ago

Just like said in the title it also suggest the methods that is declared private/public

image

Here is the class implementing it image

Although php will also throw an error for this might be better if the intellisense won't suggest anymore.

duplicate-issues[bot] commented 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

raheelkhan commented 6 years ago

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.

gnoe commented 5 years ago

Hi, I was checking this issue and I came up with a solution. I added this to the \LanguageServer\Definition class /**

gnoe commented 5 years ago

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); } } }

felixfbecker commented 5 years ago

@gnoe want to submit a pull request? https://help.github.com/articles/creating-a-pull-request/

gnoe commented 5 years ago

@felixfbecker, yes, I am going to do it!