mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
InspectionMappingConsistency inspection
This commit is contained in:
@@ -48,8 +48,8 @@ public class InspectionMappingConsistencyInspection extends DevKitInspectionBase
|
||||
public void visitXmlTag(XmlTag tag) {
|
||||
DomElement element = DomUtil.getDomElement(tag);
|
||||
if (element instanceof Extension) {
|
||||
ExtensionPoint target = ((Extension)element).getExtensionPoint();
|
||||
if (target != null && InheritanceUtil.isInheritor(target.getBeanClass().getValue(), "com.intellij.codeInspection.InspectionEP")) {
|
||||
ExtensionPoint extensionPoint = ((Extension)element).getExtensionPoint();
|
||||
if (extensionPoint != null && InheritanceUtil.isInheritor(extensionPoint.getBeanClass().getValue(), "com.intellij.codeInspection.InspectionEP")) {
|
||||
boolean key = tag.getAttribute("key") != null;
|
||||
boolean groupKey = tag.getAttribute("groupKey") != null;
|
||||
if (key) {
|
||||
@@ -57,11 +57,17 @@ public class InspectionMappingConsistencyInspection extends DevKitInspectionBase
|
||||
checkDefaultBundle(element, holder);
|
||||
}
|
||||
}
|
||||
else if (tag.getAttribute("displayName") == null) {
|
||||
registerProblem(element, holder, "displayName or key should be specified");
|
||||
}
|
||||
if (groupKey) {
|
||||
if (tag.getAttribute("bundle") == null && tag.getAttribute("groupBundle") == null) {
|
||||
checkDefaultBundle(element, holder);
|
||||
}
|
||||
}
|
||||
else if (tag.getAttribute("groupName") == null) {
|
||||
registerProblem(element, holder, "groupName or groupKey should be specified");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -71,11 +77,15 @@ public class InspectionMappingConsistencyInspection extends DevKitInspectionBase
|
||||
private static void checkDefaultBundle(DomElement element, ProblemsHolder holder) {
|
||||
IdeaPlugin plugin = DomUtil.getParentOfType(element, IdeaPlugin.class, true);
|
||||
if (plugin != null && plugin.getResourceBundles().isEmpty()) {
|
||||
Pair<TextRange,PsiElement> range = DomUtil.getProblemRange(element.getXmlTag());
|
||||
holder.registerProblem(range.second, range.first, "Bundle should be specified");
|
||||
registerProblem(element, holder, "Bundle should be specified");
|
||||
}
|
||||
}
|
||||
|
||||
private static void registerProblem(DomElement element, ProblemsHolder holder, String message) {
|
||||
Pair<TextRange,PsiElement> range = DomUtil.getProblemRange(element.getXmlTag());
|
||||
holder.registerProblem(range.second, range.first, message);
|
||||
}
|
||||
|
||||
@Nls
|
||||
@NotNull
|
||||
@Override
|
||||
|
||||
@@ -8,11 +8,14 @@
|
||||
</extensionPoints>
|
||||
|
||||
<extensions defaultExtensionNs="com.intellij">
|
||||
<<warning descr="Bundle should be specified">localInspection</warning> key="foo"/>
|
||||
<<warning descr="Bundle should be specified">localInspection</warning> groupKey="foo"/>
|
||||
<<warning descr="Bundle should be specified">localInspection</warning> key="foo" groupBundle="bundle"/>
|
||||
<<warning descr="groupName or groupKey should be specified"><warning descr="Bundle should be specified">localInspection</warning></warning> key="foo"/>
|
||||
<<warning descr="displayName or key should be specified"><warning descr="Bundle should be specified">localInspection</warning></warning> groupKey="foo"/>
|
||||
<<warning descr="groupName or groupKey should be specified"><warning descr="Bundle should be specified">localInspection</warning></warning> key="foo" groupBundle="bundle"/>
|
||||
|
||||
<localInspection key="foo" bundle="bundle"/>
|
||||
<localInspection groupKey="foo" bundle="bundle"/>
|
||||
<<warning descr="groupName or groupKey should be specified">localInspection</warning> key="foo" bundle="bundle"/>
|
||||
<<warning descr="displayName or key should be specified">localInspection</warning> groupKey="foo" bundle="bundle"/>
|
||||
|
||||
<localInspection key="foo" bundle="bundle" groupName="groupName"/>
|
||||
<localInspection groupKey="foo" bundle="bundle" displayName="displayName"/>
|
||||
</extensions>
|
||||
</idea-plugin>
|
||||
@@ -9,11 +9,15 @@
|
||||
</extensionPoints>
|
||||
|
||||
<extensions defaultExtensionNs="com.intellij">
|
||||
<localInspection key="foo"/>
|
||||
<localInspection groupKey="foo"/>
|
||||
<localInspection key="foo" groupBundle="bundle"/>
|
||||
<<warning descr="groupName or groupKey should be specified">localInspection</warning> key="foo"/>
|
||||
<<warning descr="displayName or key should be specified">localInspection</warning> groupKey="foo"/>
|
||||
<<warning descr="groupName or groupKey should be specified">localInspection</warning> key="foo" groupBundle="bundle"/>
|
||||
|
||||
<<warning descr="groupName or groupKey should be specified">localInspection</warning> key="foo" bundle="bundle"/>
|
||||
<<warning descr="displayName or key should be specified">localInspection</warning> groupKey="foo" bundle="bundle"/>
|
||||
|
||||
<localInspection key="foo" bundle="bundle" groupName="groupName"/>
|
||||
<localInspection groupKey="foo" bundle="bundle" displayName="displayName"/>
|
||||
|
||||
<localInspection key="foo" bundle="bundle"/>
|
||||
<localInspection groupKey="foo" bundle="bundle"/>
|
||||
</extensions>
|
||||
</idea-plugin>
|
||||
Reference in New Issue
Block a user