2 * Copyright 2003-2006 Dave Griffith, Bas Leijdekkers
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package com
.siyeh
.ig
.psiutils
;
18 import com
.intellij
.psi
.*;
19 import org
.jetbrains
.annotations
.NotNull
;
21 public class VariablePassedAsArgumentVisitor
extends JavaRecursiveElementVisitor
{
24 private final PsiVariable variable
;
25 private boolean passed
= false;
27 public VariablePassedAsArgumentVisitor(@NotNull PsiVariable variable
){
29 this.variable
= variable
;
32 @Override public void visitElement(@NotNull PsiElement element
){
34 super.visitElement(element
);
38 @Override public void visitMethodCallExpression(@NotNull PsiMethodCallExpression call
){
42 super.visitMethodCallExpression(call
);
43 final PsiExpressionList argumentList
= call
.getArgumentList();
44 final PsiExpression
[] arguments
= argumentList
.getExpressions();
45 for(final PsiExpression argument
: arguments
){
46 if(VariableAccessUtils
.mayEvaluateToVariable(argument
, variable
)){
52 @Override public void visitNewExpression(@NotNull PsiNewExpression newExpression
){
56 super.visitNewExpression(newExpression
);
57 final PsiExpressionList argumentList
= newExpression
.getArgumentList();
58 if(argumentList
== null){
61 final PsiExpression
[] arguments
= argumentList
.getExpressions();
62 for(final PsiExpression argument
: arguments
){
63 if(VariableAccessUtils
.mayEvaluateToVariable(argument
, variable
)){
69 public boolean isPassed(){