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

show generate toString()/hashCode() and equals() quick fixes on demand #2213

Merged
merged 2 commits into from
Sep 16, 2022

Conversation

CsCherrYY
Copy link
Contributor

Signed-off-by: Shi Chen chenshi@microsoft.com

This PR will detect the methods of the current type, and choose which quick fix to show.If the current type has corresponding:

  • toString() method without arguments, we do not show generate toString() in quick fixes
  • hashCode() method without arguments and equals() method with an object argument, we do not show generate hashCode() and equals() in quick fixes

Please note that this change will not affect "Source Action" in the right click menu, the "Source Action" part will always show them in case of the user wants to override the methods anyway.

@snjeza
Copy link
Contributor

snjeza commented Sep 6, 2022

test this please

Signed-off-by: Shi Chen <chenshi@microsoft.com>
@CsCherrYY
Copy link
Contributor Author

test this please

@CsCherrYY CsCherrYY marked this pull request as ready for review September 14, 2022 08:28
Copy link
Contributor

@rgrunber rgrunber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall change looks good to me. So once the small issue with tests is addressed, feel free to merge this.

@@ -177,4 +177,23 @@ public void testGenerateToStringQuickAssist_emptyFields() throws JavaModelExcept
quickAssistActions = CodeActionHandlerTest.findActions(codeActions, JavaCodeActionKind.QUICK_ASSIST);
Assert.assertFalse(CodeActionHandlerTest.commandExists(quickAssistActions, CodeActionHandler.COMMAND_ID_APPLY_EDIT, ActionMessages.GenerateToStringAction_label));
}

@Test
public void testGenerateToStringQuickAssistExists() throws JavaModelException {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this method and the one below. Instead of calling them testGenerateToStringQuickAssistExists, testHashCodeEqualsQuickAssistExists , I would call them testNoGenerateToStringQuickAssist & testNoHashCodeEqualsQuickAssist .

Basically, the current name implies that the quick-assist should exist, but I know what you mean is that the method exists so the quick-assist shouldn't. It just might be confusing with the current name.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, Let's make them clear.

Signed-off-by: Shi Chen <chenshi@microsoft.com>
@CsCherrYY CsCherrYY merged commit 8e654d7 into eclipse-jdtls:master Sep 16, 2022
@CsCherrYY CsCherrYY deleted the cs-quickfix-ondemand branch September 16, 2022 05:12
@rgrunber rgrunber added this to the End September milestone Sep 16, 2022
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.

None yet

3 participants