mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
html path inspections merged
This commit is contained in:
@@ -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}"
|
||||
|
||||
|
||||
@@ -360,9 +360,6 @@
|
||||
<localInspection language="XML" implementationClass="com.intellij.codeInsight.daemon.impl.analysis.XmlPathReferenceInspection"
|
||||
displayName="File path resolving in XML"
|
||||
groupName="XML" enabledByDefault="true" level="ERROR"/>
|
||||
<localInspection language="XML" implementationClass="com.intellij.codeInsight.daemon.impl.analysis.HtmlPathReferenceInspection"
|
||||
displayName="File path resolving in XML"
|
||||
groupName="XML" enabledByDefault="true" level="WARNING"/>
|
||||
|
||||
<globalInspection shortName="XmlHighlighting" displayName="XML highlighting" groupName="General" enabledByDefault="true" level="ERROR"
|
||||
implementationClass="com.intellij.codeInsight.daemon.impl.analysis.XmlHighlightVisitorBasedInspection"/>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<html>
|
||||
<body>
|
||||
<font face="verdana" size="-1">This inspection checks unknown values of "href" attribute in HTML.<br>
|
||||
<font face="verdana" size="-1">This inspection checks unresolved file references in HTML.<br>
|
||||
</font>
|
||||
</body>
|
||||
</html>
|
||||
-28
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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) {
|
||||
|
||||
+6
-10
@@ -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),
|
||||
|
||||
+4
-31
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@ public class XmlInspectionToolProvider implements InspectionToolProvider {
|
||||
XmlUnusedNamespaceInspection.class,
|
||||
XmlHighlightVisitorBasedInspection.class,
|
||||
XmlPathReferenceInspection.class,
|
||||
HtmlPathReferenceInspection.class
|
||||
HtmlUnknownTargetInspection.class
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user