xml: inspection group names fixed

This commit is contained in:
Roman Shevchenko
2015-06-15 18:22:09 +03:00
parent b6a462414e
commit 70cad880f3
5 changed files with 95 additions and 76 deletions
@@ -164,6 +164,15 @@ html.add.table.column.after.action=Add a new column to the table after the curre
html.add.table.column.before.action=Add a new column to the table before the current one
xml.javadoc.enumeration.value.message=Enumeration value
xml.inspections.unused.schema=Unused XML schema declaration
xml.inspections.unused.schema.location=Namespace location is never used
xml.inspections.unused.schema.declaration=Namespace declaration is never used
xml.inspections.unused.schema.remove=Remove unused namespace declaration
xml.inspections.path.resolve=File path resolving in XML
xml.inspections.global=XML highlighting
#xsd2xml and xml2xsd
url.is.empty.validation.problem=Url is empty
invalid.number.validation.problem=Invalid number
@@ -390,64 +390,85 @@
<iconProvider implementation="com.intellij.xml.util.XmlIconProvider"/>
<localInspection language="XML" shortName="CheckTagEmptyBody" bundle="messages.XmlBundle" key="xml.inspections.check.tag.empty.body"
groupKey="xml.inspections.group.name" enabledByDefault="true" level="WARNING"
<localInspection language="XML" shortName="CheckTagEmptyBody" enabledByDefault="true" level="WARNING"
bundle="messages.XmlBundle" key="xml.inspections.check.tag.empty.body"
groupBundle="messages.XmlBundle" groupKey="xml.inspections.group.name"
implementationClass="com.intellij.xml.util.CheckTagEmptyBodyInspection"/>
<!-- TODO: assign it to XML & DTD -->
<localInspection shortName="CheckDtdRefs" bundle="messages.XmlBundle" key="xml.inspections.check.dtd.references" groupName="XML"
enabledByDefault="true" level="ERROR" implementationClass="com.intellij.xml.util.CheckDtdReferencesInspection"/>
<localInspection language="XML" shortName="CheckEmptyScriptTag" bundle="messages.XmlBundle" key="html.inspections.check.empty.tag" groupName="HTML"
enabledByDefault="true" level="WARNING" implementationClass="com.intellij.xml.util.CheckEmptyTagInspection"/>
<localInspection language="XML" shortName="CheckValidXmlInScriptTagBody" bundle="messages.XmlBundle" key="html.inspections.check.valid.script.tag"
groupName="HTML" enabledByDefault="true" level="ERROR"
implementationClass="com.intellij.xml.util.CheckValidXmlInScriptBodyInspection"/>
<localInspection language="XML" shortName="CheckXmlFileWithXercesValidator" bundle="messages.XmlBundle" key="xml.inspections.check.file.with.xerces"
groupName="XML" enabledByDefault="true" level="ERROR"
<localInspection shortName="CheckDtdRefs" enabledByDefault="true" level="ERROR"
bundle="messages.XmlBundle" key="xml.inspections.check.dtd.references"
groupBundle="messages.XmlBundle" groupKey="xml.inspections.group.name"
implementationClass="com.intellij.xml.util.CheckDtdReferencesInspection"/>
<localInspection language="XML" shortName="CheckXmlFileWithXercesValidator" enabledByDefault="true" level="ERROR"
bundle="messages.XmlBundle" key="xml.inspections.check.file.with.xerces"
groupBundle="messages.XmlBundle" groupKey="xml.inspections.group.name"
implementationClass="com.intellij.xml.util.CheckXmlFileWithXercesValidatorInspection" unfair="true"/>
<localInspection language="XML" bundle="messages.XmlBundle" key="xml.inspections.duplicate.id"
groupKey="xml.inspections.group.name" enabledByDefault="true" level="ERROR" runForWholeFile="true" unfair="true"
<localInspection language="XML" enabledByDefault="true" level="ERROR" runForWholeFile="true" unfair="true"
bundle="messages.XmlBundle" key="xml.inspections.duplicate.id"
groupBundle="messages.XmlBundle" groupKey="xml.inspections.group.name"
implementationClass="com.intellij.xml.util.XmlDuplicatedIdInspection"/>
<localInspection language="XML" bundle="messages.XmlBundle" key="xml.inspections.invalid.id"
groupKey="xml.inspections.group.name" enabledByDefault="true" level="ERROR" runForWholeFile="true" unfair="true"
groupBundle="messages.XmlBundle" groupKey="xml.inspections.group.name"
enabledByDefault="true" level="ERROR" runForWholeFile="true" unfair="true"
implementationClass="com.intellij.xml.util.XmlInvalidIdInspection"/>
<localInspection language="XML" shortName="RequiredAttributes" bundle="messages.InspectionsBundle" key="inspection.required.attributes.display.name"
groupName="HTML" enabledByDefault="true" level="WARNING"
implementationClass="com.intellij.codeInspection.htmlInspections.RequiredAttributesInspection" unfair="true"/>
<localInspection language="XML" shortName="HtmlExtraClosingTag" bundle="messages.XmlBundle" key="html.inspection.extra.closing.tag" groupName="HTML"
enabledByDefault="true" level="ERROR"
implementationClass="com.intellij.codeInspection.htmlInspections.HtmlExtraClosingTagInspection"/>
<localInspection language="XML" shortName="XmlWrongRootElement" bundle="messages.XmlBundle" key="xml.inspection.wrong.root.element" groupName="XML"
<localInspection language="XML" shortName="XmlWrongRootElement"
bundle="messages.XmlBundle" key="xml.inspection.wrong.root.element"
groupBundle="messages.XmlBundle" groupKey="xml.inspections.group.name"
enabledByDefault="true" level="ERROR"
implementationClass="com.intellij.codeInspection.htmlInspections.XmlWrongRootElementInspection"/>
<localInspection language="XML" shortName="HtmlUnknownTag" bundle="messages.XmlBundle" key="html.inspections.unknown.tag" groupName="HTML"
enabledByDefault="true" level="WARNING"
implementationClass="com.intellij.codeInspection.htmlInspections.HtmlUnknownTagInspection"/>
<localInspection language="XML" shortName="HtmlUnknownAttribute" bundle="messages.XmlBundle" key="html.inspections.unknown.attribute" groupName="HTML"
enabledByDefault="true" level="WARNING"
implementationClass="com.intellij.codeInspection.htmlInspections.HtmlUnknownAttributeInspection"/>
<localInspection language="XML" bundle="messages.XmlBundle" key="html.inspections.unknown.boolean.attribute" groupName="HTML"
enabledByDefault="true" level="WARNING"
implementationClass="com.intellij.codeInspection.htmlInspections.HtmlUnknownBooleanAttributeInspection"/>
<localInspection language="XML" shortName="XmlUnboundNsPrefix" bundle="messages.XmlBundle" key="xml.inspections.unbound.prefix"
groupKey="xml.inspections.group.name" enabledByDefault="true" level="WARNING"
<localInspection language="XML" shortName="XmlUnboundNsPrefix" enabledByDefault="true" level="WARNING"
bundle="messages.XmlBundle" key="xml.inspections.unbound.prefix"
groupBundle="messages.XmlBundle" groupKey="xml.inspections.group.name"
implementationClass="com.intellij.codeInsight.daemon.impl.analysis.XmlUnboundNsPrefixInspection"/>
<localInspection language="XML" shortName="XmlUnusedNamespaceDeclaration" displayName="Unused XML schema declaration"
groupKey="xml.inspections.group.name" bundle="messages.XmlBundle" enabledByDefault="true" level="WARNING"
<localInspection language="XML" shortName="XmlUnusedNamespaceDeclaration" enabledByDefault="true" level="WARNING"
bundle="messages.XmlBundle" key="xml.inspections.unused.schema"
groupBundle="messages.XmlBundle" groupKey="xml.inspections.group.name"
implementationClass="com.intellij.codeInsight.daemon.impl.analysis.XmlUnusedNamespaceInspection"/>
<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" shortName="HtmlUnknownTarget" bundle="messages.XmlBundle" key="html.inspections.unknown.target" groupName="HTML"
enabledByDefault="true" level="WARNING"
<localInspection language="XML" enabledByDefault="true" level="ERROR"
bundle="messages.XmlBundle" key="xml.inspections.path.resolve"
groupBundle="messages.XmlBundle" groupKey="xml.inspections.group.name"
implementationClass="com.intellij.codeInsight.daemon.impl.analysis.XmlPathReferenceInspection"/>
<localInspection language="XML" shortName="CheckEmptyScriptTag" enabledByDefault="true" level="WARNING"
bundle="messages.XmlBundle" key="html.inspections.check.empty.tag"
groupBundle="messages.XmlBundle" groupKey="html.inspections.group.name"
implementationClass="com.intellij.xml.util.CheckEmptyTagInspection"/>
<localInspection language="XML" shortName="CheckValidXmlInScriptTagBody" enabledByDefault="true" level="ERROR"
bundle="messages.XmlBundle" key="html.inspections.check.valid.script.tag"
groupBundle="messages.XmlBundle" groupKey="html.inspections.group.name"
implementationClass="com.intellij.xml.util.CheckValidXmlInScriptBodyInspection"/>
<localInspection language="XML" shortName="RequiredAttributes" enabledByDefault="true" level="WARNING" unfair="true"
bundle="messages.InspectionsBundle" key="inspection.required.attributes.display.name"
groupBundle="messages.XmlBundle" groupKey="html.inspections.group.name"
implementationClass="com.intellij.codeInspection.htmlInspections.RequiredAttributesInspection"/>
<localInspection language="XML" shortName="HtmlExtraClosingTag" enabledByDefault="true" level="ERROR"
bundle="messages.XmlBundle" key="html.inspection.extra.closing.tag"
groupBundle="messages.XmlBundle" groupKey="html.inspections.group.name"
implementationClass="com.intellij.codeInspection.htmlInspections.HtmlExtraClosingTagInspection"/>
<localInspection language="XML" shortName="HtmlUnknownTag" enabledByDefault="true" level="WARNING"
bundle="messages.XmlBundle" key="html.inspections.unknown.tag"
groupBundle="messages.XmlBundle" groupKey="html.inspections.group.name"
implementationClass="com.intellij.codeInspection.htmlInspections.HtmlUnknownTagInspection"/>
<localInspection language="XML" shortName="HtmlUnknownAttribute" enabledByDefault="true" level="WARNING"
bundle="messages.XmlBundle" key="html.inspections.unknown.attribute"
groupBundle="messages.XmlBundle" groupKey="html.inspections.group.name"
implementationClass="com.intellij.codeInspection.htmlInspections.HtmlUnknownAttributeInspection"/>
<localInspection language="XML" enabledByDefault="true" level="WARNING"
bundle="messages.XmlBundle" key="html.inspections.unknown.boolean.attribute"
groupBundle="messages.XmlBundle" groupKey="html.inspections.group.name"
implementationClass="com.intellij.codeInspection.htmlInspections.HtmlUnknownBooleanAttributeInspection"/>
<localInspection language="XML" shortName="HtmlUnknownTarget" enabledByDefault="true" level="WARNING"
bundle="messages.XmlBundle" key="html.inspections.unknown.target"
groupBundle="messages.XmlBundle" groupKey="html.inspections.group.name"
implementationClass="com.intellij.codeInsight.daemon.impl.analysis.HtmlUnknownTargetInspection"/>
<localInspection language="XML" shortName="HtmlUnknownAnchorTarget" bundle="messages.XmlBundle" key="html.inspections.unknown.anchor" groupName="HTML"
enabledByDefault="true" level="WARNING"
<localInspection language="XML" shortName="HtmlUnknownAnchorTarget" enabledByDefault="true" level="WARNING"
bundle="messages.XmlBundle" key="html.inspections.unknown.anchor"
groupBundle="messages.XmlBundle" groupKey="html.inspections.group.name"
implementationClass="com.intellij.codeInsight.daemon.impl.analysis.HtmlUnknownAnchorTargetInspection"/>
<globalInspection language="XML" shortName="XmlHighlighting" displayName="XML highlighting" groupName="xml.inspections.group.name" enabledByDefault="true" level="ERROR"
<globalInspection language="XML" shortName="XmlHighlighting" enabledByDefault="true" level="ERROR"
bundle="messages.XmlBundle" key="xml.inspections.global"
groupBundle="messages.XmlBundle" groupKey="xml.inspections.group.name"
implementationClass="com.intellij.codeInsight.daemon.impl.analysis.XmlHighlightVisitorBasedInspection"/>
<codeFoldingOptionsProvider instance="com.intellij.application.options.editor.XmlCodeFoldingOptionsProvider"/>
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 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.
@@ -23,7 +23,6 @@ import com.intellij.ide.highlighter.XmlFileType;
import com.intellij.javaee.ExternalResourceManagerExImpl;
import com.intellij.openapi.application.Result;
import com.intellij.openapi.command.WriteCommandAction;
import com.intellij.testFramework.IdeaTestCase;
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase;
import org.jetbrains.annotations.NotNull;
@@ -31,16 +30,10 @@ import org.jetbrains.annotations.NotNull;
* @author Dmitry Avdeev
*/
public class XmlNamespacesTest extends LightCodeInsightFixtureTestCase {
@SuppressWarnings("JUnitTestCaseWithNonTrivialConstructors")
public XmlNamespacesTest() {
IdeaTestCase.initPlatformPrefix();
}
public void testUnusedNamespaces() throws Exception {
doUnusedDeclarationTest(
"<all xmlns=\"http://www.w3.org/2001/XMLSchema\" <warning descr=\"Namespace declaration is never used\">xmlns:xsi=\"http://www.w3.org/2001/XMLSc<caret>hema-instance\"</warning>/>",
"<all xmlns=\"http://www.w3.org/2001/XMLSchema\"/>", XmlUnusedNamespaceInspection.RemoveNamespaceDeclarationFix.NAME);
"<all xmlns=\"http://www.w3.org/2001/XMLSchema\"/>", XmlBundle.message("xml.inspections.unused.schema.remove"));
}
public void testUnusedDefaultNamespace() throws Exception {
@@ -55,7 +48,7 @@ public class XmlNamespacesTest extends LightCodeInsightFixtureTestCase {
" xmlns:schema=\"http://www.w3.org/2001/XMLSchema\"\n" +
" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" +
">\n" +
"</schema:schema>", XmlUnusedNamespaceInspection.RemoveNamespaceDeclarationFix.NAME, false);
"</schema:schema>", XmlBundle.message("xml.inspections.unused.schema.remove"), false);
doOptimizeImportsTest("<schema:schema \n" +
" xmlns:schema=\"http://www.w3.org/2001/XMLSchema\"\n" +
@@ -73,7 +66,7 @@ public class XmlNamespacesTest extends LightCodeInsightFixtureTestCase {
"<x:all\n" +
" xmlns:x=\"http://www.w3.org/2001/XMLSchema\"\n" +
" xmlns:y=\"http://www.w3.org/2001/XMLSchema\"/>",
XmlUnusedNamespaceInspection.RemoveNamespaceDeclarationFix.NAME, false);
XmlBundle.message("xml.inspections.unused.schema.remove"), false);
doOptimizeImportsTest("<x:all\n" +
" xmlns:x=\"http://www.w3.org/2001/XMLSchema\"\n" +
@@ -104,7 +97,7 @@ public class XmlNamespacesTest extends LightCodeInsightFixtureTestCase {
" xmlns:x=\"http://www.w3.org/2001/XMLSchema\"\n" +
" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" +
" xsi:schemaLocation=\"http://www.w3.org/2001/XMLSchema http://www.w3.org/2001/XMLSchema.xsd\"/>",
XmlUnusedNamespaceInspection.RemoveNamespaceDeclarationFix.NAME);
XmlBundle.message("xml.inspections.unused.schema.remove"));
}
public void testUnusedDefaultLocation() throws Exception {
@@ -139,7 +132,7 @@ public class XmlNamespacesTest extends LightCodeInsightFixtureTestCase {
"\n" +
" </xs:complexType>\n" +
"</xs:schema>",
XmlUnusedNamespaceInspection.RemoveNamespaceDeclarationFix.NAME);
XmlBundle.message("xml.inspections.unused.schema.remove"));
}
public void testImplicitPrefixUsage() throws Exception {
@@ -227,7 +220,7 @@ public class XmlNamespacesTest extends LightCodeInsightFixtureTestCase {
public void testUsedInXmlns() throws Exception {
myFixture.testHighlighting("spring.xml", "spring-beans-2.5.xsd", "spring-batch-2.1.xsd");
IntentionAction action = myFixture.getAvailableIntention(XmlUnusedNamespaceInspection.RemoveNamespaceDeclarationFix.NAME);
IntentionAction action = myFixture.getAvailableIntention(XmlBundle.message("xml.inspections.unused.schema.remove"));
assertNotNull(action);
myFixture.launchAction(action);
myFixture.checkResultByFile("spring_after.xml");
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2015 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.
@@ -191,7 +191,7 @@ public class XmlUnboundNsPrefixInspection extends XmlSuppressableInspectionTool
@Override
@NotNull
public String getGroupDisplayName() {
return XmlBundle.message("xml.inspections.group.name");
return XmlInspectionGroupNames.XML_INSPECTIONS;
}
@Override
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 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.
@@ -45,8 +45,6 @@ import org.jetbrains.annotations.Nullable;
* @author Dmitry Avdeev
*/
public class XmlUnusedNamespaceInspection extends XmlSuppressableInspectionTool {
private static final String NAMESPACE_LOCATION_IS_NEVER_USED = "Namespace location is never used";
@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
@@ -74,21 +72,21 @@ public class XmlUnusedNamespaceInspection extends XmlSuppressableInspectionTool
XmlAttributeValue value = attribute.getValueElement();
assert value != null;
holder.registerProblem(attribute, "Namespace declaration is never used", ProblemHighlightType.LIKE_UNUSED_SYMBOL,
holder.registerProblem(attribute, XmlBundle.message("xml.inspections.unused.schema.declaration"), ProblemHighlightType.LIKE_UNUSED_SYMBOL,
new RemoveNamespaceDeclarationFix(declaredPrefix, false, !refCountHolder.isUsedNamespace(namespace)));
XmlTag parent = attribute.getParent();
if (declaredPrefix.isEmpty()) {
XmlAttribute location = getDefaultLocation(parent);
if (location != null) {
holder.registerProblem(location, NAMESPACE_LOCATION_IS_NEVER_USED, ProblemHighlightType.LIKE_UNUSED_SYMBOL,
holder.registerProblem(location, XmlBundle.message("xml.inspections.unused.schema.location"), ProblemHighlightType.LIKE_UNUSED_SYMBOL,
new RemoveNamespaceDeclarationFix(declaredPrefix, true, true));
}
}
else if (!refCountHolder.isUsedNamespace(namespace)) {
for (PsiReference reference : getLocationReferences(namespace, parent)) {
if (!XmlHighlightVisitor.hasBadResolve(reference, false))
holder.registerProblemForReference(reference, ProblemHighlightType.LIKE_UNUSED_SYMBOL, NAMESPACE_LOCATION_IS_NEVER_USED,
holder.registerProblemForReference(reference, ProblemHighlightType.LIKE_UNUSED_SYMBOL, XmlBundle.message("xml.inspections.unused.schema.location"),
new RemoveNamespaceDeclarationFix(declaredPrefix, true, true));
}
}
@@ -131,7 +129,7 @@ public class XmlUnusedNamespaceInspection extends XmlSuppressableInspectionTool
if (XmlUtil.XML_SCHEMA_INSTANCE_URI.equals(attribute.getNamespace())) {
if (XmlUtil.NO_NAMESPACE_SCHEMA_LOCATION_ATT.equals(attribute.getLocalName())) {
if (refCountHolder.isInUse("")) return;
holder.registerProblem(attribute, NAMESPACE_LOCATION_IS_NEVER_USED, ProblemHighlightType.LIKE_UNUSED_SYMBOL,
holder.registerProblem(attribute, XmlBundle.message("xml.inspections.unused.schema.location"), ProblemHighlightType.LIKE_UNUSED_SYMBOL,
new RemoveNamespaceLocationFix(""));
}
else if (XmlUtil.SCHEMA_LOCATION_ATT.equals(attribute.getLocalName())) {
@@ -144,14 +142,14 @@ public class XmlUnusedNamespaceInspection extends XmlSuppressableInspectionTool
String ns = getNamespaceFromReference(reference);
if (ArrayUtil.indexOf(attribute.getParent().knownNamespaces(), ns) == -1 && !refCountHolder.isUsedNamespace(ns)) {
if (!XmlHighlightVisitor.hasBadResolve(reference, false)) {
holder.registerProblemForReference(reference, ProblemHighlightType.LIKE_UNUSED_SYMBOL, NAMESPACE_LOCATION_IS_NEVER_USED,
holder.registerProblemForReference(reference, ProblemHighlightType.LIKE_UNUSED_SYMBOL, XmlBundle.message("xml.inspections.unused.schema.location"),
new RemoveNamespaceLocationFix(ns));
}
for (int j = i + 1; j < referencesLength; j++) {
PsiReference nextRef = references[j];
if (nextRef instanceof URLReference) break;
if (!XmlHighlightVisitor.hasBadResolve(nextRef, false)) {
holder.registerProblemForReference(nextRef, ProblemHighlightType.LIKE_UNUSED_SYMBOL, NAMESPACE_LOCATION_IS_NEVER_USED,
holder.registerProblemForReference(nextRef, ProblemHighlightType.LIKE_UNUSED_SYMBOL, XmlBundle.message("xml.inspections.unused.schema.location"),
new RemoveNamespaceLocationFix(ns));
}
}
@@ -215,14 +213,14 @@ public class XmlUnusedNamespaceInspection extends XmlSuppressableInspectionTool
@NotNull
@Override
public String getGroupDisplayName() {
return XmlBundle.message("xml.inspections.group.name");
return XmlInspectionGroupNames.XML_INSPECTIONS;
}
@Nls
@NotNull
@Override
public String getDisplayName() {
return "Unused XML schema declaration";
return XmlBundle.message("xml.inspections.unused.schema");
}
@NotNull
@@ -232,8 +230,6 @@ public class XmlUnusedNamespaceInspection extends XmlSuppressableInspectionTool
}
public static class RemoveNamespaceDeclarationFix implements LocalQuickFix {
public static final String NAME = "Remove unused namespace declaration";
protected final String myPrefix;
private final boolean myLocationFix;
private final boolean myRemoveLocation;
@@ -247,13 +243,13 @@ public class XmlUnusedNamespaceInspection extends XmlSuppressableInspectionTool
@Override
@NotNull
public String getName() {
return NAME;
return XmlBundle.message("xml.inspections.unused.schema.remove");
}
@Override
@NotNull
public String getFamilyName() {
return XmlBundle.message("xml.inspections.group.name");
return XmlInspectionGroupNames.XML_INSPECTIONS;
}
@Override