diff --git a/plugins/devkit/resources/META-INF/plugin.xml b/plugins/devkit/resources/META-INF/plugin.xml
index 419c3bb285bb..51da77a1b118 100644
--- a/plugins/devkit/resources/META-INF/plugin.xml
+++ b/plugins/devkit/resources/META-INF/plugin.xml
@@ -13,8 +13,12 @@
+
+
+
+
@@ -46,6 +50,13 @@
enabledByDefault="true"
level="WARNING"
implementationClass="org.jetbrains.idea.devkit.inspections.TitleCapitalizationInspection"/>
+
diff --git a/plugins/devkit/resources/inspectionDescriptions/InspectionMappingConsistency.html b/plugins/devkit/resources/inspectionDescriptions/InspectionMappingConsistency.html
new file mode 100644
index 000000000000..96e825a7e17c
--- /dev/null
+++ b/plugins/devkit/resources/inspectionDescriptions/InspectionMappingConsistency.html
@@ -0,0 +1,5 @@
+
+
+Checks inspection mappings consistency
+
+
\ No newline at end of file
diff --git a/plugins/devkit/src/dom/Extension.java b/plugins/devkit/src/dom/Extension.java
index 80086c227b52..97b32d1760ff 100644
--- a/plugins/devkit/src/dom/Extension.java
+++ b/plugins/devkit/src/dom/Extension.java
@@ -29,4 +29,5 @@ public interface Extension extends DomElement {
GenericAttributeValue getOrder();
+ ExtensionPoint getExtensionPoint();
}
diff --git a/plugins/devkit/src/dom/IdeaPlugin.java b/plugins/devkit/src/dom/IdeaPlugin.java
index deac79056e3a..1e93ca342c50 100644
--- a/plugins/devkit/src/dom/IdeaPlugin.java
+++ b/plugins/devkit/src/dom/IdeaPlugin.java
@@ -81,6 +81,7 @@ public interface IdeaPlugin extends DomElement {
@NotNull
+ @SubTagList("resource-bundle")
List> getResourceBundles();
GenericDomValue addResourceBundle();
diff --git a/plugins/devkit/src/dom/impl/ExtensionImpl.java b/plugins/devkit/src/dom/impl/ExtensionImpl.java
new file mode 100644
index 000000000000..5681f0840294
--- /dev/null
+++ b/plugins/devkit/src/dom/impl/ExtensionImpl.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2000-2011 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 org.jetbrains.idea.devkit.dom.impl;
+
+import com.intellij.pom.PomTargetPsiElement;
+import com.intellij.psi.PsiElement;
+import com.intellij.util.xml.DomTarget;
+import org.jetbrains.idea.devkit.dom.Extension;
+import org.jetbrains.idea.devkit.dom.ExtensionPoint;
+
+/**
+ * @author Dmitry Avdeev
+ * Date: 10/10/11
+ */
+public abstract class ExtensionImpl implements Extension {
+
+ @Override
+ public ExtensionPoint getExtensionPoint() {
+ PsiElement declaration = getChildDescription().getDeclaration(getManager().getProject());
+ if (declaration instanceof PomTargetPsiElement) {
+ return (ExtensionPoint)((DomTarget)((PomTargetPsiElement)declaration).getTarget()).getDomElement();
+ }
+ return null;
+ }
+}
diff --git a/plugins/devkit/src/dom/impl/PluginXmlDomFileDescription.java b/plugins/devkit/src/dom/impl/PluginXmlDomFileDescription.java
index 5c1119288273..e7238ca56260 100644
--- a/plugins/devkit/src/dom/impl/PluginXmlDomFileDescription.java
+++ b/plugins/devkit/src/dom/impl/PluginXmlDomFileDescription.java
@@ -32,11 +32,6 @@ public class PluginXmlDomFileDescription extends DomFileDescription
super(IdeaPlugin.class, "idea-plugin");
}
- protected void initializeFileDescription() {
- super.initializeFileDescription();
- registerImplementation(IdeaPlugin.class, IdeaPluginImpl.class);
- }
-
@Override
public Icon getFileIcon(int flags) {
return ICON;
diff --git a/plugins/devkit/src/inspections/InspectionMappingConsistencyInspection.java b/plugins/devkit/src/inspections/InspectionMappingConsistencyInspection.java
new file mode 100644
index 000000000000..b601932ab5d7
--- /dev/null
+++ b/plugins/devkit/src/inspections/InspectionMappingConsistencyInspection.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2000-2011 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 org.jetbrains.idea.devkit.inspections;
+
+import com.intellij.codeInspection.LocalInspectionToolSession;
+import com.intellij.codeInspection.ProblemsHolder;
+import com.intellij.openapi.util.Pair;
+import com.intellij.openapi.util.TextRange;
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiElementVisitor;
+import com.intellij.psi.XmlElementVisitor;
+import com.intellij.psi.util.InheritanceUtil;
+import com.intellij.psi.xml.XmlTag;
+import com.intellij.util.xml.DomElement;
+import com.intellij.util.xml.DomUtil;
+import org.jetbrains.annotations.Nls;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.idea.devkit.dom.Extension;
+import org.jetbrains.idea.devkit.dom.ExtensionPoint;
+import org.jetbrains.idea.devkit.dom.IdeaPlugin;
+
+/**
+ * @author Dmitry Avdeev
+ * Date: 10/10/11
+ */
+public class InspectionMappingConsistencyInspection extends DevKitInspectionBase {
+
+ @NotNull
+ @Override
+ public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder,
+ boolean isOnTheFly,
+ @NotNull LocalInspectionToolSession session) {
+ return new XmlElementVisitor() {
+ @Override
+ public void visitXmlTag(XmlTag tag) {
+ DomElement element = DomUtil.getDomElement(tag);
+ if (element instanceof Extension) {
+ ExtensionPoint target = ((Extension)element).getExtensionPoint();
+ if (InheritanceUtil.isInheritor(target.getBeanClass().getValue(), "com.intellij.codeInspection.InspectionEP")) {
+ if (tag.getAttribute("key") != null || tag.getAttribute("bundleKey") != null) {
+ if (tag.getAttribute("bundle") == null && tag.getAttribute("groupBundle") == null) {
+ IdeaPlugin plugin = DomUtil.getParentOfType(element, IdeaPlugin.class, true);
+ if (plugin != null && plugin.getResourceBundles().isEmpty()) {
+ Pair range = DomUtil.getProblemRange(element.getXmlTag());
+ holder.registerProblem(range.second, range.first, "Bundle should be specified");
+ }
+ }
+ }
+ }
+ }
+ }
+ };
+ }
+
+ @Nls
+ @NotNull
+ @Override
+ public String getDisplayName() {
+ return " tag consistency";
+ }
+
+ @NotNull
+ @Override
+ public String getShortName() {
+ return "InspectionMappingConsistency";
+ }
+}
diff --git a/plugins/groovy/src/META-INF/plugin.xml b/plugins/groovy/src/META-INF/plugin.xml
index 56a592da2e73..1fa4111bf839 100644
--- a/plugins/groovy/src/META-INF/plugin.xml
+++ b/plugins/groovy/src/META-INF/plugin.xml
@@ -620,7 +620,7 @@
enabledByDefault="false" level="WARNING"
implementationClass="org.jetbrains.plugins.groovy.codeInspection.bugs.GroovyConstructorNamedArgumentsInspection"/>
createTagNameRange(final XmlTag tag) {
- final PsiElement startToken = XmlTagUtil.getStartTagNameElement(tag);
- if (startToken == null) {
- return Pair.create(tag.getTextRange(), (PsiElement)tag);
- }
-
- return Pair.create(startToken.getTextRange().shiftRight(-tag.getTextRange().getStartOffset()), (PsiElement)tag);
- }
-
public String toString() {
return myDomElement + "; " + myMessage;
}
diff --git a/xml/dom-openapi/src/com/intellij/util/xml/DomUtil.java b/xml/dom-openapi/src/com/intellij/util/xml/DomUtil.java
index 0fef4ac42a03..045e59b1f815 100644
--- a/xml/dom-openapi/src/com/intellij/util/xml/DomUtil.java
+++ b/xml/dom-openapi/src/com/intellij/util/xml/DomUtil.java
@@ -5,6 +5,7 @@ import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Key;
+import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiElement;
@@ -21,6 +22,7 @@ import com.intellij.util.xml.reflect.DomAttributeChildDescription;
import com.intellij.util.xml.reflect.DomCollectionChildDescription;
import com.intellij.util.xml.reflect.DomFixedChildDescription;
import com.intellij.util.xml.reflect.DomGenericInfo;
+import com.intellij.xml.util.XmlTagUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -444,5 +446,13 @@ public class DomUtil {
public static boolean hasXml(@NotNull DomElement element) {
return element.getXmlElement() != null;
}
-
+
+ public static Pair getProblemRange(final XmlTag tag) {
+ final PsiElement startToken = XmlTagUtil.getStartTagNameElement(tag);
+ if (startToken == null) {
+ return Pair.create(tag.getTextRange(), (PsiElement)tag);
+ }
+
+ return Pair.create(startToken.getTextRange().shiftRight(-tag.getTextRange().getStartOffset()), (PsiElement)tag);
+ }
}