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 stops when code files are reopened #3485

Open
YaduAhuja opened this issue Feb 4, 2024 · 8 comments
Open

Code Completion stops when code files are reopened #3485

YaduAhuja opened this issue Feb 4, 2024 · 8 comments
Labels

Comments

@YaduAhuja
Copy link

YaduAhuja commented Feb 4, 2024

Whenever I open a folder and start to write some java code in it, then it works fine I get autocomplete and everything, but If I close VSCode and open that folder again then everything stops only some basic features work like syntax highlighting etc. even the auto imports feature does not even works until I have cleaned the Java Language server workspace.

Environment
  • Operating System: Windows 10 Version 22H2 Build 19045.3930
  • JDK version: java 21 2023-09-19
  • Visual Studio Code version: Version: 1.86.0 (system setup) Commit: 05047486b6df5eb8d44b2ecd70ea3bdf775fd937
  • Java extension version: v1.27.0
Steps To Reproduce
  1. Open VSCode in an empty folder
  2. Create a java source file with some basic code in it (Like a hello world or read a number through terminal with scanner).
  3. Close VSCode.
  4. Open VSCode in the same folder again.
  5. Create a new java source file with some basic code.
  6. Now code completion will stop working.
Issue Replication Video
Java.Language.server.Issue.mp4

Please attach logs
.log
client.log

Current Result

Screenshot (7)

Expected Result

Screenshot (8)

Additional Informations
@rgrunber rgrunber added the bug label Feb 5, 2024
@rgrunber
Copy link
Member

rgrunber commented Feb 5, 2024

@snjeza let me know if you're able to reproduce this or narrow it down. There's nothing weird in the attached client/server logs that would indicate an error. It just looks like the language server stops responding to textDocument/completion, although it looks like snippets still work. To me that implies some kind of failure in the underlying JDT code completion engine. Maybe the order in which some token was typed broke it ?

I thought maybe it had something to do with the Java 21 String Template completion (eg. STR) but it looks like by the time that shows up, the regular type-baesd completions have already stopped being returned.

Update: Another thing to try is with intellicode, since I can see it in the completion items.

@snjeza
Copy link
Contributor

snjeza commented Feb 8, 2024

I can't reproduce issue.

There's nothing weird in the attached client/server logs that would indicate an error

@YaduAhuja Could you attach all client logs?

Update: Another thing to try is with intellicode, since I can see it in the completion items.

@YaduAhuja Could you try to add

"vsintellicode.java.completionsEnabled": false,

@YaduAhuja
Copy link
Author

YaduAhuja commented Feb 11, 2024

I added the setting you mentioned, Although it did not fixed the issue.

I have attached the logs before adding the setting and after the setting.

If any logs are missing, then let me know how to get them. As of now, I use the Open All Log Files command to get logs.

AfterAddingSetting.zip
BeforeAddingSetting.zip

@snjeza
Copy link
Contributor

snjeza commented Feb 12, 2024

@YaduAhuja Could you attach your settings.json?

@YaduAhuja
Copy link
Author

Did you find anything in logs which can give insight regarding the error.

settings.json

@snjeza
Copy link
Contributor

snjeza commented Feb 14, 2024

Did you find anything in logs which can give insight regarding the error

Yes, I am.

org.eclipse.core.runtime.CoreException: Cannot get completion responses.
	at org.eclipse.jdt.ls.core.internal.ExceptionFactory.newException(ExceptionFactory.java:28)
	at org.eclipse.jdt.ls.core.internal.handlers.CompletionHandler.onDidCompletionItemSelect(CompletionHandler.java:185)
	at org.eclipse.jdt.ls.core.internal.JDTDelegateCommandHandler.executeCommand(JDTDelegateCommandHandler.java:198)
	at org.eclipse.jdt.ls.core.internal.handlers.WorkspaceExecuteCommandHandler$1.run(WorkspaceExecuteCommandHandler.java:230)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:47)
	at org.eclipse.jdt.ls.core.internal.handlers.WorkspaceExecuteCommandHandler.executeCommand(WorkspaceExecuteCommandHandler.java:220)
	at org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$4(JDTLanguageServer.java:616)
	at org.eclipse.jdt.ls.core.internal.BaseJDTLanguageServer.lambda$0(BaseJDTLanguageServer.java:87)
	at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(Unknown Source)
	at java.base/java.util.concurrent.CompletableFuture$Completion.exec(Unknown Source)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(Unknown Source)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(Unknown Source)
	at java.base/java.util.concurrent.ForkJoinPool.scan(Unknown Source)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(Unknown Source)

VS Code calls textDocument/completion before java.completion.onDidSelect
However, I can't reproduce issue.
A related issue - eclipse-jdtls/eclipse.jdt.ls#2362

There are com.oracle.graal.* in your logs. How do you get it?

@YaduAhuja
Copy link
Author

There are com.oracle.graal.* in your logs. How do you get it?

I am using GraalVM JDK 21 from Oracle, that is the reason I think I was getting those completions.

Do you think that maybe this JDK is creating problems for extension ?

Here is a screenshot for graal completions.

Screenshot (9)

Ideally, I think there must be a configuration like we have in Eclipse where we can specify on which keywords a completion is shown. If we had that, then I think we could even improve the performance of this extension, as we can reduce the number of calls made to the language server by making a configuration to give completions only on a list of characters like A-Z and . .

@ghosh-rounak
Copy link

Yes I agree with @YaduAhuja .
This extension is not working at all like other JAVA ide for example Intellij IDEA.
The code completion randomly stops .
For example on typing S the code completion popup should show all valid java keywords including Scanner , String , System , etc. But this code completion behavior does not happen always . Sometimes it just stops to show JAVA keywords on the code completion list and only shows some snippets which are of no use.
The code completion behavior should be consistent and should always show all valid java keywords.
Please fix this extension.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants