-
Notifications
You must be signed in to change notification settings - Fork 408
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 'hashCode()' and 'equals()' to Show Fixes for type declaration #1842
Add 'hashCode()' and 'equals()' to Show Fixes for type declaration #1842
Conversation
@@ -555,4 +582,26 @@ public static InnovationContext getInnovationContext(CodeActionParams params, IP | |||
public static ICompilationUnit getCompilationUnit(CodeActionParams params) { | |||
return JDTUtils.resolveCompilationUnit(params.getTextDocument().getUri()); | |||
} | |||
|
|||
public static Optional<Either<Command, CodeAction>> copySourceActionCommand(Optional<Either<Command, CodeAction>> sourceActionCommand) { |
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.
Since this utility is not for source action only, i would use a more generic method name such as
public static Optional<Either<Command, CodeAction>> copyCodeActionCommand(Optional<Either<Command, CodeAction>> codeActionCommand)
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.
According to #1842 (comment), I'd like to remove this method since currently we don't need it.
....jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/text/correction/SourceAssistProcessor.java
Outdated
Show resolved
Hide resolved
....jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/text/correction/SourceAssistProcessor.java
Outdated
Show resolved
Hide resolved
if (node instanceof SimpleName) { | ||
ASTNode parent = node.getParent(); | ||
if (parent instanceof TypeDeclaration) { | ||
quickAssistHashCodeEquals = getHashCodeEqualsAction(params, JavaCodeActionKind.QUICK_ASSIST); |
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.
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.
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.
In the above screenshot, we can get the following information, including it's startpotision and length:
@entity
,@Table(name = "owners")
andpublic
: modifiersOwner
: Class itselfPerson
: extended classSerializable
: implemented interface
For extending the place to show the light bulb, I have the following two plans:
- When the covered node or the covering node is one of the above nodes, we offer the light bulb (in the screenshot, the six red squares will be valid)
- calculate the first startpotision and the last endpotision as construct a range. If the covered node or the covering node is in the range, we offer the light bulb (in the screenshot, all parts between line 46 - line 49 will be valid)
@testforstephen which one do you prefer?
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.
Use 1 to make it consistent with "Move...".
Signed-off-by: Shi Chen <[email protected]>
Signed-off-by: Shi Chen <[email protected]>
e452f1d
to
2385b79
Compare
Signed-off-by: Shi Chen <[email protected]>
commit 1ed1d87 supports more places to show this light bulb, see the following gif: |
test this please |
Signed-off-by: Shi Chen <[email protected]>
....jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/text/correction/SourceAssistProcessor.java
Outdated
Show resolved
Hide resolved
....jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/text/correction/SourceAssistProcessor.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Shi Chen <[email protected]>
Signed-off-by: Shi Chen <[email protected]>
922df18 optimizes the source location, if we use quickfix out of the class body to generate the source, the generated source location will be the end of the class body. see the following gif: |
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.
LGTM
test this please |
Part of redhat-developer/vscode-java#2057
Signed-off-by: Shi Chen [email protected]