-
Notifications
You must be signed in to change notification settings - Fork 185
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
Completion #165
Completion #165
Conversation
4780b34
to
0be6551
Compare
Current coverage is 95.02% (diff: 96.00%)@@ master #165 diff @@
==========================================
Files 31 34 +3
Lines 416 583 +167
Methods 67 75 +8
Messages 0 0
Branches 0 0
==========================================
+ Hits 394 554 +160
- Misses 22 29 +7
Partials 0 0
|
0be6551
to
44d26ba
Compare
d10e172
to
5125fa7
Compare
Refactor logic into CompletionProvider class
* classes * variables with prefix filtering
* use -> for instance methods/properties * use ::$ for static properties
Hi, I'm trying to play with this PR but I cannot make it working. I'm using code from gif. Is there anything specific I need to do to test it? |
Are trying with VS Code? You need to manually patch your VS Code installation to fix the bugs in VS Code |
Yes, I'm using vscode 1.7.2, but without patching. Only stack trace is for
If you feel its to early to test it let me know, I can wait. |
That is the described bug in VS Code. I have proposed a fix here: https://github.com/Microsoft/vscode-languageserver-node/pull/128/files You need to go into |
Ok, I will give it a try. |
With patch completion works as described :) Thanks! |
Ok, I will take a look at this. |
Never mind, fixed it. I referenced the wrong branch in composer.json. Sorry for the ping. |
I found one issue, such code: <?php
class Test
{
public function getAAA()
{
}
public function getBBB()
{
}
}
$a = new Test();
$a->|getAAA(); If you will invoke completion in place of |
Another issue: <?php
$a->
$a->|getAAA(); Invoke completion in place of
|
@mniewrzal can you get the full stack trace? You need to change this line to @kaloyan-raev I set |
@felixfbecker I updated issue description. |
Fixed, thanks! |
Another thing that is missing (and its important imho) is completion for types. Now its hard to get completion in many places. Simple example: <?php
interface Example {
}
class Test implements Ex| {
} From code I see that completion is limited to closed list of nodes. I think it would be great that if node isn't from handled list (or there is problem with parser) then result list should be as big as possible (types and keywords). It will be filtered by vscode after first letters. |
|
I understand that its doable but until new cases will be supported maybe it would be good approach to return 'everything' that workspace contains. It will also help with cases were parser will be not error tolerant. Of course it can be done later :) |
Another thing that should be considered is completion filtering in server code. This PR is using substring but vscode supports filtering on client side and its 'fuzzy' filtering (e.g. in CSS In general vscode built-in language servers like CSS doesn't do filtering on server side, results list is depends on code context not on prefix. This part was left for client (at least for now). If you feel that this is too much for this PR just merge it and I will open issues for things I mentioned in previous comments :) |
Ok, one more thing that isn't enhancement but a bug ;) Example: <?php
class Test
{
public function def(){}
public function abc()
{
$this->|
}
} No completion after |
The thing is that fuzzy filtering has much worse performance. Remember that we might have to iterate over 100k definitions. Checking the key for a prefix is fast. Doing Is your last bug related to |
I understand, what I wanted to say is that there are many approaches:
Yes, looks like that. I checked this: <?php
class Test
{
public function adef(){
$a = new Test();
$a->
}
} and works ok. |
Yes, but sending 100k suggestions has a performance impact too. I think the current solution is the best compromise for now. This might be #171 then |
@felixfbecker I suggest that we follow the pattern already used for the VSCode language servers implemented by Microsoft, which is:
The pros of the above approach is:
Cons:
If we decide on a stricter server-based filtering to reduce the size of the completion list then:
|
What does "context-based" filtering mean? When giving completions for a method for example, we have to filter by an FQN prefix to filter by the class - so why not include the part of the typed property name too? |
Example for "context-based" filtering. If you have But the completion list should not include:
|
yeah, gotcha. Just saying that the class-filtering is implemented atm by doing a FQN prefix search. So I don't really see the disadvantage of also excluding anything that doesn't match what is already typed? Besides fuzzy searching of course. It saves a few items being sent to the client that don't match anyway. |
I wouldn't worry about the size of the completion list at that place. I don't believe a class can have thousands of methods and members. The largest list is produced when you invoke code completion on an empty line. |
Closes #9 💪
Big ups to @nikic for making this possible with the improvements in error recovery in v3!
Works for properties and methods with all of the recursive type goodness of #54
Todo:
Testing
Two things are preventing a nice testing experience:
null
(PR Treat null as undefined microsoft/vscode-languageserver-node#128)