diff --git a/platform/platform-resources-en/src/messages/XmlBundle.properties b/platform/platform-resources-en/src/messages/XmlBundle.properties
index d838ae23f222..00211cd8f9f8 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=Unresolved href target
+html.inspections.unknown.target=File reference problems
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 4a2c4e5ba77b..626613d7eb4e 100644
--- a/platform/platform-resources/src/META-INF/XmlPlugin.xml
+++ b/platform/platform-resources/src/META-INF/XmlPlugin.xml
@@ -360,9 +360,6 @@
-
diff --git a/xml/impl/resources/inspectionDescriptions/HtmlUnknownTarget.html b/xml/impl/resources/inspectionDescriptions/HtmlUnknownTarget.html
index 3cc74b24d077..506b1d63adc0 100644
--- a/xml/impl/resources/inspectionDescriptions/HtmlUnknownTarget.html
+++ b/xml/impl/resources/inspectionDescriptions/HtmlUnknownTarget.html
@@ -1,6 +1,6 @@
-This inspection checks unknown values of "href" attribute in HTML.
+This inspection checks unresolved file references in HTML.
\ 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
deleted file mode 100644
index e02eba110ea7..000000000000
--- a/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/HtmlPathReferenceInspection.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * 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 f97642df1287..c0964deff179 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
@@ -51,6 +51,7 @@ import com.intellij.xml.XmlAttributeDescriptor;
import com.intellij.xml.XmlElementDescriptor;
import com.intellij.xml.XmlExtension;
import com.intellij.xml.impl.schema.AnyXmlElementDescriptor;
+import com.intellij.xml.util.AnchorReference;
import com.intellij.xml.util.HtmlUtil;
import com.intellij.xml.util.XmlTagUtil;
import com.intellij.xml.util.XmlUtil;
@@ -593,9 +594,7 @@ public class XmlHighlightVisitor extends XmlElementVisitor implements HighlightV
for (int i = start; i < references.length; ++i) {
PsiReference reference = references[i];
ProgressManager.checkCanceled();
- if (reference instanceof FileReferenceOwner) {
- continue;
- }
+ if (isUrlReference(reference)) continue;
if (!hasBadResolve(reference, false)) {
continue;
}
@@ -618,9 +617,6 @@ public class XmlHighlightVisitor extends XmlElementVisitor implements HighlightV
if (type.getSeverity(null).compareTo(HighlightInfoType.WARNING.getSeverity(null)) > 0 && name.endsWith("stylename")) {
type = HighlightInfoType.WARNING;
}
- else if (name.equals("href") && type.getSeverity(null) == HighlightInfoType.WARNING.getSeverity(null)) {
- continue;
- }
}
}
HighlightInfo info = HighlightInfo.createHighlightInfo(
@@ -635,6 +631,13 @@ public class XmlHighlightVisitor extends XmlElementVisitor implements HighlightV
}
}
+ public static boolean isUrlReference(PsiReference reference) {
+ if (reference instanceof FileReferenceOwner || reference instanceof AnchorReference) {
+ return true;
+ }
+ return false;
+ }
+
public static String getErrorDescription(final PsiReference reference) {
String message;
if (reference instanceof EmptyResolveMessageProvider) {
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
index ea8bf17013f7..555fa15ab145 100644
--- a/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlPathReferenceInspection.java
+++ b/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlPathReferenceInspection.java
@@ -22,8 +22,9 @@ 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.psi.xml.XmlAttributeValue;
+import com.intellij.psi.xml.XmlDoctype;
+import com.intellij.psi.xml.XmlTag;
import com.intellij.xml.util.HtmlUtil;
import org.jetbrains.annotations.NotNull;
@@ -57,20 +58,15 @@ public class XmlPathReferenceInspection extends XmlSuppressableInspectionTool {
private void checkRefs(PsiElement element, ProblemsHolder holder, boolean isOnTheFly) {
PsiReference[] references = element.getReferences();
for (PsiReference reference : references) {
- if (!(reference instanceof FileReferenceOwner) ||
- XmlHighlightVisitor.skipValidation(element)) {
+ if (!XmlHighlightVisitor.isUrlReference(reference)) {
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 (!isHtml && XmlHighlightVisitor.skipValidation(element)) {
+ continue;
}
if (XmlHighlightVisitor.hasBadResolve(reference, false)) {
holder.registerProblem(reference, ProblemsHolder.unresolvedReferenceMessage(reference),
diff --git a/xml/impl/src/com/intellij/codeInspection/htmlInspections/HtmlUnknownTargetInspection.java b/xml/impl/src/com/intellij/codeInspection/htmlInspections/HtmlUnknownTargetInspection.java
index 427a762bb098..ffef4826f33d 100644
--- a/xml/impl/src/com/intellij/codeInspection/htmlInspections/HtmlUnknownTargetInspection.java
+++ b/xml/impl/src/com/intellij/codeInspection/htmlInspections/HtmlUnknownTargetInspection.java
@@ -15,27 +15,13 @@
*/
package com.intellij.codeInspection.htmlInspections;
-import com.intellij.codeInsight.daemon.impl.analysis.XmlHighlightVisitor;
-import com.intellij.codeInspection.ProblemHighlightType;
-import com.intellij.codeInspection.ProblemsHolder;
-import com.intellij.psi.PsiReference;
-import com.intellij.psi.xml.XmlAttribute;
-import com.intellij.psi.xml.XmlAttributeValue;
-import com.intellij.xml.XmlBundle;
-import com.intellij.xml.util.HtmlUtil;
-import org.jetbrains.annotations.Nls;
+import com.intellij.codeInsight.daemon.impl.analysis.XmlPathReferenceInspection;
import org.jetbrains.annotations.NotNull;
/**
* @author Eugene.Kudelevsky
*/
-public class HtmlUnknownTargetInspection extends HtmlLocalInspectionTool {
- @Nls
- @NotNull
- @Override
- public String getDisplayName() {
- return XmlBundle.message("html.inspections.unknown.target");
- }
+public class HtmlUnknownTargetInspection extends XmlPathReferenceInspection {
@NotNull
@Override
@@ -44,20 +30,7 @@ public class HtmlUnknownTargetInspection extends HtmlLocalInspectionTool {
}
@Override
- protected void checkAttribute(@NotNull XmlAttribute attribute, @NotNull ProblemsHolder holder, boolean isOnTheFly) {
- if (!HtmlUtil.isHtmlTagContainingFile(attribute)) {
- return;
- }
- if (attribute.getLocalName().equalsIgnoreCase("href")) {
- XmlAttributeValue valueElement = attribute.getValueElement();
- if (valueElement != null) {
- PsiReference[] refs = valueElement.getReferences();
- for (PsiReference ref : refs) {
- if (XmlHighlightVisitor.hasBadResolve(ref, false)) {
- holder.registerProblem(ref, ProblemsHolder.unresolvedReferenceMessage(ref), ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
- }
- }
- }
- }
+ protected boolean isForHtml() {
+ return true;
}
}
diff --git a/xml/impl/src/com/intellij/codeInspection/htmlInspections/XmlInspectionToolProvider.java b/xml/impl/src/com/intellij/codeInspection/htmlInspections/XmlInspectionToolProvider.java
index 9ea1ae6f91e2..287591f79901 100644
--- a/xml/impl/src/com/intellij/codeInspection/htmlInspections/XmlInspectionToolProvider.java
+++ b/xml/impl/src/com/intellij/codeInspection/htmlInspections/XmlInspectionToolProvider.java
@@ -40,7 +40,7 @@ public class XmlInspectionToolProvider implements InspectionToolProvider {
XmlUnusedNamespaceInspection.class,
XmlHighlightVisitorBasedInspection.class,
XmlPathReferenceInspection.class,
- HtmlPathReferenceInspection.class
+ HtmlUnknownTargetInspection.class
};
}
}
diff --git a/xml/impl/src/com/intellij/xml/util/AnchorReference.java b/xml/impl/src/com/intellij/xml/util/AnchorReference.java
index 6c5138c802b3..65e0c1a9522e 100644
--- a/xml/impl/src/com/intellij/xml/util/AnchorReference.java
+++ b/xml/impl/src/com/intellij/xml/util/AnchorReference.java
@@ -44,9 +44,9 @@ import java.util.Map;
/**
* @author Maxim.Mossienko
*/
-class AnchorReference implements PsiReference, EmptyResolveMessageProvider {
+public class AnchorReference implements PsiReference, EmptyResolveMessageProvider {
private final String myAnchor;
- private final PsiReference myFileReference;
+ private final FileReference myFileReference;
private final PsiElement myElement;
private final int myOffset;
private final boolean mySoft;