Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code completion #321

Closed
nadar opened this issue Jun 2, 2018 · 7 comments
Closed

Code completion #321

nadar opened this issue Jun 2, 2018 · 7 comments

Comments

@nadar
Copy link

nadar commented Jun 2, 2018

Hi, maybe i am in the wrong repo but i was not able to find out if its a "missing" feature by design, a wrong configuration or just related to vscode.

I was trying out vscode several times but code completion does not work as expected or as i already mentioned it was never be intended to work like this:

Assuming i have 2 files not in the same directory, but in the same namespace:

foo/Foo1.php:

namespace foo;

class Foo1
{

}

foo/bar/Bar1.php:

namespace foo/bar;

class Bar1
{

}

the code completion is not able to detected the Bar1 class when typing in Foo1. For my understanding of code completion it should be possible to find all classes inside the current work directory while typing. After selecting the class it will be written to use statement section. This is what Eclipse PDT, PHPStorm or others does.

If i have two files in the same directory, the suggestion works but only for files in the same directory.

So i am just wondering if this feature not implemented, does not work on my machine or any other reason? I tested on OSX and Ubuntu 18.10 with latest VSCODE and intellisense extension, also trying to configure the path to the php bin file and disable default completion. For example Eclipse PDT does have an indexing process, afterwards all classes are available (also from vendor folder).

@thetechpanda
Copy link

thetechpanda commented Jun 2, 2018

I have the same issue, this is due the lack of multiroot workspace implementation.

I'm not aware of any other php-intellisense in vscode that supports it.

This is the issue:
felixfbecker/php-language-server#513

@felixfbecker I'm trying to sort out how to help you with this one, any suggestions on what should I study on VSCode side to jump on this? I'm quite skilled on php and I've to say you are a damn good developer.

@felixfbecker
Copy link
Owner

felixfbecker commented Jun 4, 2018

@nadar the language server will look at all subfolders in the workspace, but does not support multiple workspace folders. Are you using multiple workspace folders? Can you give an example where exactly your cursor was when typing Foo1?

@valerio-brew I actually started a WIP PR that I never had the time to finish: felixfbecker/php-language-server#509
It's along those lines - look at all workspaceFolders for indexing and make sure to consider all composer.json/composer.locks. I would love to get help on it.
The spec for workspaceFolders is here: https://microsoft.github.io/language-server-protocol/specification#initialize-request-leftwards_arrow_with_hook

@nadar
Copy link
Author

nadar commented Jun 4, 2018

@felixfbecker I made a quick gif for you => http://www.giphy.com/gifs/1dOKUo82Sfjihom8hg

  • Auto complete suggestion is displayed if already in use statement.
  • Auto complete suggestion works if in the same namespace.

If file is located in another namespace or directory (in vendor like in the gif the Curl class which is located in vendor as you can see) it does not work.

Does that help? Maybe i can provide some more informations?

@felixfbecker
Copy link
Owner

That is as designed. Auto completion suggests you things that are in scope

@nadar
Copy link
Author

nadar commented Jun 4, 2018

Hmm okay, sad. But since composer and vendor folder is so important it would maybe be a good to provide full auto completion so it can compete with PHPStorm, Eclipse PDT and others.

So i am going to close this issue 😢

@thetechpanda
Copy link

thetechpanda commented Jun 4, 2018 via email

@felixfbecker
Copy link
Owner

@nadar I think you are looking for felixfbecker/php-language-server#234

@valerio-brew thanks, I am happy to help give an overview of how this works, feel free to contact me on Gitter (https://gitter.im/felixfbecker/php-language-server or DM me)

@nadar nadar closed this as completed Jun 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants