From 70cad880f362e00f85f385c18ee451b67f2c88fd Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Mon, 15 Jun 2015 18:22:09 +0300 Subject: [PATCH] xml: inspection group names fixed --- .../src/messages/XmlBundle.properties | 9 ++ .../src/META-INF/XmlPlugin.xml | 111 +++++++++++------- .../com/intellij/xml/XmlNamespacesTest.java | 21 ++-- .../XmlUnboundNsPrefixInspection.java | 4 +- .../XmlUnusedNamespaceInspection.java | 26 ++-- 5 files changed, 95 insertions(+), 76 deletions(-) diff --git a/platform/platform-resources-en/src/messages/XmlBundle.properties b/platform/platform-resources-en/src/messages/XmlBundle.properties index f1f562b21bb8..aa754f09f720 100644 --- a/platform/platform-resources-en/src/messages/XmlBundle.properties +++ b/platform/platform-resources-en/src/messages/XmlBundle.properties @@ -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 diff --git a/platform/platform-resources/src/META-INF/XmlPlugin.xml b/platform/platform-resources/src/META-INF/XmlPlugin.xml index 345fb6259d99..ddd9cb54eb26 100644 --- a/platform/platform-resources/src/META-INF/XmlPlugin.xml +++ b/platform/platform-resources/src/META-INF/XmlPlugin.xml @@ -390,64 +390,85 @@ - - - - - + - - - - - - - - - - - - - + + + + + + + + + - - - diff --git a/xml/tests/src/com/intellij/xml/XmlNamespacesTest.java b/xml/tests/src/com/intellij/xml/XmlNamespacesTest.java index 55afa3d200c6..d86e93163ee1 100644 --- a/xml/tests/src/com/intellij/xml/XmlNamespacesTest.java +++ b/xml/tests/src/com/intellij/xml/XmlNamespacesTest.java @@ -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( "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"/>", - "", XmlUnusedNamespaceInspection.RemoveNamespaceDeclarationFix.NAME); + "", 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" + - "", XmlUnusedNamespaceInspection.RemoveNamespaceDeclarationFix.NAME, false); + "", XmlBundle.message("xml.inspections.unused.schema.remove"), false); doOptimizeImportsTest("", - XmlUnusedNamespaceInspection.RemoveNamespaceDeclarationFix.NAME, false); + XmlBundle.message("xml.inspections.unused.schema.remove"), false); doOptimizeImportsTest("", - 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" + " \n" + "", - 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"); diff --git a/xml/xml-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlUnboundNsPrefixInspection.java b/xml/xml-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlUnboundNsPrefixInspection.java index fc05a4849506..350aa982d175 100644 --- a/xml/xml-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlUnboundNsPrefixInspection.java +++ b/xml/xml-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlUnboundNsPrefixInspection.java @@ -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 diff --git a/xml/xml-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlUnusedNamespaceInspection.java b/xml/xml-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlUnusedNamespaceInspection.java index 046a172ab11f..d76e2c567680 100644 --- a/xml/xml-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlUnusedNamespaceInspection.java +++ b/xml/xml-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlUnusedNamespaceInspection.java @@ -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