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.
16 package com
.intellij
.codeInsight
.daemon
.impl
.analysis
;
18 import com
.intellij
.analysis
.AnalysisScope
;
19 import com
.intellij
.codeHighlighting
.HighlightDisplayLevel
;
20 import com
.intellij
.codeInsight
.daemon
.impl
.HighlightInfo
;
21 import com
.intellij
.codeInsight
.daemon
.impl
.HighlightInfoFilter
;
22 import com
.intellij
.codeInspection
.*;
23 import com
.intellij
.openapi
.util
.TextRange
;
24 import com
.intellij
.psi
.PsiElement
;
25 import com
.intellij
.psi
.PsiFile
;
26 import com
.intellij
.psi
.XmlRecursiveElementVisitor
;
27 import org
.jetbrains
.annotations
.Nls
;
28 import org
.jetbrains
.annotations
.NotNull
;
29 import org
.jetbrains
.annotations
.Nullable
;
34 public class XmlHighlightVisitorBasedInspection
extends GlobalInspectionTool
{
36 public boolean isGraphNeeded() {
42 public HighlightDisplayLevel
getDefaultLevel() {
43 return HighlightDisplayLevel
.ERROR
;
47 public void runInspection(AnalysisScope scope
,
48 final InspectionManager manager
,
49 final GlobalInspectionContext globalContext
,
50 final ProblemDescriptionsProcessor problemDescriptionsProcessor
) {
51 scope
.accept(new XmlRecursiveElementVisitor() {
52 final XmlHighlightVisitor highlightVisitor
= new XmlHighlightVisitor();
54 HighlightInfoHolder myHolder
;
57 public void visitFile(final PsiFile file
) {
58 myHolder
= new HighlightInfoHolder(file
, HighlightInfoFilter
.EMPTY_ARRAY
) {
60 public boolean add(@Nullable HighlightInfo info
) {
62 ProblemHighlightType problemHighlightType
= HighlightInfo
.convertType(info
.type
);
63 GlobalInspectionUtil
.createProblem(
67 new TextRange(info
.startOffset
, info
.endOffset
),
69 problemDescriptionsProcessor
,
76 myHolder
.setWritable(true);
77 super.visitFile(file
);
81 public void visitElement(PsiElement element
) {
82 highlightVisitor
.visit(element
, myHolder
);
83 super.visitElement(element
);
91 public String
getGroupDisplayName() {
98 public String
getDisplayName() {
99 return "Xml Highlighting";
104 public String
getShortName() {
105 return "XmlHighlighting";