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

Add some more quick fixes from LocalCorrectionsBaseSubProcessor. #3372

Merged
merged 1 commit into from
Jan 29, 2025

Conversation

rgrunber
Copy link
Contributor

@rgrunber rgrunber commented Jan 27, 2025

New quick fixes

  • UninitializedLocalVariable, UninitializedLocalVariableHintMissingDefault -> addUninitializedLocalVariableProposal
UninitializedLocalVariable.mp4
  • UnusedTypeParameter -> addUnusedTypeParameterProposal
    • org.eclipse.jdt.core.compiler.problem.unusedTypeParameter
UnusedTypeParameter.mp4
  • DuplicateInheritedDefaultMethods, InheritedDefaultMethodConflictsWithOtherInherited -> addOverrideDefaultMethodProposal
DuplicateInheritedDefaultMethods.mp4
  • I need to verify the line that converts the code action data as it seems a bit odd that we need to List instead of being handled by String[]

@rgrunber
Copy link
Contributor Author

rgrunber commented Jan 29, 2025

I need to verify the line that converts the code action data as it seems a bit odd that we need to List instead of being handled by String[]

Where there's smoke, there's fire. There is actually a regression since #3167 (3 releases ago) ! Basically, any code action that needs the IProblem "arguments" (just a few) is broken. Specifically this line : https://github.com/eclipse-jdtls/eclipse.jdt.ls/pull/3167/files#diff-419f075b7b562e824b4f38f2b6be9714c669ba4e72785216d8352f9517448fdbR354 . We took a given list of string, String [] and needed to convert it to a map, {"arguments": [ "arg1", "arg2", ... ]}. However, when sent/returned from the client, LSP4J has converted it to a JsonObject, where before it was a JsonArray and handled by the existing if. Now we convert the JsonObject to a Map which seems to treat the value as a List, and we don't have a case for this, but this PR deals with it.

stacktrace
[Error - 15:34:18] Request textDocument/codeAction failed.
  Message: Internal error.
  Code: -32603 
java.util.concurrent.CompletionException: java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
	at java.base/java.util.concurrent.CompletableFuture.wrapInCompletionException(CompletableFuture.java:323)
	at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:359)
	at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:364)
	at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:693)
	at java.base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:527)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:507)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1458)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:2034)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:189)
Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
	at org.eclipse.jdt.internal.ui.text.correction.proposals.InitializeFinalFieldProposalCore.<init>(InitializeFinalFieldProposalCore.java:70)
	at org.eclipse.jdt.ls.core.internal.corrections.UnInitializedFinalFieldSubProcessor.createInitializeFinalFieldProposal(UnInitializedFinalFieldSubProcessor.java:35)
	at org.eclipse.jdt.ls.core.internal.corrections.UnInitializedFinalFieldSubProcessor.createInitializeFinalFieldProposal(UnInitializedFinalFieldSubProcessor.java:1)
	at org.eclipse.jdt.internal.ui.text.correction.UnInitializedFinalFieldBaseSubProcessor.addProposals(UnInitializedFinalFieldBaseSubProcessor.java:94)
	at org.eclipse.jdt.ls.core.internal.corrections.QuickFixProcessor.process(QuickFixProcessor.java:165)
	at org.eclipse.jdt.ls.core.internal.corrections.QuickFixProcessor.getCorrections(QuickFixProcessor.java:91)
	at org.eclipse.jdt.ls.core.internal.handlers.CodeActionHandler.getCodeActionCommands(CodeActionHandler.java:190)
	at org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$14(JDTLanguageServer.java:764)
	at org.eclipse.jdt.ls.core.internal.BaseJDTLanguageServer.lambda$0(BaseJDTLanguageServer.java:87)
	at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:690)
	... 5 more

- UninitializedLocalVariable, UninitializedLocalVariableHintMissingDefault
  -> addUninitializedLocalVariableProposal
- UnusedTypeParameter -> addUnusedTypeParameterProposal
- DuplicateInheritedDefaultMethods, InheritedDefaultMethodConflictsWithOtherInherited
  -> addOverrideDefaultMethodProposal
- Fix quick fixes that require diagnostic data (IProblem argumments)

Signed-off-by: Roland Grunberg <[email protected]>
@rgrunber rgrunber force-pushed the upstream-more-fixes branch from 4e7ab77 to 3b1869a Compare January 29, 2025 20:51
@rgrunber rgrunber merged commit 9356c22 into eclipse-jdtls:master Jan 29, 2025
7 checks passed
@rgrunber rgrunber deleted the upstream-more-fixes branch January 29, 2025 22:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant