2 * Copyright 2000-2009 JetBrains s.r.o.
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.
17 package com
.intellij
.codeInspection
;
19 import com
.intellij
.codeInspection
.reference
.RefElement
;
20 import com
.intellij
.openapi
.util
.TextRange
;
21 import com
.intellij
.psi
.PsiElement
;
22 import com
.intellij
.psi
.PsiFile
;
25 * User: Maxim.Mossienko
29 public class GlobalInspectionUtil
{
30 private static final String LOC_MARKER
= " #loc";
32 static RefElement
retrieveRefElement(PsiElement element
, GlobalInspectionContext globalContext
) {
33 PsiFile elementFile
= element
.getContainingFile();
34 RefElement refElement
= globalContext
.getRefManager().getReference(elementFile
);
35 if (refElement
== null) {
36 PsiElement context
= elementFile
.getContext();
37 if (context
!= null) refElement
= globalContext
.getRefManager().getReference(context
.getContainingFile());
42 public static String
createInspectionMessage(String message
) {
43 return message
+ LOC_MARKER
;
46 public static void createProblem(PsiElement elt
, String message
, ProblemHighlightType problemHighlightType
, TextRange range
,
47 InspectionManager manager
, ProblemDescriptionsProcessor problemDescriptionsProcessor
,
48 GlobalInspectionContext globalContext
) {
49 ProblemDescriptor descriptor
= manager
.createProblemDescriptor(
52 createInspectionMessage(message
),
53 problemHighlightType
, false);
54 problemDescriptionsProcessor
.addProblemElement(
55 retrieveRefElement(elt
, globalContext
),