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

Duplicate quick fixes when shown at line #2236

Closed
0dinD opened this issue Nov 29, 2021 · 6 comments · Fixed by eclipse-jdtls/eclipse.jdt.ls#1982
Closed

Duplicate quick fixes when shown at line #2236

0dinD opened this issue Nov 29, 2021 · 6 comments · Fixed by eclipse-jdtls/eclipse.jdt.ls#1982

Comments

@0dinD
Copy link
Contributor

0dinD commented Nov 29, 2021

When java.quickfix.showAt is set to line (the default), duplicate quick fixes are shown in certain scenarios.

Environment
  • Java extension version: 1.1.0
Steps To Reproduce
  1. Have the following code:
package com.example;

public class Foo {

	List list = List.of();

}
  1. Show quick fixes for adding the missing import for List.
Current Result

The actions in the quick fix menu are duplicated (if java.quickfix.showAt is set to line).

Expected Result

The actions in the quick fix menu are not duplicated even if java.quickfix.showAt is set to line.

Additional Information

The problem appears to be that quick fixes for both problem occurrences are shown at the same time when they occur at the same line. I cannot reproduce the issue when I put a newline after the = operator.

@rgrunber
Copy link
Member

Are there any other cases where 2 different types of problems/diagnostics with the same resolution can appear on the same line ?

@rgrunber rgrunber added this to the End January 2022 milestone Jan 11, 2022
@snjeza
Copy link
Contributor

snjeza commented Jan 11, 2022

Are there any other cases where 2 different types of problems/diagnostics with the same resolution can appear on the same line ?

In my opinion there aren't any.

@0dinD
Copy link
Contributor Author

0dinD commented Jan 13, 2022

I haven't had time to investigate it that much, but what I've found is that it occurs for variable declarations (fields and local variables), but not for parameter declarations:

package com.example;

public class Foo {

	List list = List.of(); // Duplicate quick fixes

	public void bar(List list1, List list2) { // No duplicates
		List list = List.of(); // Duplicate quick fixes
	}

}

@rgrunber
Copy link
Member

rgrunber commented Jan 13, 2022

I haven't had time to investigate it that much, but what I've found is that it occurs for variable declarations (fields and local variables), but not for parameter declarations:

I guess because the parameter declarations are the same type of problem ID, whereas the example below it are different problem IDs.

@snjeza
Copy link
Contributor

snjeza commented Jan 13, 2022

@0dinD
Copy link
Contributor Author

0dinD commented Jan 14, 2022

@snjeza your build fixes the issue for me in both examples 👍

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

Successfully merging a pull request may close this issue.

3 participants