mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
StreamApiMigrationInspection: AIOOBE fixed, unused variable removed, foreach -> forEach
This commit is contained in:
+7
-2
@@ -120,6 +120,8 @@ public class StreamApiMigrationInspection extends BaseJavaBatchLocalInspectionTo
|
||||
TerminalBlock tb = TerminalBlock.from(statement.getIterationParameter(), body);
|
||||
List<Operation> operations = tb.extractOperations();
|
||||
|
||||
if(tb.isEmpty()) return;
|
||||
|
||||
final ControlFlow controlFlow = ControlFlowFactory.getInstance(holder.getProject())
|
||||
.getControlFlow(body, LocalsOrMyInstanceFieldsControlFlowPolicy.getInstance());
|
||||
final Collection<PsiStatement> exitPoints = ControlFlowUtil
|
||||
@@ -174,7 +176,7 @@ public class StreamApiMigrationInspection extends BaseJavaBatchLocalInspectionTo
|
||||
//for .stream()
|
||||
fixes.add(new ReplaceWithForeachCallFix("forEachOrdered"));
|
||||
}
|
||||
holder.registerProblem(iteratedValue, "Can be replaced with foreach call",
|
||||
holder.registerProblem(iteratedValue, "Can be replaced with forEach call",
|
||||
ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
|
||||
fixes.toArray(new LocalQuickFix[fixes.size()]));
|
||||
}
|
||||
@@ -705,7 +707,6 @@ public class StreamApiMigrationInspection extends BaseJavaBatchLocalInspectionTo
|
||||
}
|
||||
intermediateOps
|
||||
.add(createMapperFunctionalExpressionText(tb.getVariable(), methodCallExpression.getArgumentList().getExpressions()[0]));
|
||||
PsiType itemType = methodCallExpression.getArgumentList().getExpressionTypes()[0];
|
||||
final StringBuilder builder = generateStream(iteratedValue, intermediateOps);
|
||||
|
||||
final PsiExpression qualifierExpression = methodCallExpression.getMethodExpression().getQualifierExpression();
|
||||
@@ -1138,6 +1139,10 @@ public class StreamApiMigrationInspection extends BaseJavaBatchLocalInspectionTo
|
||||
return myVariable;
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return myStatements.length == 0;
|
||||
}
|
||||
|
||||
@Contract("_, _ -> !null")
|
||||
static TerminalBlock from(PsiVariable variable, PsiStatement statement) {
|
||||
return new TerminalBlock(variable, new PsiStatement[] {statement});
|
||||
|
||||
Reference in New Issue
Block a user