public void visitAssignmentExpression(GrAssignmentExpression expression) { GrExpression rValue = expression.getRValue(); GrExpression lValue = expression.getLValue(); if (myExpression.equals(rValue)) { PsiType lType = lValue.getNominalType(); if (lType != null) { myResult = new TypeConstraint[] {SubtypeConstraint.create(lType)}; } else if (lValue instanceof GrReferenceExpression) { GroovyResolveResult result = ((GrReferenceExpression) lValue).advancedResolve(); PsiElement resolved = result.getElement(); if (resolved instanceof GrVariable) { PsiType type = ((GrVariable) resolved).getTypeGroovy(); if (type != null) { myResult = new TypeConstraint[] { SubtypeConstraint.create(result.getSubstitutor().substitute(type)) }; } } } } else if (myExpression.equals(lValue)) { if (rValue != null) { PsiType rType = rValue.getType(); if (rType != null) { myResult = new TypeConstraint[] {SupertypeConstraint.create(rType)}; } } } }
public void visitAssignmentExpression(GrAssignmentExpression expression) { GrExpression lValue = expression.getLValue(); if (expression.getOperationTokenType() != mASSIGN) { if (lValue instanceof GrReferenceExpression && myPolicy.isReferenceAccepted((GrReferenceExpression) lValue)) { String referenceName = ((GrReferenceExpression) lValue).getReferenceName(); if (referenceName != null) { addNodeAndCheckPending(new ReadWriteVariableInstruction(referenceName, lValue, READ)); } } } GrExpression rValue = expression.getRValue(); if (rValue != null) { rValue.accept(this); lValue.accept(this); } }
private static boolean assignmentExpressionsAreEquivalent( @NotNull GrAssignmentExpression assignExp1, @NotNull GrAssignmentExpression assignExp2) { final IElementType sign1 = assignExp1.getOperationToken(); final IElementType sign2 = assignExp2.getOperationToken(); if (!sign1.equals(sign2)) { return false; } final GrExpression lhs1 = assignExp1.getLValue(); final GrExpression lhs2 = assignExp2.getLValue(); final GrExpression rhs1 = assignExp1.getRValue(); final GrExpression rhs2 = assignExp2.getRValue(); return expressionsAreEquivalent(lhs1, lhs2) && expressionsAreEquivalent(rhs1, rhs2); }