Skip to content

Commit

Permalink
Setting endPos correctly when deleting the statement
Browse files Browse the repository at this point in the history
  • Loading branch information
Ameya Ketkar committed Dec 2, 2021
1 parent 976d7cc commit 90e2577
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -697,9 +697,9 @@ private Description updateCode(
if (fixBuilder.isEmpty()) {
String replacementString = v.equals(Value.TRUE) ? TRUE : FALSE;
fixBuilder = SuggestedFix.builder().replace(expr, replacementString);
endPos = state.getEndPosition(expr);
}
decrementAllSymbolUsages(expr, state, fixBuilder);
endPos = state.getEndPosition(expr);
return buildDescription(tree).addFix(fixBuilder.build()).build();
}
return Description.NO_MATCH;
Expand Down Expand Up @@ -727,6 +727,7 @@ private SuggestedFix.Builder handleSpecificAPIPatterns(VisitorState state) {
ExpressionStatementTree stmt =
ASTHelpers.findEnclosingNode(state.getPath(), ExpressionStatementTree.class);
if (stmt != null && MOCKITO_UNNECESSARY_MOCKING_PATTERN.matches(stmt.getExpression(), state)) {
endPos = state.getEndPosition(stmt);
return SuggestedFix.builder().delete(stmt);
}
return SuggestedFix.builder();
Expand Down

0 comments on commit 90e2577

Please sign in to comment.