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
.threading
;
18 import com
.intellij
.psi
.PsiMethodCallExpression
;
19 import com
.intellij
.psi
.PsiType
;
20 import com
.siyeh
.InspectionGadgetsBundle
;
21 import com
.siyeh
.ig
.BaseInspection
;
22 import com
.siyeh
.ig
.BaseInspectionVisitor
;
23 import com
.siyeh
.ig
.psiutils
.ControlFlowUtils
;
24 import com
.siyeh
.ig
.psiutils
.MethodCallUtils
;
25 import org
.jetbrains
.annotations
.NotNull
;
27 public class AwaitNotInLoopInspection
extends BaseInspection
{
30 public String
getDisplayName() {
31 return InspectionGadgetsBundle
.message(
32 "await.not.in.loop.display.name");
36 protected String
buildErrorString(Object
... infos
) {
37 return InspectionGadgetsBundle
.message(
38 "await.not.in.loop.problem.descriptor");
41 public BaseInspectionVisitor
buildVisitor() {
42 return new AwaitNotInLoopVisitor();
45 private static class AwaitNotInLoopVisitor
extends BaseInspectionVisitor
{
47 @Override public void visitMethodCallExpression(
48 @NotNull PsiMethodCallExpression expression
) {
49 super.visitMethodCallExpression(expression
);
50 if (!MethodCallUtils
.isCallToMethod(expression
,
51 "java.util.concurrent.locks.Condition", PsiType
.VOID
,
55 if (ControlFlowUtils
.isInLoop(expression
)) {
58 registerMethodCallError(expression
);