From d708f1a24503a358ec70fe72e8d75ab7a6616216 Mon Sep 17 00:00:00 2001 From: Dmitry Avdeev Date: Tue, 4 Sep 2012 16:29:14 +0400 Subject: [PATCH] extracting XmlPathReferenceInspection --- .../codeInspection/ProblemsHolder.java | 4 +- .../paths/PathReferenceProviderBase.java | 4 +- .../impl/providers/FileReference.java | 10 +-- .../src/messages/XmlBundle.properties | 2 +- .../src/META-INF/XmlPlugin.xml | 7 ++ .../lang/ant/AntHighlightingTest.java | 5 +- .../referenceContributor/TestNGSuiteTest.java | 12 +-- plugins/testng/testng.iml | 1 + ...omElementResolveProblemDescriptorImpl.java | 10 ++- .../HtmlPathReference.html | 5 ++ .../XmlPathReference.html | 5 ++ .../analysis/HtmlPathReferenceInspection.java | 28 ++++++ .../impl/analysis/XmlHighlightVisitor.java | 9 +- .../analysis/XmlPathReferenceInspection.java | 85 +++++++++++++++++++ .../HtmlUnknownTargetInspection.java | 25 +----- .../XmlInspectionToolProvider.java | 8 +- .../com/intellij/lang/dtd/DTDLanguage.java | 6 +- .../util/CheckDtdReferencesInspection.java | 4 +- .../daemon/XmlHighlightingTest.java | 5 +- .../testData/xml/ComplexSchemaValidation3.xml | 2 +- 20 files changed, 173 insertions(+), 64 deletions(-) create mode 100644 xml/impl/resources/inspectionDescriptions/HtmlPathReference.html create mode 100644 xml/impl/resources/inspectionDescriptions/XmlPathReference.html create mode 100644 xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/HtmlPathReferenceInspection.java create mode 100644 xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlPathReferenceInspection.java diff --git a/platform/lang-api/src/com/intellij/codeInspection/ProblemsHolder.java b/platform/lang-api/src/com/intellij/codeInspection/ProblemsHolder.java index d455d29e6c29..8ce77f2eef98 100644 --- a/platform/lang-api/src/com/intellij/codeInspection/ProblemsHolder.java +++ b/platform/lang-api/src/com/intellij/codeInspection/ProblemsHolder.java @@ -136,10 +136,10 @@ public class ProblemsHolder { } public void registerProblem(@NotNull PsiReference reference) { - registerProblem(reference, inresolvedReferenceMessage(reference), ProblemHighlightType.LIKE_UNKNOWN_SYMBOL); + registerProblem(reference, unresolvedReferenceMessage(reference), ProblemHighlightType.LIKE_UNKNOWN_SYMBOL); } - public static String inresolvedReferenceMessage(PsiReference reference) { + public static String unresolvedReferenceMessage(PsiReference reference) { String message; if (reference instanceof EmptyResolveMessageProvider) { String pattern = ((EmptyResolveMessageProvider)reference).getUnresolvedMessagePattern(); diff --git a/platform/lang-impl/src/com/intellij/openapi/paths/PathReferenceProviderBase.java b/platform/lang-impl/src/com/intellij/openapi/paths/PathReferenceProviderBase.java index 8704fde2031e..ae0e4b15a1b8 100644 --- a/platform/lang-impl/src/com/intellij/openapi/paths/PathReferenceProviderBase.java +++ b/platform/lang-impl/src/com/intellij/openapi/paths/PathReferenceProviderBase.java @@ -26,14 +26,12 @@ public abstract class PathReferenceProviderBase implements PathReferenceProvider final TextRange range = manipulator.getRangeInElement(psiElement); int offset = range.getStartOffset(); int endOffset = range.getEndOffset(); - boolean dynamicContext = false; final String elementText = psiElement.getText(); for (DynamicContextProvider provider: Extensions.getExtensions(DynamicContextProvider.EP_NAME)) { final int dynamicOffset = provider.getOffset(psiElement, offset, elementText); if (dynamicOffset == -1) { return false; } else if (dynamicOffset != offset) { - dynamicContext = true; offset = dynamicOffset; } } @@ -44,7 +42,7 @@ public abstract class PathReferenceProviderBase implements PathReferenceProvider } try { final String text = elementText.substring(offset, endOffset); - return createReferences(psiElement, offset, text, references, soft || dynamicContext); + return createReferences(psiElement, offset, text, references, soft); } catch (StringIndexOutOfBoundsException e) { LOG.error("Cannot process string: '" + psiElement.getParent().getParent().getText() + "'", e); return false; diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/FileReference.java b/platform/lang-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/FileReference.java index ae652a95a1e0..ce1a41ffbb38 100644 --- a/platform/lang-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/FileReference.java +++ b/platform/lang-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/FileReference.java @@ -359,7 +359,7 @@ public class FileReference implements FileReferenceOwner, PsiPolyVariantReferenc @Override public PsiFileSystemItem resolve() { ResolveResult[] resolveResults = multiResolve(false); - return resolveResults.length == 1 ? (PsiFileSystemItem)resolveResults[0].getElement() : null; + return resolveResults.length == 1 ? (PsiFileSystemItem)resolveResults[0].getElement() : null; } @Nullable @@ -533,11 +533,7 @@ public class FileReference implements FileReferenceOwner, PsiPolyVariantReferenc protected PsiElement rename(final String newName) throws IncorrectOperationException { final TextRange range = new TextRange(myFileReferenceSet.getStartInElement(), getRangeInElement().getEndOffset()); PsiElement element = getElement(); - final ElementManipulator manipulator = CachingReference.getManipulator(element); - if (manipulator == null) { - throw new IncorrectOperationException("Manipulator not defined for: " + element + " of class " + element.getClass()); - } - return manipulator.handleContentChange(element, range, newName); + return CachingReference.getManipulator(element).handleContentChange(element, range, newName); } @Override @@ -559,7 +555,7 @@ public class FileReference implements FileReferenceOwner, PsiPolyVariantReferenc public String getUnresolvedMessagePattern() { return LangBundle.message("error.cannot.resolve") + " " + (isLast() ? LangBundle.message("terms.file") : LangBundle.message("terms.directory")) - + " ''" + StringUtil.escapePattern(StringUtil.notNullize(decode(getCanonicalText()))) + "''"; + + " '" + StringUtil.escapePattern(StringUtil.notNullize(decode(getCanonicalText()))) + "'"; } public final boolean isLast() { diff --git a/platform/platform-resources-en/src/messages/XmlBundle.properties b/platform/platform-resources-en/src/messages/XmlBundle.properties index 56c26bca3562..d838ae23f222 100644 --- a/platform/platform-resources-en/src/messages/XmlBundle.properties +++ b/platform/platform-resources-en/src/messages/XmlBundle.properties @@ -57,7 +57,7 @@ html.inspections.form.input.without.label=Form input without an associated label html.inspections.create.label.from.text.before.action=Create a new label from the text before {0} element html.inspections.create.label.from.text.after.action=Create a new label from the text after {0} element html.inspections.create.new.label=Associate a new label with {0} element -html.inspections.unknown.target=Unknown href target +html.inspections.unknown.target=Unresolved href target html.annotators.non.existent.internet.resource=Cannot find resource "{0}" diff --git a/platform/platform-resources/src/META-INF/XmlPlugin.xml b/platform/platform-resources/src/META-INF/XmlPlugin.xml index 9e8c2676c725..3a81db46ba98 100644 --- a/platform/platform-resources/src/META-INF/XmlPlugin.xml +++ b/platform/platform-resources/src/META-INF/XmlPlugin.xml @@ -355,6 +355,13 @@ + + + diff --git a/plugins/ant/tests/src/com/intellij/lang/ant/AntHighlightingTest.java b/plugins/ant/tests/src/com/intellij/lang/ant/AntHighlightingTest.java index a347509231cb..8feb3e204a3c 100644 --- a/plugins/ant/tests/src/com/intellij/lang/ant/AntHighlightingTest.java +++ b/plugins/ant/tests/src/com/intellij/lang/ant/AntHighlightingTest.java @@ -24,6 +24,7 @@ package com.intellij.lang.ant; import com.intellij.codeInsight.daemon.DaemonAnalyzerTestCase; import com.intellij.codeInsight.daemon.impl.HighlightInfo; +import com.intellij.codeInsight.daemon.impl.analysis.XmlPathReferenceInspection; import com.intellij.codeInspection.LocalInspectionTool; import com.intellij.lang.ant.dom.AntResolveInspection; import com.intellij.lang.ant.validation.AntDuplicateTargetsInspection; @@ -137,6 +138,8 @@ public class AntHighlightingTest extends DaemonAnalyzerTestCase { @Override protected LocalInspectionTool[] configureLocalInspectionTools() { - return new LocalInspectionTool[]{new AntDuplicateTargetsInspection(), new AntResolveInspection()}; + return new LocalInspectionTool[]{new AntDuplicateTargetsInspection(), + new AntResolveInspection(), + new XmlPathReferenceInspection()}; } } diff --git a/plugins/testng/testSources/com/theoryinpractice/testng/referenceContributor/TestNGSuiteTest.java b/plugins/testng/testSources/com/theoryinpractice/testng/referenceContributor/TestNGSuiteTest.java index 707632099246..5eef4af65a2f 100644 --- a/plugins/testng/testSources/com/theoryinpractice/testng/referenceContributor/TestNGSuiteTest.java +++ b/plugins/testng/testSources/com/theoryinpractice/testng/referenceContributor/TestNGSuiteTest.java @@ -15,13 +15,12 @@ */ package com.theoryinpractice.testng.referenceContributor; +import com.intellij.codeInsight.daemon.impl.analysis.XmlPathReferenceInspection; import com.intellij.openapi.application.PluginPathManager; import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase; -import com.intellij.util.ArrayUtil; import com.intellij.util.ui.UIUtil; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; -import org.testng.annotations.DataProvider; import org.testng.annotations.Test; /** @@ -73,10 +72,11 @@ public class TestNGSuiteTest extends LightCodeInsightFixtureTestCase { myFixture.addClass("package org.testng.annotations; public @interface Test {}"); myFixture.addClass("package o; @Test public class MyTest { public void testMe(){} }"); myFixture.addFileToProject("subPack/test-unit.xml", "" + - "" + - "" + - "" + - ""); + "" + + "" + + "" + + ""); + myFixture.enableInspections(new XmlPathReferenceInspection()); myFixture.testHighlighting("testng.xml"); } catch (Exception e) { diff --git a/plugins/testng/testng.iml b/plugins/testng/testng.iml index c9048cc509a6..3b83e26f5d24 100644 --- a/plugins/testng/testng.iml +++ b/plugins/testng/testng.iml @@ -23,6 +23,7 @@ + diff --git a/xml/dom-impl/src/com/intellij/util/xml/highlighting/DomElementResolveProblemDescriptorImpl.java b/xml/dom-impl/src/com/intellij/util/xml/highlighting/DomElementResolveProblemDescriptorImpl.java index 725fab9176d3..6f1f9a2cbbcc 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/highlighting/DomElementResolveProblemDescriptorImpl.java +++ b/xml/dom-impl/src/com/intellij/util/xml/highlighting/DomElementResolveProblemDescriptorImpl.java @@ -17,13 +17,15 @@ package com.intellij.util.xml.highlighting; import com.intellij.codeInsight.daemon.impl.analysis.XmlHighlightVisitor; import com.intellij.codeInspection.LocalQuickFix; +import com.intellij.codeInspection.ProblemsHolder; import com.intellij.lang.annotation.HighlightSeverity; -import com.intellij.psi.PsiReference; +import com.intellij.openapi.util.Pair; +import com.intellij.openapi.util.TextRange; import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiReference; +import com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReference; import com.intellij.psi.xml.XmlAttributeValue; import com.intellij.util.xml.GenericDomValue; -import com.intellij.openapi.util.TextRange; -import com.intellij.openapi.util.Pair; import org.jetbrains.annotations.NotNull; /** @@ -33,7 +35,7 @@ class DomElementResolveProblemDescriptorImpl extends DomElementProblemDescriptor @NotNull private final PsiReference myReference; public DomElementResolveProblemDescriptorImpl(@NotNull final GenericDomValue domElement, @NotNull final PsiReference reference, LocalQuickFix... quickFixes) { - super(domElement, XmlHighlightVisitor.getErrorDescription(reference), HighlightSeverity.ERROR, quickFixes); + super(domElement, reference instanceof FileReference ? ProblemsHolder.unresolvedReferenceMessage(reference) : XmlHighlightVisitor.getErrorDescription(reference), HighlightSeverity.ERROR, quickFixes); myReference = reference; } diff --git a/xml/impl/resources/inspectionDescriptions/HtmlPathReference.html b/xml/impl/resources/inspectionDescriptions/HtmlPathReference.html new file mode 100644 index 000000000000..54d0ed0c4bc8 --- /dev/null +++ b/xml/impl/resources/inspectionDescriptions/HtmlPathReference.html @@ -0,0 +1,5 @@ + + +Highlights unresolved file references in HTML. + + \ No newline at end of file diff --git a/xml/impl/resources/inspectionDescriptions/XmlPathReference.html b/xml/impl/resources/inspectionDescriptions/XmlPathReference.html new file mode 100644 index 000000000000..94c9e128a1f8 --- /dev/null +++ b/xml/impl/resources/inspectionDescriptions/XmlPathReference.html @@ -0,0 +1,5 @@ + + +Highlights unresolved file references in XML. + + \ No newline at end of file diff --git a/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/HtmlPathReferenceInspection.java b/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/HtmlPathReferenceInspection.java new file mode 100644 index 000000000000..e02eba110ea7 --- /dev/null +++ b/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/HtmlPathReferenceInspection.java @@ -0,0 +1,28 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.codeInsight.daemon.impl.analysis; + +/** + * @author Dmitry Avdeev + * Date: 9/3/12 + */ +public class HtmlPathReferenceInspection extends XmlPathReferenceInspection { + + @Override + protected boolean isForHtml() { + return true; + } +} diff --git a/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlHighlightVisitor.java b/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlHighlightVisitor.java index 5177c4a9f020..f97642df1287 100644 --- a/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlHighlightVisitor.java +++ b/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlHighlightVisitor.java @@ -41,6 +41,7 @@ import com.intellij.profile.codeInspection.InspectionProjectProfileManager; import com.intellij.psi.*; import com.intellij.psi.html.HtmlTag; import com.intellij.psi.impl.source.SourceTreeToPsiMap; +import com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReferenceOwner; import com.intellij.psi.meta.PsiMetaData; import com.intellij.psi.templateLanguages.OuterLanguageElement; import com.intellij.psi.tree.IElementType; @@ -556,9 +557,10 @@ public class XmlHighlightVisitor extends XmlElementVisitor implements HighlightV } @Override public void visitXmlAttributeValue(XmlAttributeValue value) { + checkReferences(value); + final PsiElement parent = value.getParent(); if (!(parent instanceof XmlAttribute)) { - checkReferences(value); return; } @@ -577,11 +579,8 @@ public class XmlHighlightVisitor extends XmlElementVisitor implements HighlightV getTagProblemInfoType(tag), value, error)); - return; } } - - checkReferences(value); } private void checkReferences(PsiElement value) { @@ -594,7 +593,7 @@ public class XmlHighlightVisitor extends XmlElementVisitor implements HighlightV for (int i = start; i < references.length; ++i) { PsiReference reference = references[i]; ProgressManager.checkCanceled(); - if (reference == null) { + if (reference instanceof FileReferenceOwner) { continue; } if (!hasBadResolve(reference, false)) { diff --git a/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlPathReferenceInspection.java b/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlPathReferenceInspection.java new file mode 100644 index 000000000000..ea8bf17013f7 --- /dev/null +++ b/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlPathReferenceInspection.java @@ -0,0 +1,85 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.codeInsight.daemon.impl.analysis; + +import com.intellij.codeInspection.ProblemHighlightType; +import com.intellij.codeInspection.ProblemsHolder; +import com.intellij.codeInspection.XmlSuppressableInspectionTool; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiElementVisitor; +import com.intellij.psi.PsiReference; +import com.intellij.psi.XmlElementVisitor; +import com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReferenceOwner; +import com.intellij.psi.xml.*; +import com.intellij.xml.util.HtmlUtil; +import org.jetbrains.annotations.NotNull; + +/** + * @author Dmitry Avdeev + * Date: 9/3/12 + */ +public class XmlPathReferenceInspection extends XmlSuppressableInspectionTool { + + @NotNull + @Override + public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, final boolean isOnTheFly) { + return new XmlElementVisitor() { + @Override + public void visitXmlAttributeValue(XmlAttributeValue value) { + checkRefs(value, holder, isOnTheFly); + } + + @Override + public void visitXmlDoctype(XmlDoctype xmlDoctype) { + checkRefs(xmlDoctype, holder, isOnTheFly); + } + + @Override + public void visitXmlTag(XmlTag tag) { + checkRefs(tag, holder, isOnTheFly); + } + }; + } + + private void checkRefs(PsiElement element, ProblemsHolder holder, boolean isOnTheFly) { + PsiReference[] references = element.getReferences(); + for (PsiReference reference : references) { + if (!(reference instanceof FileReferenceOwner) || + XmlHighlightVisitor.skipValidation(element)) { + continue; + } + boolean isHtml = HtmlUtil.isHtmlTagContainingFile(element); + if (isHtml ^ isForHtml()) { + continue; + } + if (isHtml) { + PsiElement parent = element.getParent(); + if (parent instanceof XmlAttribute && "href".equals(((XmlAttribute)parent).getLocalName())) { + // handled by HtmlUnknownTargetInspection + continue; + } + } + if (XmlHighlightVisitor.hasBadResolve(reference, false)) { + holder.registerProblem(reference, ProblemsHolder.unresolvedReferenceMessage(reference), + isHtml ? ProblemHighlightType.GENERIC_ERROR_OR_WARNING : ProblemHighlightType.LIKE_UNKNOWN_SYMBOL); + } + } + } + + protected boolean isForHtml() { + return false; + } +} diff --git a/xml/impl/src/com/intellij/codeInspection/htmlInspections/HtmlUnknownTargetInspection.java b/xml/impl/src/com/intellij/codeInspection/htmlInspections/HtmlUnknownTargetInspection.java index 58c5e1ac94ee..427a762bb098 100644 --- a/xml/impl/src/com/intellij/codeInspection/htmlInspections/HtmlUnknownTargetInspection.java +++ b/xml/impl/src/com/intellij/codeInspection/htmlInspections/HtmlUnknownTargetInspection.java @@ -15,11 +15,9 @@ */ package com.intellij.codeInspection.htmlInspections; -import com.intellij.codeInsight.daemon.EmptyResolveMessageProvider; import com.intellij.codeInsight.daemon.impl.analysis.XmlHighlightVisitor; import com.intellij.codeInspection.ProblemHighlightType; import com.intellij.codeInspection.ProblemsHolder; -import com.intellij.psi.PsiElement; import com.intellij.psi.PsiReference; import com.intellij.psi.xml.XmlAttribute; import com.intellij.psi.xml.XmlAttributeValue; @@ -28,8 +26,6 @@ import com.intellij.xml.util.HtmlUtil; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; -import java.text.MessageFormat; - /** * @author Eugene.Kudelevsky */ @@ -57,25 +53,8 @@ public class HtmlUnknownTargetInspection extends HtmlLocalInspectionTool { if (valueElement != null) { PsiReference[] refs = valueElement.getReferences(); for (PsiReference ref : refs) { - if (ref instanceof EmptyResolveMessageProvider && XmlHighlightVisitor.hasBadResolve(ref, false)) { - - PsiElement element = ref.getElement(); - if (element != null && element.getTextLength() == 0) { - continue; - } - - String messagePattern = ((EmptyResolveMessageProvider)ref).getUnresolvedMessagePattern(); - String description; - try { - description = MessageFormat.format(messagePattern, ref.getCanonicalText()); - } - catch (IllegalArgumentException ex) { - description = messagePattern; - } - if (description != null) { - description += " #loc"; - } - holder.registerProblem(ref, description, ProblemHighlightType.GENERIC_ERROR_OR_WARNING); + if (XmlHighlightVisitor.hasBadResolve(ref, false)) { + holder.registerProblem(ref, ProblemsHolder.unresolvedReferenceMessage(ref), ProblemHighlightType.GENERIC_ERROR_OR_WARNING); } } } diff --git a/xml/impl/src/com/intellij/codeInspection/htmlInspections/XmlInspectionToolProvider.java b/xml/impl/src/com/intellij/codeInspection/htmlInspections/XmlInspectionToolProvider.java index 345809f1cb5e..9ea1ae6f91e2 100644 --- a/xml/impl/src/com/intellij/codeInspection/htmlInspections/XmlInspectionToolProvider.java +++ b/xml/impl/src/com/intellij/codeInspection/htmlInspections/XmlInspectionToolProvider.java @@ -15,9 +15,7 @@ */ package com.intellij.codeInspection.htmlInspections; -import com.intellij.codeInsight.daemon.impl.analysis.XmlHighlightVisitorBasedInspection; -import com.intellij.codeInsight.daemon.impl.analysis.XmlUnboundNsPrefixInspection; -import com.intellij.codeInsight.daemon.impl.analysis.XmlUnusedNamespaceInspection; +import com.intellij.codeInsight.daemon.impl.analysis.*; import com.intellij.codeInspection.InspectionToolProvider; import com.intellij.xml.util.*; @@ -40,7 +38,9 @@ public class XmlInspectionToolProvider implements InspectionToolProvider { HtmlUnknownAttributeInspection.class, XmlUnboundNsPrefixInspection.class, XmlUnusedNamespaceInspection.class, - XmlHighlightVisitorBasedInspection.class + XmlHighlightVisitorBasedInspection.class, + XmlPathReferenceInspection.class, + HtmlPathReferenceInspection.class }; } } diff --git a/xml/impl/src/com/intellij/lang/dtd/DTDLanguage.java b/xml/impl/src/com/intellij/lang/dtd/DTDLanguage.java index fccd1bb98c31..29ce449875f1 100644 --- a/xml/impl/src/com/intellij/lang/dtd/DTDLanguage.java +++ b/xml/impl/src/com/intellij/lang/dtd/DTDLanguage.java @@ -16,7 +16,7 @@ package com.intellij.lang.dtd; import com.intellij.ide.highlighter.XmlFileHighlighter; -import com.intellij.lang.Language; +import com.intellij.lang.xml.XMLLanguage; import com.intellij.openapi.fileTypes.SingleLazyInstanceSyntaxHighlighterFactory; import com.intellij.openapi.fileTypes.SyntaxHighlighter; import com.intellij.openapi.fileTypes.SyntaxHighlighterFactory; @@ -25,12 +25,12 @@ import org.jetbrains.annotations.NotNull; /** * @author max */ -public class DTDLanguage extends Language { +public class DTDLanguage extends XMLLanguage { public static final DTDLanguage INSTANCE = new DTDLanguage(); protected DTDLanguage() { - super("DTD", "text/dtd", "text/x-dtd"); + super(XMLLanguage.INSTANCE, "DTD", "text/dtd", "text/x-dtd"); SyntaxHighlighterFactory.LANGUAGE_FACTORY.addExplicitExtension(this, new SingleLazyInstanceSyntaxHighlighterFactory() { @NotNull protected SyntaxHighlighter createHighlighter() { diff --git a/xml/impl/src/com/intellij/xml/util/CheckDtdReferencesInspection.java b/xml/impl/src/com/intellij/xml/util/CheckDtdReferencesInspection.java index b5962bd6a7b8..5ce4df8d517f 100644 --- a/xml/impl/src/com/intellij/xml/util/CheckDtdReferencesInspection.java +++ b/xml/impl/src/com/intellij/xml/util/CheckDtdReferencesInspection.java @@ -19,7 +19,6 @@ package com.intellij.xml.util; import com.intellij.codeHighlighting.HighlightDisplayLevel; import com.intellij.codeInsight.CodeInsightUtilBase; import com.intellij.codeInsight.daemon.impl.analysis.XmlHighlightVisitor; -import com.intellij.codeInsight.dataflow.map.MapSemilattice; import com.intellij.codeInsight.template.Template; import com.intellij.codeInsight.template.TemplateManager; import com.intellij.codeInspection.*; @@ -29,7 +28,6 @@ import com.intellij.openapi.fileEditor.FileEditorManager; import com.intellij.openapi.fileEditor.OpenFileDescriptor; import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.Ref; import com.intellij.psi.*; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.xml.*; @@ -110,7 +108,7 @@ public class CheckDtdReferencesInspection extends XmlSuppressableInspectionTool final String image = ref.getCanonicalText(); if (image.equals("-") || image.equals("O")) continue; } - holder.registerProblem(ref, XmlHighlightVisitor.getErrorDescription(ref), ProblemHighlightType.LIKE_UNKNOWN_SYMBOL); + holder.registerProblem(ref); } } } diff --git a/xml/tests/src/com/intellij/codeInsight/daemon/XmlHighlightingTest.java b/xml/tests/src/com/intellij/codeInsight/daemon/XmlHighlightingTest.java index 77da07a367d6..fa3797b31a06 100644 --- a/xml/tests/src/com/intellij/codeInsight/daemon/XmlHighlightingTest.java +++ b/xml/tests/src/com/intellij/codeInsight/daemon/XmlHighlightingTest.java @@ -5,6 +5,7 @@ import com.intellij.codeInsight.completion.CodeCompletionHandlerBase; import com.intellij.codeInsight.completion.CompletionType; import com.intellij.codeInsight.daemon.impl.HighlightInfo; import com.intellij.codeInsight.daemon.impl.analysis.XmlHighlightVisitor; +import com.intellij.codeInsight.daemon.impl.analysis.XmlPathReferenceInspection; import com.intellij.codeInsight.daemon.impl.analysis.XmlUnboundNsPrefixInspection; import com.intellij.codeInsight.daemon.impl.quickfix.AddXsiSchemaLocationForExtResourceAction; import com.intellij.codeInsight.lookup.LookupManager; @@ -953,7 +954,8 @@ public class XmlHighlightingTest extends DaemonAnalyzerTestCase { new RequiredAttributesInspection(), new XmlDuplicatedIdInspection(), new CheckDtdReferencesInspection(), - new XmlUnboundNsPrefixInspection() + new XmlUnboundNsPrefixInspection(), + new XmlPathReferenceInspection() }; } @@ -1588,6 +1590,7 @@ public class XmlHighlightingTest extends DaemonAnalyzerTestCase { doTestWithLocations(null, "xsd"); } + @HighlightingFlags(HighlightingFlag.SkipExternalValidation) public void testDtdElementRefs() throws Exception { doTestWithLocations( new String[] [] { diff --git a/xml/tests/testData/xml/ComplexSchemaValidation3.xml b/xml/tests/testData/xml/ComplexSchemaValidation3.xml index e652a7230220..0bfd66abb1ac 100644 --- a/xml/tests/testData/xml/ComplexSchemaValidation3.xml +++ b/xml/tests/testData/xml/ComplexSchemaValidation3.xml @@ -10,7 +10,7 @@ http://schemas.niku.com/2002/service service-2002-02.xsd "> - + <xi:include href="portlets/actionitemTOC.xml"/>