-
Notifications
You must be signed in to change notification settings - Fork 378
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
Auto complete after new keyword #2010
Conversation
- Add " " into the completion trigger character list - Trigger the completion when meets "new |" Signed-off-by: Sheng Chen <sheche@microsoft.com>
test this please |
BTW there is a discussion about supporting multi-character match at LSP side: microsoft/language-server-protocol#1413 And there are already several extensions use similar solution in this PR to resolve this requirement. Once this new capability is supported in LSP in the future, we can migrate the implementation to the LSP side. |
This works pretty well for me, and we should probably merge. For the sake of discussion, how do we feel about completion being unintentionally triggered for things like : I think using |
Signed-off-by: Sheng Chen <sheche@microsoft.com>
@rgrunber Thank you for the suggestions, leverage AST can definitely make the completion trigger more context-aware! Sharing some thought behind the appended commit:
Checking the response time in the output channel. I didn't see a significant time increase after using
After some attempts, I finally decide to not support this case. Because it needs to add more logic to find a valid offset(skip all the whitespaces), and thus find a valid node via One more thing I found: Currently JDT won't give a right completion proposal when the expected type is an array, which we might need to improve it in upstream. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feel free to merge after taking care of that minor issue listed.
org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/handlers/CompletionHandler.java
Show resolved
Hide resolved
Signed-off-by: Sheng Chen <sheche@microsoft.com>
This PR adds ability to trigger completion when user types "new |".
This can be a handy feature especially when the expected type is an object.
If the expected type is interface, currently JDT will only propose an anonymous class creation, which is not ideal and needs improve from upstream. For such case I've filed an issue there: https://bugs.eclipse.org/bugs/show_bug.cgi?id=578815
fix redhat-developer/vscode-java#1666
Signed-off-by: Sheng Chen sheche@microsoft.com