mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-05-06 05:10:22 +07:00
FoldExpressionIntoStream, StreamApiMigration: EquivalenceChecker used
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.codeInspection.streamMigration;
|
||||
|
||||
import com.intellij.codeInsight.PsiEquivalenceUtil;
|
||||
import com.intellij.codeInspection.*;
|
||||
import com.intellij.codeInspection.util.LambdaGenerationUtil;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -148,7 +147,8 @@ public class FoldExpressionIntoStreamInspection extends AbstractBaseJavaLocalIns
|
||||
PsiExpression delimiter = null;
|
||||
PsiExpression rest = null;
|
||||
if (operands.length > 4 && ExpressionUtils.isSafelyRecomputableExpression(operands[1]) &&
|
||||
IntStreamEx.range(1, operands.length, 2).elements(operands).pairMap(PsiEquivalenceUtil::areElementsEquivalent)
|
||||
IntStreamEx.range(1, operands.length, 2).elements(operands)
|
||||
.pairMap(EquivalenceChecker.getCanonicalPsiEquivalence()::expressionsAreEquivalent)
|
||||
.allMatch(Boolean.TRUE::equals)) {
|
||||
delimiter = operands[1];
|
||||
if (operands.length % 2 == 0) {
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
package com.intellij.codeInspection.streamMigration;
|
||||
|
||||
import com.intellij.codeInsight.ExceptionUtil;
|
||||
import com.intellij.codeInsight.PsiEquivalenceUtil;
|
||||
import com.intellij.codeInsight.daemon.GroupNames;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightControlFlowUtil;
|
||||
import com.intellij.codeInsight.intention.impl.StreamRefactoringUtil;
|
||||
@@ -645,7 +644,7 @@ public class StreamApiMigrationInspection extends AbstractBaseJavaLocalInspectio
|
||||
|
||||
private static boolean isArrayLength(PsiLocalVariable arrayVariable, PsiExpression dimension, PsiExpression bound) {
|
||||
if (ExpressionUtils.isReferenceTo(ExpressionUtils.getArrayFromLengthExpression(bound), arrayVariable)) return true;
|
||||
if (PsiEquivalenceUtil.areElementsEquivalent(dimension, bound)) return true;
|
||||
if (EquivalenceChecker.getCanonicalPsiEquivalence().expressionsAreEquivalent(dimension, bound)) return true;
|
||||
if (bound instanceof PsiMethodCallExpression) {
|
||||
PsiExpression qualifier = ((PsiMethodCallExpression)bound).getMethodExpression().getQualifierExpression();
|
||||
if (qualifier != null && CollectionUtils.isCollectionOrMapSize(dimension, qualifier)) return true;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// "Fold expression into 'String.join'" "true"
|
||||
class Test {
|
||||
void test(String a, String b, String c, String d) {
|
||||
String result = a + "," + b + "," + c + ","<caret> + d + ",";
|
||||
String result = a + "," + b + ((",")) + c + ","<caret> + d + ",";
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import java.util.List;
|
||||
public class Test {
|
||||
public void test(List<Integer> ints) {
|
||||
long[] arr = new long[ints.size()];
|
||||
for(int <caret>i = 0; i < ints.size(); i++) {
|
||||
for(int <caret>i = 0; i < (ints).size(); i++) {
|
||||
arr[i] = ints.get(i);
|
||||
}
|
||||
System.out.println(Arrays.toString(arr));
|
||||
|
||||
Reference in New Issue
Block a user