You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For more advanced completion features language server needs to index files from project. For now it looks that whole process of indexing is not standardized (microsoft/language-server-protocol#54)
I think relying on the PHPStorm stubs is the better way to go.
As for the indexing, here is what I have in my head:
Upon initialization, parse the stub files
Upon a completion request
at the start of a line (no node in front of it)
check if it has been used in the file, try to load it using the autoloader if yes
read the directory (which is equivalent to the current namespace). we can quickly provide the list of files as classes, then resolve additional details with the completionItem/resolve request by parsing it. folders can be provided as namespaces the same way.
check if it is in the globally parsed files (composer.json files property and stubs)
with a namespace name in front it, do the above steps in the typed namespace
with a class in front of it, find the file with the autoloader and parse it, then provide completion
with a variable in front of it, find the definiton (basically what definitionRequest will do), then find out its type (assignment or parameter type hint / docblock. Need some recursive logic here to resolve assignments). If the resolved type is a class, find the file with the autoloader and parse it, then provide completion.
Do you plan redistributing the stub files with the language server? If yes, then looking at the license compatibility would make sense.
Another approach is to download the stub files on demand, i.e. before parsing them during the initialize phase. This way the language server is not tightly coupled to the stub files. Users may even configure the language server to download stub files from a different location. This approach should not qualify as "redistribution" and I don't see any license issue.
downloading on demand would be an option of course, that would put the burden on the user. The extension would have to make it easy for the user to download them and then send the location to the language server. Why can't they just release as ISC/MIT 🙄
I guess you can open an issue to the phpstorm-stubs project and ask to change the license to MIT/ISC.
However, I have read the 4. Redistribution section of the Apache 2.0 license and I don't see any license compatibility issue to distribute the stubs as you have described above.
No, I just wanted to be sure. When we add it as dependency, the license notice will be included in the subfolder, so I guess it should be fine?
By the way: I just did a diff between HvyIndustries/crane-php-stubs and JetBrains/phpstorm-stubs and they are basically the same. Besides changes that were not merged from the upstream and some renames, the files are almost identical and it looks like crane's stubs are based on JetBrain's. Which would mean he copied the JetBrains stubs, removed the README and LICENSE, removed the PHPStorm specific files, and published it in a fresh commit as "crane php stubs". That would be an illegal copyright infringement and a violation of the license terms, which states that the license must be included in all copies.
That is exactly what I do not want to do. Give credit where credit is due.
Maybe I'm wrong and the diff just happens to be similar because it includes the same documentation and signatures. I don't want to falsely accuse anyone here, and it is none of my business, but for this language server I think we shouldn't maintain our own stubs and it's best to include some open source option (without breaking any license).
@Gert-dev thanks for reaching out! This language server is intended to be usable by any IDE as it uses the open language server protocol, which is being implemented by many IDEs. That means if Atom had a LSP client, it could consume it too. The server already has a simple indexer, it just isn't used to provide completion yet, only "go to definition", symbol search, "find all references", hover and parse errors. I am very open to joining efforts, and am particulary interested in how you leveraged the PHP parser to provide completion. Since your codebase is quite large and to not clutter this issue, would you jump on Gitter and explain a bit of your work?
Activity
lgabeskiria commentedon Sep 4, 2016
@felixfbecker you are doing great job!
for built-in php classes, functions you can use https://github.com/JetBrains/phpstorm-stubs
felixfbecker commentedon Sep 6, 2016
Thanks for the hint!
mniewrzal commentedon Sep 6, 2016
For more advanced completion features language server needs to index files from project. For now it looks that whole process of indexing is not standardized (microsoft/language-server-protocol#54)
[-]provideCompletion[/-][+]Completion[/+]kaloyan-raev commentedon Sep 13, 2016
Another repo with PHP Stubs: https://github.com/HvyIndustries/crane-php-stubs
Used by the Crane PHP language server.
felixfbecker commentedon Sep 13, 2016
I think relying on the PHPStorm stubs is the better way to go.
As for the indexing, here is what I have in my head:
used in the file, try to load it using the autoloader if yesfilesproperty and stubs)definitionRequestwill do), then find out its type (assignment or parameter type hint / docblock. Need some recursive logic here to resolve assignments). If the resolved type is a class, find the file with the autoloader and parse it, then provide completion.felixfbecker commentedon Sep 13, 2016
https://github.com/JetBrains/phpstorm-stubs is licensed under Apache 2, while the language server is ISC. Does anyone know if we can use it? Are they compatible? Afaik Apache 2 is more restrictive
kaloyan-raev commentedon Sep 13, 2016
Do you plan redistributing the stub files with the language server? If yes, then looking at the license compatibility would make sense.
Another approach is to download the stub files on demand, i.e. before parsing them during the
initializephase. This way the language server is not tightly coupled to the stub files. Users may even configure the language server to download stub files from a different location. This approach should not qualify as "redistribution" and I don't see any license issue.felixfbecker commentedon Sep 13, 2016
I was planning to add them as dependency with composer:
downloading on demand would be an option of course, that would put the burden on the user. The extension would have to make it easy for the user to download them and then send the location to the language server. Why can't they just release as ISC/MIT 🙄
kaloyan-raev commentedon Sep 13, 2016
I guess you can open an issue to the phpstorm-stubs project and ask to change the license to MIT/ISC.
However, I have read the
4. Redistributionsection of the Apache 2.0 license and I don't see any license compatibility issue to distribute the stubs as you have described above.Is there any particular clause that worries you?
felixfbecker commentedon Sep 13, 2016
No, I just wanted to be sure. When we add it as dependency, the license notice will be included in the subfolder, so I guess it should be fine?
By the way: I just did a diff between HvyIndustries/crane-php-stubs and JetBrains/phpstorm-stubs and they are basically the same. Besides changes that were not merged from the upstream and some renames, the files are almost identical and it looks like crane's stubs are based on JetBrain's. Which would mean he copied the JetBrains stubs, removed the README and LICENSE, removed the PHPStorm specific files, and published it in a fresh commit as "crane php stubs". That would be an illegal copyright infringement and a violation of the license terms, which states that the license must be included in all copies.
That is exactly what I do not want to do. Give credit where credit is due.
kaloyan-raev commentedon Sep 13, 2016
I did not notice that. I agree with you.
felixfbecker commentedon Sep 13, 2016
Maybe I'm wrong and the diff just happens to be similar because it includes the same documentation and signatures. I don't want to falsely accuse anyone here, and it is none of my business, but for this language server I think we shouldn't maintain our own stubs and it's best to include some open source option (without breaking any license).
lgabeskiria commentedon Sep 13, 2016
how about including completion for [global] keyword?
mniewrzal commentedon Sep 13, 2016
I'm experimenting with keywords completion. I prepare simplest possible implementation https://github.com/mniewrzal/php-language-server/tree/keyword_completion. There are two problems. First is that internal PHP support in VS Code also has now keywords completion (results are doubled). But its not very important from language server point of view. Second is microsoft/vscode#11876 and I'm wating for response from Code team.
felixfbecker commentedon Oct 23, 2016
@Gert-dev thanks for reaching out! This language server is intended to be usable by any IDE as it uses the open language server protocol, which is being implemented by many IDEs. That means if Atom had a LSP client, it could consume it too. The server already has a simple indexer, it just isn't used to provide completion yet, only "go to definition", symbol search, "find all references", hover and parse errors. I am very open to joining efforts, and am particulary interested in how you leveraged the PHP parser to provide completion. Since your codebase is quite large and to not clutter this issue, would you jump on Gitter and explain a bit of your work?