IDEADEV-31824 (Incorrect "manual array copy" warning)
[fedora-idea.git] / plugins / InspectionGadgets / src / com / siyeh / ig / finalization / CallToSuperFinalizeVisitor.java
blob14ba7f33d441c11f232d45d7eaad66d2e7af15f7
1 /*
2 * Copyright 2003-2005 Dave Griffith
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.finalization;
18 import com.intellij.psi.*;
19 import com.siyeh.HardcodedMethodConstants;
20 import org.jetbrains.annotations.NotNull;
22 class CallToSuperFinalizeVisitor extends JavaRecursiveElementVisitor{
24 private boolean callToSuperFinalizeFound = false;
26 @Override public void visitElement(@NotNull PsiElement element){
27 if(!callToSuperFinalizeFound){
28 super.visitElement(element);
32 @Override public void visitMethodCallExpression(
33 @NotNull PsiMethodCallExpression expression){
34 if(callToSuperFinalizeFound){
35 return;
37 super.visitMethodCallExpression(expression);
38 final PsiReferenceExpression methodExpression =
39 expression.getMethodExpression();
40 final PsiExpression target = methodExpression.getQualifierExpression();
41 if(!(target instanceof PsiSuperExpression)){
42 return;
44 final String methodName = methodExpression.getReferenceName();
45 if(!HardcodedMethodConstants.FINALIZE.equals(methodName)){
46 return;
48 callToSuperFinalizeFound = true;
51 public boolean isCallToSuperFinalizeFound(){
52 return callToSuperFinalizeFound;