2 * Copyright 2003-2007 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
.maturity
;
18 import com
.intellij
.psi
.*;
19 import com
.siyeh
.HardcodedMethodConstants
;
20 import com
.siyeh
.InspectionGadgetsBundle
;
21 import com
.siyeh
.ig
.BaseInspection
;
22 import com
.siyeh
.ig
.BaseInspectionVisitor
;
23 import com
.siyeh
.ig
.psiutils
.MethodCallUtils
;
24 import org
.jetbrains
.annotations
.NotNull
;
26 public class ThreadDumpStackInspection
extends BaseInspection
{
29 public String
getID(){
30 return "CallToThreadDumpStack";
33 public String
getDisplayName() {
34 return InspectionGadgetsBundle
.message("dumpstack.call.display.name");
38 public String
buildErrorString(Object
... infos
) {
39 return InspectionGadgetsBundle
.message(
40 "dumpstack.call.problem.descriptor");
43 public BaseInspectionVisitor
buildVisitor() {
44 return new ThreadDumpStackVisitor();
47 private static class ThreadDumpStackVisitor
extends BaseInspectionVisitor
{
49 @Override public void visitMethodCallExpression(
50 @NotNull PsiMethodCallExpression expression
) {
51 super.visitMethodCallExpression(expression
);
52 final String methodName
= MethodCallUtils
.getMethodName(expression
);
53 if (!HardcodedMethodConstants
.DUMP_STACKTRACE
.equals(methodName
)) {
56 final PsiExpressionList argumentList
= expression
.getArgumentList();
57 if (argumentList
.getExpressions().length
!= 0) {
60 final PsiReferenceExpression methodExpression
=
61 expression
.getMethodExpression();
62 final PsiElement element
= methodExpression
.resolve();
63 if (!(element
instanceof PsiMethod
)) {
66 final PsiMethod method
= (PsiMethod
) element
;
67 final PsiClass aClass
= method
.getContainingClass();
72 final String qualifiedName
= aClass
.getQualifiedName();
73 if (!"java.lang.Thread".equals(qualifiedName
)) {
76 registerMethodCallError(expression
);