mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Java inspection: Update messages related to forEachOrdered() in the inspection "Replace coll.stream().forEachOrdered(..) with coll.forEach(..)"
This commit is contained in:
+11
-4
@@ -81,9 +81,16 @@ public class SimplifyStreamApiCallChainsInspection extends BaseJavaBatchLocalIns
|
||||
}
|
||||
final PsiMethodCallExpression qualifierCall = getQualifierMethodCall(methodCall);
|
||||
if (isCallOf(qualifierCall, CommonClassNames.JAVA_UTIL_COLLECTION, STREAM_METHOD, 0)) {
|
||||
holder.registerProblem(methodCall, getCallChainRange(methodCall, qualifierCall),
|
||||
"Collection.stream()." + name + "() can be replaced with Collection.forEach()",
|
||||
FOR_EACH_METHOD.equals(name) ? new CollectionForEachFix() : new CollectionForEachOrderedFix());
|
||||
String message = "Collection.stream()." + name + "() can be replaced with Collection.forEach()";
|
||||
final LocalQuickFix fix;
|
||||
if (FOR_EACH_METHOD.equals(name)) {
|
||||
fix = new CollectionForEachFix();
|
||||
}
|
||||
else {
|
||||
fix = new CollectionForEachOrderedFix();
|
||||
message += " (may change semantics)";
|
||||
}
|
||||
holder.registerProblem(methodCall, getCallChainRange(methodCall, qualifierCall), message, fix);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -221,7 +228,7 @@ public class SimplifyStreamApiCallChainsInspection extends BaseJavaBatchLocalIns
|
||||
@NotNull
|
||||
@Override
|
||||
public String getFamilyName() {
|
||||
return "Replace Collection.stream()." + FOR_EACH_ORDERED_METHOD + "() with Collection.forEach()";
|
||||
return "Replace Collection.stream()." + FOR_EACH_ORDERED_METHOD + "() with Collection.forEach() (may change semantics)";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Replace Collection.stream().forEachOrdered() with Collection.forEach()" "true"
|
||||
// "Replace Collection.stream().forEachOrdered() with Collection.forEach() (may change semantics)" "true"
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Replace Collection.stream().forEachOrdered() with Collection.forEach()" "true"
|
||||
// "Replace Collection.stream().forEachOrdered() with Collection.forEach() (may change semantics)" "true"
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
<html>
|
||||
<body>
|
||||
This inspection reports stream API call chains which can be simplified.
|
||||
It allows to avoid creating redundant temporary objects without changing semantics.
|
||||
<br>
|
||||
For example, Collection.stream().forEach() can be replaced with Collection.forEach()
|
||||
It allows to avoid creating redundant temporary objects when traversing a collection.
|
||||
<p>
|
||||
For example, <b>Collection.stream().forEach()</b> can be replaced with <b>Collection.forEach()</b>.
|
||||
<p>
|
||||
Note that <b>forEachOrdered()</b> is a special case. While the traversal order of <b>Collection.forEach()</b> is usually the same as with
|
||||
<b>Collection.stream().forEachOrdered()</b>, specific implementations may override that. Please check the documentation on the collection's implementation.
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user