IDEA-168296 Comments are duplicated when I replace Map.entrySet() loop with Map.forEach

This commit is contained in:
Tagir Valeev
2017-02-17 12:15:58 +07:00
parent 4230df9ede
commit 86b7bcfe0a
3 changed files with 13 additions and 1 deletions
@@ -191,7 +191,7 @@ public class Java8MapForEachInspection extends BaseJavaBatchLocalInspectionTool
LambdaRefactoringUtil.simplifyToExpressionLambda(newLambda);
entrySetCall.getArgumentList().add(newLambda);
ExpressionUtils.bindCallTo(entrySetCall, "forEach");
return entrySetCall.getText();
return ct.text(entrySetCall);
}
private static void fixInForeach(PsiForeachStatement loop) {
@@ -86,4 +86,10 @@ public class Test {
System.out.println(str + ":" + num);
});
}
void forEach(Map<String, String> map) {
map.forEach((key, value) -> {
//long comment
});
}
}
@@ -108,4 +108,10 @@ public class Test {
System.out.println(str + ":" + num);
}
}
void forEach(Map<String, String> map) {
for (Map.Entry<String, String> entry : map.entrySet()) {
//long comment
}
}
}