-
Notifications
You must be signed in to change notification settings - Fork 744
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
Prevent SuggestedFixes#renameMethod
from modifying return type declaration
#4043
Prevent SuggestedFixes#renameMethod
from modifying return type declaration
#4043
Conversation
.addOutputLines( | ||
"Test.java", | ||
"class Test {", | ||
" private Object object() {", |
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.
For other reviewers: before this fix Error Prone would suggest:
" private Object object() {", | |
" private object Object() {", |
for (ErrorProneToken token : methodTokens) { | ||
if (token.kind() == TokenKind.IDENTIFIER && token.name().equals(tree.getName())) { | ||
if (token.kind() == TokenKind.IDENTIFIER | ||
&& token.pos() > returnTypeEndPos |
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.
Instead of checking the token positions here, I think we might be able to adjust basePos
earlier and only tokenize from after the return type. Do you see any issues with that approach?
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.
That's a good catch thanks! Will push a commit.
By ensuring the return type
IDENTIFIER
token is not matched.