mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-249976 support loading intentions/inspections descriptions from language plugin
GitOrigin-RevId: 45a364b2680bafe25c655c91b40d9d504b0c05b7
This commit is contained in:
committed by
intellij-monorepo-bot
parent
79789a301a
commit
04431f29bd
@@ -1,6 +1,7 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.codeInspection.ex;
|
||||
|
||||
import com.intellij.DynamicBundle;
|
||||
import com.intellij.codeHighlighting.HighlightDisplayLevel;
|
||||
import com.intellij.codeInsight.daemon.HighlightDisplayKey;
|
||||
import com.intellij.codeInspection.CleanupLocalInspectionTool;
|
||||
@@ -13,6 +14,7 @@ import com.intellij.lang.MetaLanguage;
|
||||
import com.intellij.openapi.application.Application;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.extensions.PluginDescriptor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.util.ResourceUtil;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
@@ -22,6 +24,8 @@ import org.jetbrains.annotations.Nullable;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import static com.intellij.DynamicBundle.findLanguageBundle;
|
||||
|
||||
/**
|
||||
* @author Dmitry Avdeev
|
||||
*/
|
||||
@@ -204,6 +208,9 @@ public abstract class InspectionToolWrapper<T extends InspectionProfileEntry, E
|
||||
Application app = ApplicationManager.getApplication();
|
||||
String fileName = getDescriptionFileName();
|
||||
|
||||
InputStream langStream = getLanguagePluginStream(fileName);
|
||||
if (langStream != null) return langStream;
|
||||
|
||||
if (myEP == null || app.isUnitTestMode() || app.isHeadlessEnvironment()) {
|
||||
return ResourceUtil.getResourceAsStream(getDescriptionContextClass().getClassLoader(), "inspectionDescriptions", fileName);
|
||||
}
|
||||
@@ -211,6 +218,20 @@ public abstract class InspectionToolWrapper<T extends InspectionProfileEntry, E
|
||||
return myEP.getPluginDescriptor().getPluginClassLoader().getResourceAsStream("inspectionDescriptions/" + fileName);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static InputStream getLanguagePluginStream(@NotNull String fileName) {
|
||||
DynamicBundle.LanguageBundleEP langBundle = findLanguageBundle();
|
||||
if (langBundle == null) return null;
|
||||
|
||||
PluginDescriptor langPluginDescriptor = langBundle.pluginDescriptor;
|
||||
if (langPluginDescriptor == null) return null;
|
||||
|
||||
ClassLoader classLoader = langPluginDescriptor.getPluginClassLoader();
|
||||
if (classLoader == null) return null;
|
||||
|
||||
return classLoader.getResourceAsStream("inspectionDescriptions/" + fileName);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private String getDescriptionFileName() {
|
||||
return getShortName() + ".html";
|
||||
|
||||
Reference in New Issue
Block a user