Skip to content

Commit

Permalink
Another gotcha
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephan202 authored and mlrprananta committed Dec 5, 2022
1 parent d3d6c93 commit f9acde6
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ public Description matchMethodInvocation(MethodInvocationTree tree, VisitorState
}

private static Fix suggestLocale(MethodInvocationTree tree, String locale, VisitorState state) {
// XXX: The logic that replaces the first parenthesis assumes that `tree` does not have a source
// code representation such as `str.toLowerCase/* Some comment with parens (). */()`. In such a
// case the comment, rather than the method invocation arguments, will be modified. Implement a
// generic solution for this.
return SuggestedFix.builder()
.addImport("java.util.Locale")
.replace(tree, SourceCode.treeToString(tree, state).replaceFirst("\\(", '(' + locale))
Expand Down

0 comments on commit f9acde6

Please sign in to comment.