IDEA-217683 plugin.xml: highlight duplicate <depends> only if using same config-file

GitOrigin-RevId: a0c11e44128c20c084de10b86307daa6573372b9
This commit is contained in:
Yann Cébron
2019-10-02 10:07:03 +00:00
committed by intellij-monorepo-bot
parent d76fed8eba
commit 3ea3071d51
3 changed files with 24 additions and 20 deletions
@@ -196,7 +196,7 @@ inspections.plugin.xml.product.descriptor.invalid.date=Date must be in YYYYMMDD
inspections.plugin.xml.no.plugin.icon.svg.file=<html>Plugin should provide ''{0}'' (<a href="https://www.jetbrains.org/intellij/sdk/docs/basics/plugin_structure/plugin_icon_file.html">Documentation</a>)</html>
inspections.plugin.xml.component.interface.class.redundant=Redundant tag 'interfaceClass'
inspections.plugin.xml.service.interface.class.redundant=Redundant attribute 'serviceInterface'
inspections.plugin.xml.duplicated.dependency=Duplicate dependency ''{0}''
inspections.plugin.xml.duplicated.dependency=Duplicate dependency configuration file ''{0}''
inspections.registration.problems.name=Component type mismatch
inspections.registration.problems.option.check.plugin.xml=Check Plugin Descriptor (plugin.xml)
@@ -169,9 +169,10 @@ public class PluginXmlDomInspection extends BasicDomElementsInspection<IdeaPlugi
}
}
else {
ComponentModuleRegistrationChecker componentModuleRegistrationChecker = new ComponentModuleRegistrationChecker(myPluginModuleSetByModuleName,
myRegistrationCheckIgnoreClassList,
holder);
ComponentModuleRegistrationChecker componentModuleRegistrationChecker =
new ComponentModuleRegistrationChecker(myPluginModuleSetByModuleName,
myRegistrationCheckIgnoreClassList,
holder);
if (element instanceof Extension) {
annotateExtension((Extension)element, holder, componentModuleRegistrationChecker);
}
@@ -210,14 +211,14 @@ public class PluginXmlDomInspection extends BasicDomElementsInspection<IdeaPlugi
}
else //noinspection deprecation
if (element instanceof Helpset) {
highlightRedundant(element, DevKitBundle.message("inspections.plugin.xml.deprecated.helpset"), holder);
}
else if (element instanceof Listeners) {
annotateListeners((Listeners)element, holder);
}
else if (element instanceof Listeners.Listener) {
annotateListener((Listeners.Listener)element, holder);
}
highlightRedundant(element, DevKitBundle.message("inspections.plugin.xml.deprecated.helpset"), holder);
}
else if (element instanceof Listeners) {
annotateListeners((Listeners)element, holder);
}
else if (element instanceof Listeners.Listener) {
annotateListener((Listeners.Listener)element, holder);
}
}
if (element instanceof GenericDomValue) {
@@ -299,10 +300,10 @@ public class PluginXmlDomInspection extends BasicDomElementsInspection<IdeaPlugi
@Nullable
private static IdeaPlugin findMainDescriptor(@NotNull Module module) {
final XmlFile mainPluginXml = PluginModuleType.getPluginXml(module);
if (mainPluginXml == null) return null;
final XmlFile mainPluginXml = PluginModuleType.getPluginXml(module);
if (mainPluginXml == null) return null;
return DescriptorUtil.getIdeaPlugin(mainPluginXml);
return DescriptorUtil.getIdeaPlugin(mainPluginXml);
}
private static void annotateDependency(Dependency dependency, DomElementAnnotationHolder holder) {
@@ -350,7 +351,11 @@ public class PluginXmlDomInspection extends BasicDomElementsInspection<IdeaPlugi
if (!hasRealPluginId(ideaPlugin)) return;
MultiMap<String, Dependency> dependencies = MultiMap.create();
ideaPlugin.getDependencies().forEach(dependency -> dependencies.putValue(dependency.getStringValue(), dependency));
ideaPlugin.getDependencies().forEach(dependency -> {
if (DomUtil.hasXml(dependency.getConfigFile())) {
dependencies.putValue(dependency.getConfigFile().getStringValue(), dependency);
}
});
for (Map.Entry<String, Collection<Dependency>> entry : dependencies.entrySet()) {
if (entry.getValue().size() > 1) {
for (Dependency dependency : entry.getValue()) {
@@ -956,7 +961,7 @@ public class PluginXmlDomInspection extends BasicDomElementsInspection<IdeaPlugi
private static void highlightExperimental(DomElement element, DomElementAnnotationHolder holder) {
holder.createProblem(element, ProblemHighlightType.WARNING,
"Usage of API marked with @" + ApiStatus.Experimental.class.getCanonicalName() + ". "+
"Usage of API marked with @" + ApiStatus.Experimental.class.getCanonicalName() + ". " +
"Such API may be changed or removed in future IDE versions causing compatibility problems.",
null)
.highlightWholeElement();
@@ -11,9 +11,8 @@
<depends <warning descr="Superfluous declaration">optional="false"</warning>>com.intellij.custom3</depends>
<error descr="Must specify 'config-file'"><depends optional="true">com.intellij.custom4</depends></error>
<depends config-file="optional.xml">com.intellij</depends>
<depends config-file="<error descr="Cannot resolve file 'INVALID_VALUE'">INVALID_VALUE</error>">com.intellij.custom2</depends>
<error descr="Duplicate dependency 'com.intellij.duplicated'"><depends config-file="optional.xml">com.intellij.duplicated</depends></error>
<error descr="Duplicate dependency 'com.intellij.duplicated'"><depends config-file="optional.xml">com.intellij.duplicated</depends></error>
<error descr="Duplicate dependency configuration file 'optional.xml'"><depends config-file="optional.xml">com.intellij.duplicated</depends></error>
<error descr="Duplicate dependency configuration file 'optional.xml'"><depends config-file="optional.xml" optional="true">com.intellij.duplicated</depends></error>
</idea-plugin>