mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PsiReference.isReferenceTo() used (IDEA-CR-14288)
This commit is contained in:
+1
-1
@@ -134,7 +134,7 @@ public class OptionalIsPresentInspection extends BaseJavaBatchLocalInspectionToo
|
||||
if(!"get".equals(call.getMethodExpression().getReferenceName())) return false;
|
||||
PsiExpression qualifier = call.getMethodExpression().getQualifierExpression();
|
||||
if(!(qualifier instanceof PsiReferenceExpression)) return false;
|
||||
return ((PsiReferenceExpression)qualifier).resolve() == variable;
|
||||
return ((PsiReferenceExpression)qualifier).isReferenceTo(variable);
|
||||
}
|
||||
|
||||
@Contract("null, _ -> false")
|
||||
|
||||
+1
-1
@@ -239,7 +239,7 @@ public class Java8CollectionRemoveIfInspection extends BaseJavaBatchLocalInspect
|
||||
if(!method.equals(expression.getReferenceName())) return false;
|
||||
PsiExpression qualifier = expression.getQualifierExpression();
|
||||
if(!(qualifier instanceof PsiReferenceExpression)) return false;
|
||||
return ((PsiReferenceExpression)qualifier).resolve() == myIterator;
|
||||
return ((PsiReferenceExpression)qualifier).isReferenceTo(myIterator);
|
||||
}
|
||||
|
||||
public PsiVariable getNextElementVariable(PsiStatement statement) {
|
||||
|
||||
+1
-1
@@ -159,7 +159,7 @@ public class Java8ReplaceMapGetInspection extends BaseJavaBatchLocalInspectionTo
|
||||
PsiElement[] elements = declaration.getDeclaredElements();
|
||||
if(elements.length > 0) {
|
||||
PsiElement lastDeclaration = elements[elements.length - 1];
|
||||
if(lastDeclaration instanceof PsiLocalVariable && lastDeclaration == target.resolve()) {
|
||||
if(lastDeclaration instanceof PsiLocalVariable && target.isReferenceTo(lastDeclaration)) {
|
||||
PsiLocalVariable var = (PsiLocalVariable)lastDeclaration;
|
||||
PsiExpression initializer = PsiUtil.skipParenthesizedExprDown(var.getInitializer());
|
||||
if (initializer instanceof PsiMethodCallExpression &&
|
||||
|
||||
+1
-1
@@ -92,7 +92,7 @@ class ReplaceWithFindFirstFix extends MigrateToStreamFix {
|
||||
if(previousAssignment != null) {
|
||||
PsiExpression prevRValue = previousAssignment.getRExpression();
|
||||
PsiExpression prevLValue = previousAssignment.getLExpression();
|
||||
if(prevRValue != null && prevLValue instanceof PsiReferenceExpression && ((PsiReferenceExpression)prevLValue).resolve() == var) {
|
||||
if(prevRValue != null && prevLValue instanceof PsiReferenceExpression && ((PsiReferenceExpression)prevLValue).isReferenceTo(var)) {
|
||||
previousAssignment.delete();
|
||||
return loopStatement.replace(elementFactory.createStatementFromText(
|
||||
var.getName() + " = " + generateOptionalUnwrap(stream, tb, value, prevRValue, var.getType()) + ";", loopStatement));
|
||||
|
||||
+5
-5
@@ -380,7 +380,7 @@ public class StreamApiMigrationInspection extends BaseJavaBatchLocalInspectionTo
|
||||
|
||||
@Contract("_, null -> false")
|
||||
static boolean isIdentityMapping(PsiVariable variable, PsiExpression mapperCall) {
|
||||
return mapperCall instanceof PsiReferenceExpression && ((PsiReferenceExpression)mapperCall).resolve() == variable;
|
||||
return mapperCall instanceof PsiReferenceExpression && ((PsiReferenceExpression)mapperCall).isReferenceTo(variable);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -724,7 +724,7 @@ public class StreamApiMigrationInspection extends BaseJavaBatchLocalInspectionTo
|
||||
if(args.length != 1) return null;
|
||||
comparatorExpression = args[0];
|
||||
}
|
||||
if(!(listExpression instanceof PsiReferenceExpression) || ((PsiReferenceExpression)listExpression).resolve() != list) return null;
|
||||
if(!(listExpression instanceof PsiReferenceExpression) || !((PsiReferenceExpression)listExpression).isReferenceTo(list)) return null;
|
||||
if(comparatorExpression == null || ExpressionUtils.isNullLiteral(comparatorExpression)) return "";
|
||||
return comparatorExpression.getText();
|
||||
}
|
||||
@@ -762,7 +762,7 @@ public class StreamApiMigrationInspection extends BaseJavaBatchLocalInspectionTo
|
||||
PsiExpression qualifierExpression = methodExpression.getQualifierExpression();
|
||||
if (!(qualifierExpression instanceof PsiReferenceExpression)) return null;
|
||||
PsiLocalVariable collectionVariable = extractCollectionVariable(expression.getMethodExpression().getQualifierExpression());
|
||||
if (collectionVariable == null || ((PsiReferenceExpression)qualifierExpression).resolve() != collectionVariable) return null;
|
||||
if (collectionVariable == null || !((PsiReferenceExpression)qualifierExpression).isReferenceTo(collectionVariable)) return null;
|
||||
PsiExpression initializer = collectionVariable.getInitializer();
|
||||
if (initializer == null) return null;
|
||||
PsiType type = initializer.getType();
|
||||
@@ -1080,7 +1080,7 @@ public class StreamApiMigrationInspection extends BaseJavaBatchLocalInspectionTo
|
||||
// check that increment is like for(...;...;i++)
|
||||
if(!(forStatement.getUpdate() instanceof PsiExpressionStatement)) return null;
|
||||
PsiExpression lValue = extractIncrementedLValue(((PsiExpressionStatement)forStatement.getUpdate()).getExpression());
|
||||
if(!(lValue instanceof PsiReferenceExpression) || ((PsiReferenceExpression)lValue).resolve() != counter) return null;
|
||||
if(!(lValue instanceof PsiReferenceExpression) || !((PsiReferenceExpression)lValue).isReferenceTo(counter)) return null;
|
||||
|
||||
// check that condition is like for(...;i<bound;...) or for(...;i<=bound;...)
|
||||
if(!(forStatement.getCondition() instanceof PsiBinaryExpression)) return null;
|
||||
@@ -1104,7 +1104,7 @@ public class StreamApiMigrationInspection extends BaseJavaBatchLocalInspectionTo
|
||||
bound = condition.getLOperand();
|
||||
ref = condition.getROperand();
|
||||
} else return null;
|
||||
if(bound == null || !(ref instanceof PsiReferenceExpression) || ((PsiReferenceExpression)ref).resolve() != counter) return null;
|
||||
if(bound == null || !(ref instanceof PsiReferenceExpression) || !((PsiReferenceExpression)ref).isReferenceTo(counter)) return null;
|
||||
if(!TypeConversionUtil.areTypesAssignmentCompatible(counter.getType(), bound)) return null;
|
||||
return new CountingLoop(counter, initializer, bound, closed);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user