@Override public boolean visitBinaryExpression(BinaryExpression node) { BinaryOperator operator = node.astOperator(); if (operator == BinaryOperator.ASSIGN || operator == BinaryOperator.OR_ASSIGN) { Expression left = node.astLeft(); String variable; if (left instanceof Select && ((Select) left).astOperand() instanceof This) { variable = ((Select) left).astIdentifier().astValue(); } else { variable = left.toString(); } mVariables.add(variable); } return super.visitBinaryExpression(node); } }
@Override public boolean visitBinaryExpression(BinaryExpression node) { if (node.astOperator() == BinaryOperator.ASSIGN) { Expression rhs = node.astRight(); if (rhs instanceof VariableReference) { JavaParser.ResolvedNode resolved = mContext.resolve(rhs); //noinspection SuspiciousMethodCalls if (resolved != null && mVariables.contains(resolved)) { JavaParser.ResolvedNode resolvedLhs = mContext.resolve(node.astLeft()); if (resolvedLhs instanceof JavaParser.ResolvedVariable) { JavaParser.ResolvedVariable variable = (JavaParser.ResolvedVariable) resolvedLhs; mVariables.add(variable); } } } } return super.visitBinaryExpression(node); }
@Override public boolean visitBinaryExpression(BinaryExpression node) { if (node.astOperator() == BinaryOperator.ASSIGN) { Expression rhs = node.astRight(); if (rhs instanceof VariableReference) { ResolvedNode resolved = mContext.resolve(rhs); //noinspection SuspiciousMethodCalls if (resolved != null && mVariables.contains(resolved)) { ResolvedNode resolvedLhs = mContext.resolve(node.astLeft()); if (resolvedLhs instanceof ResolvedVariable) { ResolvedVariable variable = (ResolvedVariable) resolvedLhs; mVariables.add(variable); } else if (resolvedLhs instanceof ResolvedField) { mEscapes = true; } } } } return super.visitBinaryExpression(node); }