diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/ImplicitLocaleUsage.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/ImplicitLocaleUsage.java index 1af47c3a22..05f6d8823f 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/ImplicitLocaleUsage.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/ImplicitLocaleUsage.java @@ -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))