devkit: highlight usages of the internal exception reporter as errors

(IDEA-189743)
This commit is contained in:
nik
2018-04-09 09:51:14 +03:00
parent 7b5637a38a
commit 3116ad1ac7
4 changed files with 27 additions and 2 deletions

View File

@@ -146,6 +146,7 @@ inspections.plugin.xml.until.build.use.asterisk.instead.of.big.number=Don''t use
inspections.plugin.xml.until.build.misleading.plain.number=Plain numbers in ''until-build'' attribute may be misleading. ''{0}'' means the same as ''{0}.0'', so the plugin won''t be compatible with {0}.* builds. It''s better to specify ''{1}'' instead.
inspections.plugin.xml.deprecated.ep=Deprecated EP ''{0}''
inspections.plugin.xml.no.need.to.specify.itnReporter=Exceptions from plugins developed by JetBrains are reported via ITNReporter automatically, there is no need to specify it explicitly
inspections.plugin.xml.third.party.plugins.must.not.use.itnReporter='com.intellij.diagnostic.ITNReporter' reports errors for internal processing at JetBrains, it should not be used for third-party plugins
inspections.plugin.xml.deprecated.attribute=Deprecated attribute ''{0}''
inspections.plugin.xml.attribute.not.used.anymore=Attribute ''{0}'' not used anymore
inspections.plugin.xml.anchor.must.have.relative-to-action='anchor' must be specified with 'relative-to-action'

View File

@@ -289,12 +289,17 @@ public class PluginXmlDomInspection extends BasicDomElementsInspection<IdeaPlugi
IdeaPlugin plugin = extension.getParentOfType(IdeaPlugin.class, true);
if (plugin != null) {
Vendor vendor = plugin.getVendor();
LocalQuickFix fix = new RemoveDomElementQuickFix(extension);
if (DomUtil.hasXml(vendor) && PluginManagerMain.isDevelopedByJetBrains(vendor.getValue())) {
LocalQuickFix fix = new RemoveDomElementQuickFix(extension);
holder.createProblem(extension, ProblemHighlightType.LIKE_UNUSED_SYMBOL,
DevKitBundle.message("inspections.plugin.xml.no.need.to.specify.itnReporter"),
null, fix).highlightWholeElement();
}
else {
holder.createProblem(extension, ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
DevKitBundle.message("inspections.plugin.xml.third.party.plugins.must.not.use.itnReporter"),
null, fix).highlightWholeElement();
}
}
}
}

View File

@@ -0,0 +1,12 @@
<idea-plugin>
<id>com.intellij</id>
<vendor>Example, Inc</vendor>
<extensionPoints>
<extensionPoint name="errorHandler"
interface="com.intellij.openapi.diagnostic.ErrorReportSubmitter"/>
</extensionPoints>
<extensions defaultExtensionNs="com.intellij">
<error descr="'com.intellij.diagnostic.ITNReporter' reports errors for internal processing at JetBrains, it should not be used for third-party plugins"><errorHandler implementation="com.intellij.diagnostic.ITNReporter"/></error>
<errorHandler implementation="MyErrorHandler"/>
</extensions>
</idea-plugin>

View File

@@ -12,7 +12,6 @@ import com.intellij.codeInspection.xml.DeprecatedClassUsageInspection
import com.intellij.diagnostic.ITNReporter
import com.intellij.lang.LanguageExtensionPoint
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.application.PluginPathManager
import com.intellij.openapi.extensions.LoadingOrder
import com.intellij.psi.ElementDescriptionUtil
import com.intellij.psi.PsiElement
@@ -422,6 +421,14 @@ public class MyErrorHandler extends ErrorReportSubmitter {}
myFixture.testHighlighting("errorHandlerExtensionInJetBrainsPlugin.xml")
}
void testErrorHandlerExtensionInNonJetBrainsPlugin() {
myFixture.addClass("""
import com.intellij.openapi.diagnostic.ErrorReportSubmitter;
public class MyErrorHandler extends ErrorReportSubmitter {}
""")
myFixture.testHighlighting("errorHandlerExtensionInNonJetBrainsPlugin.xml")
}
void testExtensionPointPresentation() {
myFixture.configureByFile(getTestName(true) + ".xml")
final PsiElement element =