From 9ba38bc486f402d1c698654cfcdbe4302e655d67 Mon Sep 17 00:00:00 2001 From: Tagir Valeev Date: Mon, 9 Jul 2018 10:42:14 +0700 Subject: [PATCH] StreamApiMigrationInspection: skip parentheses in loop bound --- .../streamMigration/StreamApiMigrationInspection.java | 2 +- .../afterAllActions/beforeToArrayCountedLength2D.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/java/java-impl/src/com/intellij/codeInspection/streamMigration/StreamApiMigrationInspection.java b/java/java-impl/src/com/intellij/codeInspection/streamMigration/StreamApiMigrationInspection.java index d40801ae55c8..300bc0e446ee 100644 --- a/java/java-impl/src/com/intellij/codeInspection/streamMigration/StreamApiMigrationInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/streamMigration/StreamApiMigrationInspection.java @@ -637,7 +637,7 @@ public class StreamApiMigrationInspection extends AbstractBaseJavaLocalInspectio if (arrayType == null || !StreamApiUtil.isSupportedStreamElement(arrayType.getComponentType())) return null; PsiExpression dimension = ArrayUtil.getFirstElement(initializer.getArrayDimensions()); if (dimension == null) return null; - PsiExpression bound = loop.myBound; + PsiExpression bound = PsiUtil.skipParenthesizedExprDown(loop.myBound); if (!isArrayLength(arrayVariable, dimension, bound)) return null; if (VariableAccessUtils.variableIsUsed(arrayVariable, assignment.getRExpression())) return null; return arrayVariable; diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/afterAllActions/beforeToArrayCountedLength2D.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/afterAllActions/beforeToArrayCountedLength2D.java index 10e0048a46eb..8b2ee3231c68 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/afterAllActions/beforeToArrayCountedLength2D.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/afterAllActions/beforeToArrayCountedLength2D.java @@ -5,7 +5,7 @@ import java.util.Arrays; public class Test { public void test(int bound) { Integer[][] arr = new Integer[bound][]; - for(int i = 0; i < arr.length; i++) { + for(int i = 0; i < (arr.length); i++) { arr[i] = new Integer[] {i}; } System.out.println(Arrays.toString(arr));