IJ-CR-147193 IJPL-161796 cleanup - part 2 and fix api check

(cherry picked from commit a567b2f79121f8349f4046dc0cf140db3af527ac)

GitOrigin-RevId: 75656a4209713201dc0e49aa2462f527775f00ed
This commit is contained in:
Vladimir Krivosheev
2024-10-17 10:13:20 +02:00
committed by intellij-monorepo-bot
parent 06b29bff39
commit 996401954f
7 changed files with 135 additions and 131 deletions

View File

@@ -4,21 +4,20 @@ package com.intellij.codeInsight.daemon;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.extensions.ExtensionPointName;
import com.intellij.psi.PsiFile;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
/**
* This filters can be used to prevent error highlighting (invalid code, unresolved references etc.) in files outside of project scope.
* Filter implementations should be permissive - i.e. should prevent highlighting only for files it absolutely knows about,
* This filters can be used to prevent error highlighting (invalid code, unresolved references, etc.) in files outside a project scope.
* Filter implementations should be permissive - i.e., should prevent highlighting only for files it absolutely knows about,
* and return true otherwise.
*/
public abstract class ProblemHighlightFilter {
public static final ExtensionPointName<ProblemHighlightFilter> EP_NAME = ExtensionPointName.create("com.intellij.problemHighlightFilter");
public static final ExtensionPointName<ProblemHighlightFilter> EP_NAME = new ExtensionPointName<>("com.intellij.problemHighlightFilter");
private static final Logger LOG = Logger.getInstance(ProblemHighlightFilter.class);
/**
* @param psiFile file to decide about
* @return false if this filter disables highlighting for given file, true if filter enables highlighting or can't decide
* @return false if this filter disables highlighting for a given file, true if filter enables highlighting or can't decide
*/
public abstract boolean shouldHighlight(@NotNull PsiFile psiFile);
@@ -35,10 +34,16 @@ public abstract class ProblemHighlightFilter {
}
private static boolean shouldProcess(@NotNull PsiFile psiFile, boolean onTheFly) {
return ContainerUtil.all(EP_NAME.getExtensionList(), filter -> {
var shouldHighlight = onTheFly ? filter.shouldHighlight(psiFile) : filter.shouldProcessInBatch(psiFile);
LOG.debug("shouldProcess highlight: ", shouldHighlight, " filter type: ", filter.getClass().getSimpleName());
return shouldHighlight;
});
boolean isDebugEnabled = LOG.isDebugEnabled();
for (ProblemHighlightFilter filter : EP_NAME.getExtensionList()) {
boolean shouldHighlight = onTheFly ? filter.shouldHighlight(psiFile) : filter.shouldProcessInBatch(psiFile);
if (isDebugEnabled) {
LOG.debug("shouldProcess highlight: " + shouldHighlight + " filter type: " + filter.getClass().getSimpleName());
}
if (!shouldHighlight) {
return false;
}
}
return true;
}
}

View File

@@ -2458,7 +2458,6 @@ c:com.intellij.codeInsight.daemon.impl.TrafficLightRenderer
- com.intellij.openapi.Disposable
- com.intellij.openapi.editor.markup.ErrorStripeRenderer
- <init>(com.intellij.openapi.project.Project,com.intellij.openapi.editor.Document):V
- p:<init>(com.intellij.openapi.project.Project,com.intellij.openapi.editor.Editor):V
- p:createUIController():com.intellij.openapi.editor.markup.UIController
- pf:createUIController(com.intellij.openapi.editor.Editor):com.intellij.openapi.editor.markup.UIController
- dispose():V
@@ -2466,12 +2465,11 @@ c:com.intellij.codeInsight.daemon.impl.TrafficLightRenderer
- p:getDaemonCodeAnalyzerStatus(com.intellij.codeInsight.daemon.impl.SeverityRegistrar):com.intellij.codeInsight.daemon.impl.TrafficLightRenderer$DaemonCodeAnalyzerStatus
- getErrorCounts():I[]
- pf:getProject():com.intellij.openapi.project.Project
- getSeverityRegistrar():com.intellij.codeInsight.daemon.impl.SeverityRegistrar
- f:getSeverityRegistrar():com.intellij.codeInsight.daemon.impl.SeverityRegistrar
- getStatus():com.intellij.openapi.editor.markup.AnalyzerStatus
- p:getUIController():com.intellij.openapi.editor.markup.UIController
- f:invalidate():V
- isValid():Z
- p:refresh(com.intellij.openapi.editor.impl.EditorMarkupModelImpl):V
- s:setTrafficLightOnEditor(com.intellij.openapi.project.Project,com.intellij.openapi.editor.ex.EditorMarkupModel,com.intellij.openapi.application.ModalityState,java.util.function.Supplier):V
- refresh(com.intellij.openapi.editor.ex.EditorMarkupModel):V
pc:com.intellij.codeInsight.daemon.impl.TrafficLightRenderer$AbstractUIController
- canClosePopup():Z
- fillHectorPanels(java.awt.Container,com.intellij.util.ui.GridBag):V
@@ -2482,7 +2480,7 @@ pc:com.intellij.codeInsight.daemon.impl.TrafficLightRenderer$AbstractUIControlle
- toggleProblemsView():V
pc:com.intellij.codeInsight.daemon.impl.TrafficLightRenderer$DefaultUIController
- com.intellij.codeInsight.daemon.impl.TrafficLightRenderer$AbstractUIController
- p:<init>(com.intellij.codeInsight.daemon.impl.TrafficLightRenderer):V
- <init>(com.intellij.codeInsight.daemon.impl.TrafficLightRenderer):V
- getActions():java.util.List
- isToolbarEnabled():Z
com.intellij.codeInsight.daemon.impl.TrafficLightRendererContributor

View File

@@ -24,7 +24,6 @@ com/intellij/openapi/client/ClientProjectSession
com/intellij/openapi/components/impl/stores/IComponentStore
com/intellij/openapi/editor/EditorMouseHoverPopupManager$Context
com/intellij/openapi/editor/PopupBridge
com/intellij/openapi/editor/impl/EditorMarkupModelImpl
com/intellij/openapi/editor/markup/AnalyzerStatus
com/intellij/openapi/editor/markup/UIController
com/intellij/openapi/roots/impl/storage/ClasspathStorageProvider

View File

@@ -141,9 +141,8 @@ class ErrorStripeUpdateManager(private val project: Project, private val corouti
val renderer = editorMarkupModel.getErrorStripeRenderer()
if (renderer is TrafficLightRenderer) {
val markupModelImpl = editorMarkupModel as EditorMarkupModelImpl
renderer.refresh(markupModelImpl)
markupModelImpl.repaintTrafficLightIcon()
renderer.refresh(editorMarkupModel)
(editorMarkupModel as EditorMarkupModelImpl).repaintTrafficLightIcon()
if (renderer.isValid) {
return
}

View File

@@ -21,22 +21,19 @@ import com.intellij.openapi.Disposable
import com.intellij.openapi.actionSystem.*
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.application.ReadAction
import com.intellij.openapi.diagnostic.Logger
import com.intellij.openapi.diagnostic.logger
import com.intellij.openapi.editor.*
import com.intellij.openapi.editor.ex.EditorMarkupModel
import com.intellij.openapi.editor.ex.MarkupModelEx
import com.intellij.openapi.editor.ex.RangeHighlighterEx
import com.intellij.openapi.editor.impl.DocumentMarkupModel
import com.intellij.openapi.editor.impl.EditorMarkupModelImpl
import com.intellij.openapi.editor.impl.event.MarkupModelListener
import com.intellij.openapi.editor.markup.*
import com.intellij.openapi.options.ConfigurationException
import com.intellij.openapi.progress.ProcessCanceledException
import com.intellij.openapi.project.DumbService.Companion.isDumb
import com.intellij.openapi.project.Project
import com.intellij.openapi.roots.ProjectRootManager
import com.intellij.openapi.util.Condition
import com.intellij.openapi.util.ThrowableComputable
import com.intellij.openapi.util.text.StringUtil
import com.intellij.psi.PsiCompiledElement
import com.intellij.psi.PsiDocumentManager
import com.intellij.psi.PsiFile
@@ -44,11 +41,9 @@ import com.intellij.util.ArrayUtilRt
import com.intellij.util.SlowOperations
import com.intellij.util.UtilBundle.message
import com.intellij.util.concurrency.ThreadingAssertions
import com.intellij.util.containers.ContainerUtil
import com.intellij.util.io.storage.HeavyProcessLatch
import com.intellij.util.ui.EdtInvocationManager
import com.intellij.util.ui.GridBag
import groovy.transform.Internal
import it.unimi.dsi.fastutil.ints.IntArrayList
import it.unimi.dsi.fastutil.ints.IntBinaryOperator
import it.unimi.dsi.fastutil.objects.Object2IntMaps
@@ -56,7 +51,7 @@ import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap
import org.jetbrains.annotations.ApiStatus
import org.jetbrains.annotations.Nls
import java.awt.Container
import javax.swing.JComponent
import java.util.concurrent.CancellationException
open class TrafficLightRenderer private constructor(
project: Project,
@@ -68,7 +63,9 @@ open class TrafficLightRenderer private constructor(
private val daemonCodeAnalyzer: DaemonCodeAnalyzerImpl
val severityRegistrar: SeverityRegistrar
private val errorCount = Object2IntMaps.synchronize(Object2IntOpenHashMap<HighlightSeverity>())
protected val uIController: UIController
@JvmField
@ApiStatus.Internal
protected val uiController: UIController
// true if getPsiFile() is in library sources
private val inLibrary: Boolean
private val shouldHighlight: Boolean
@@ -81,7 +78,7 @@ open class TrafficLightRenderer private constructor(
constructor(project: Project, document: Document) : this(project = project, document = document, editor = null)
@Internal
@ApiStatus.Internal
constructor(project: Project, editor: Editor) : this(project = project, document = editor.getDocument(), editor = editor)
init {
@@ -94,7 +91,7 @@ open class TrafficLightRenderer private constructor(
this.severityRegistrar = SeverityRegistrar.getSeverityRegistrar(this.project)
init(project, document)
uIController = if (editor == null) createUIController() else createUIController(editor)
uiController = if (editor == null) createUIController() else createUIController(editor)
data class Stuff(
@JvmField val fileHighlightingSettings: MutableMap<Language, FileHighlightingSetting>,
@JvmField val inLibrary: Boolean,
@@ -126,7 +123,7 @@ open class TrafficLightRenderer private constructor(
fileHighlightingSettings = info.fileHighlightingSettings
inLibrary = info.inLibrary
shouldHighlight = info.shouldHighlight
highlightingSettingsModificationCount = HighlightingSettingsPerFile.getInstance(project).getModificationCount()
highlightingSettingsModificationCount = HighlightingSettingsPerFile.getInstance(project).modificationCount
}
private fun init(project: Project, document: Document) {
@@ -154,13 +151,13 @@ open class TrafficLightRenderer private constructor(
open val errorCounts: IntArray
/**
* Returns a new instance of an array filled with a number of highlighters with a given severity.
* `errorCount[idx]` equals to a number of highlighters of severity with index `idx` in this markup model.
* Returns a new instance of an array filled with a number of highlighters with given severity.
* `errorCount[index]` equals to a number of highlighters of severity with index `idx` in this markup model.
* Severity index can be obtained via [SeverityRegistrar.getSeverityIdx].
*/
get() = cachedErrors.clone()
open fun refresh(editorMarkupModel: EditorMarkupModelImpl?) {
open fun refresh(editorMarkupModel: EditorMarkupModel?) {
val severities = severityRegistrar.allSeverities
if (cachedErrors.size != severities.size) {
cachedErrors = IntArray(severities.size)
@@ -199,7 +196,7 @@ open class TrafficLightRenderer private constructor(
if (psiFile == null) return false
}
val settings = HighlightingSettingsPerFile.getInstance(psiFile!!.getProject())
return settings.getModificationCount() == highlightingSettingsModificationCount
return settings.modificationCount == highlightingSettingsModificationCount
}
@ApiStatus.Internal
@@ -208,12 +205,18 @@ open class TrafficLightRenderer private constructor(
// all passes are done
var errorAnalyzingFinished: Boolean = false
var passes: MutableList<ProgressableTextEditorHighlightingPass> = mutableListOf()
@JvmField
internal var passes: List<ProgressableTextEditorHighlightingPass> = listOf()
@JvmField
var errorCounts: IntArray = ArrayUtilRt.EMPTY_INT_ARRAY
@JvmField
var reasonWhyDisabled: @Nls String? = null
@JvmField
var reasonWhySuspended: @Nls String? = null
@JvmField
var heavyProcessType: HeavyProcessLatch.Type? = null
@JvmField
// by default, full inspect mode is expected
internal var minimumLevel = FileHighlightingSetting.FORCE_HIGHLIGHTING
@@ -222,7 +225,7 @@ open class TrafficLightRenderer private constructor(
+ "; pass statuses: " + passes.size + "; "))
for (passStatus in passes) {
s.append(
String.format("(%s %2.0f%% %b)", passStatus.getPresentableName(), passStatus.getProgress() * 100, passStatus.isFinished()))
String.format("(%s %2.0f%% %b)", passStatus.presentableName, passStatus.getProgress() * 100, passStatus.isFinished))
}
s.append("; error counts: ").append(errorCounts.size).append(": ").append(IntArrayList(errorCounts))
if (reasonWhyDisabled != null) {
@@ -281,9 +284,9 @@ open class TrafficLightRenderer private constructor(
var shouldHighlight = languages.isEmpty()
for (entry in fileHighlightingSettings.entries) {
val level: FileHighlightingSetting = entry.value!!
val level = entry.value
shouldHighlight = shouldHighlight or (level != FileHighlightingSetting.SKIP_HIGHLIGHTING)
status.minimumLevel = if (status.minimumLevel.compareTo(level) < 0) status.minimumLevel else level
status.minimumLevel = if (status.minimumLevel < level) status.minimumLevel else level
}
shouldHighlight = shouldHighlight and this.shouldHighlight
@@ -300,15 +303,11 @@ open class TrafficLightRenderer private constructor(
}
status.errorCounts = this.errorCounts
status.passes = ContainerUtil.filter<ProgressableTextEditorHighlightingPass?>(
daemonCodeAnalyzer.getPassesToShowProgressFor(document),
Condition { p: ProgressableTextEditorHighlightingPass? ->
!StringUtil.isEmpty(
p!!.getPresentableName()) && p.getProgress() >= 0
})
status.passes = daemonCodeAnalyzer.getPassesToShowProgressFor(document)
.filter { !it.presentableName.isNullOrEmpty() && it.getProgress() >= 0 }
status.errorAnalyzingFinished = daemonCodeAnalyzer.isAllAnalysisFinished(psiFile)
if (!daemonCodeAnalyzer.isUpdateByTimerEnabled()) {
if (!daemonCodeAnalyzer.isUpdateByTimerEnabled) {
status.reasonWhySuspended = DaemonBundle.message("process.title.highlighting.is.paused.temporarily")
}
fillDaemonCodeAnalyzerErrorsStatus(status, severityRegistrar)
@@ -321,13 +320,13 @@ open class TrafficLightRenderer private constructor(
override fun getStatus(): AnalyzerStatus {
// this method is rather expensive and PSI-related, need to execute in BGT and cache the result to show in EDT later
ApplicationManager.getApplication().assertIsNonDispatchThread()
ApplicationManager.getApplication().assertReadAccessAllowed()
ThreadingAssertions.assertBackgroundThread()
ThreadingAssertions.assertReadAccess()
if (PowerSaveMode.isEnabled()) {
return AnalyzerStatus(AllIcons.General.InspectionsPowerSaveMode,
InspectionsBundle.message("code.analysis.is.disabled.in.power.save.mode"),
"",
this.uIController).withState(InspectionsState.DISABLED)
this.uiController).withState(InspectionsState.DISABLED)
}
val status = getDaemonCodeAnalyzerStatus(this.severityRegistrar)
@@ -336,26 +335,29 @@ open class TrafficLightRenderer private constructor(
val state: InspectionsState?
val isDumb = isDumb(this.project)
val statusItems: MutableList<SeverityStatusItem> = ArrayList<SeverityStatusItem>()
val statusItems = ArrayList<SeverityStatusItem>()
val errorCounts = status.errorCounts
for (i in errorCounts.indices.reversed()) {
val count = errorCounts[i]
if (count > 0) {
val severity = severityRegistrar.getSeverityByIndex(i)
if (severity != null) {
val icon = severityRegistrar.getRendererIconBySeverity(severity,
status.minimumLevel == FileHighlightingSetting.FORCE_HIGHLIGHTING)
var next: SeverityStatusItem? = SeverityStatusItem(severity, icon, count, severity.getCountMessage(count))
while (!statusItems.isEmpty()) {
val merged = StatusItemMerger.runMerge(ContainerUtil.getLastItem<SeverityStatusItem?>(statusItems), next!!)
if (merged == null) break
statusItems.removeAt(statusItems.size - 1)
next = merged
}
statusItems.add(next!!)
}
if (count <= 0) {
continue
}
val severity = severityRegistrar.getSeverityByIndex(i) ?: continue
val icon = severityRegistrar.getRendererIconBySeverity(severity,
status.minimumLevel == FileHighlightingSetting.FORCE_HIGHLIGHTING)
var next = SeverityStatusItem(
severity = severity,
icon = icon,
problemCount = count,
countMessage = severity.getCountMessage(count),
)
while (!statusItems.isEmpty()) {
val merged = StatusItemMerger.runMerge(statusItems.lastOrNull()!!, next) ?: break
statusItems.removeAt(statusItems.size - 1)
next = merged
}
statusItems.add(next)
}
if (status.errorAnalyzingFinished) {
@@ -386,7 +388,7 @@ open class TrafficLightRenderer private constructor(
icon = statusItems[0].icon,
title = title,
details = "",
controller = this.uIController,
controller = this.uiController,
)
.withNavigation(true)
.withState(state)
@@ -405,17 +407,20 @@ open class TrafficLightRenderer private constructor(
})
}
}
if (StringUtil.isNotEmpty(status.reasonWhyDisabled)) {
return AnalyzerStatus(AllIcons.General.InspectionsTrafficOff,
DaemonBundle.message("no.analysis.performed"),
status.reasonWhyDisabled!!,
this.uIController).withTextStatus(DaemonBundle.message("iw.status.off")).withState(InspectionsState.OFF)
if (!status.reasonWhyDisabled.isNullOrEmpty()) {
return AnalyzerStatus(
icon = AllIcons.General.InspectionsTrafficOff,
title = DaemonBundle.message("no.analysis.performed"),
details = status.reasonWhyDisabled!!,
controller = this.uiController,
).withTextStatus(DaemonBundle.message("iw.status.off")).withState(InspectionsState.OFF)
}
if (StringUtil.isNotEmpty(status.reasonWhySuspended)) {
if (!status.reasonWhySuspended.isNullOrEmpty()) {
return AnalyzerStatus(
icon = AllIcons.General.InspectionsPause,
title = DaemonBundle.message("analysis.suspended"),
details = status.reasonWhySuspended!!, controller = this.uIController,
details = status.reasonWhySuspended!!,
controller = this.uiController,
)
.withState(InspectionsState.PAUSED)
.withTextStatus(if (status.heavyProcessType != null) status.heavyProcessType.toString() else DaemonBundle.message("iw.status.paused"))
@@ -429,13 +434,13 @@ open class TrafficLightRenderer private constructor(
AllIcons.General.InspectionsOKEmpty
}
return if (isDumb) {
AnalyzerStatus(icon = AllIcons.General.InspectionsPause, title = title, details = details, controller = this.uIController)
AnalyzerStatus(icon = AllIcons.General.InspectionsPause, title = title, details = details, controller = uiController)
.withTextStatus(message("heavyProcess.type.indexing"))
.withState(InspectionsState.INDEXING)
.withAnalyzingType(AnalyzingType.SUSPENDED)
}
else {
AnalyzerStatus(icon = inspectionsCompletedIcon, title = title, details = details, controller = uIController)
AnalyzerStatus(icon = inspectionsCompletedIcon, title = title, details = details, controller = uiController)
}
}
@@ -443,7 +448,7 @@ open class TrafficLightRenderer private constructor(
icon = AllIcons.General.InspectionsEye,
title = DaemonBundle.message("no.errors.or.warnings.found"),
details = details,
controller = this.uIController,
controller = this.uiController,
)
.withTextStatus(DaemonBundle.message("iw.status.analyzing"))
.withState(InspectionsState.ANALYZING)
@@ -473,7 +478,7 @@ open class TrafficLightRenderer private constructor(
ThreadingAssertions.assertBackgroundThread()
}
@Suppress("RemoveRedundantQualifierName")
@Suppress("RemoveRedundantQualifierName", "RedundantSuppression")
override fun getAvailableLevels(): List<InspectionsLevel?> {
return when {
inLibrary -> java.util.List.of(InspectionsLevel.NONE, InspectionsLevel.SYNTAX)
@@ -486,25 +491,23 @@ open class TrafficLightRenderer private constructor(
override fun getHighlightLevels(): List<LanguageHighlightLevel> {
return fileHighlightingSettings.entries.map { entry ->
LanguageHighlightLevel(langID = entry.key!!.id, level = FileHighlightingSetting.toInspectionsLevel(entry.value!!))
LanguageHighlightLevel(langID = entry.key.id, level = FileHighlightingSetting.toInspectionsLevel(entry.value))
}
}
override fun setHighLightLevel(level: LanguageHighlightLevel) {
val psiFile = psiFile
if (psiFile != null && !project.isDisposed() && !highlightLevels.contains(level)) {
val viewProvider = psiFile.getViewProvider()
val language = Language.findLanguageByID(level.langID)
if (language != null) {
val root = viewProvider.getPsi(language) ?: return
val setting = FileHighlightingSetting.fromInspectionsLevel(level.level)
HighlightLevelUtil.forceRootHighlighting(root, setting)
InjectedLanguageManager.getInstance(project).dropFileCaches(psiFile)
daemonCodeAnalyzer.restart()
// after that, TrafficLightRenderer will be recreated anew, no need to patch myFileHighlightingSettings
}
if (psiFile == null || project.isDisposed() || highlightLevels.contains(level)) {
return
}
val language = Language.findLanguageByID(level.langID) ?: return
val root = psiFile.getViewProvider().getPsi(language) ?: return
val setting = FileHighlightingSetting.fromInspectionsLevel(level.level)
HighlightLevelUtil.forceRootHighlighting(root, setting)
InjectedLanguageManager.getInstance(project).dropFileCaches(psiFile)
daemonCodeAnalyzer.restart()
// after that, TrafficLightRenderer will be recreated anew, no need to patch myFileHighlightingSettings
}
override fun fillHectorPanels(container: Container, gc: GridBag) {
@@ -519,22 +522,19 @@ open class TrafficLightRenderer private constructor(
additionalPanels = list
for (panel in additionalPanels) {
val c: JComponent?
try {
val c = try {
panel.reset()
c = panel.createComponent()
panel.createComponent()
}
catch (e: ProcessCanceledException) {
catch (e: CancellationException) {
throw e
}
catch (e: Throwable) {
Logger.getInstance(TrafficLightRenderer::class.java).error(e)
logger<TrafficLightRenderer>().error(e)
continue
}
} ?: continue
if (c != null) {
container.add(c, gc.nextLine().next().fillCellHorizontally().coverLine().weightx(1.0))
}
container.add(c, gc.nextLine().next().fillCellHorizontally().coverLine().weightx(1.0))
}
}
@@ -542,22 +542,23 @@ open class TrafficLightRenderer private constructor(
if (additionalPanels.isEmpty()) {
return true
}
if (additionalPanels.all { it.canClose() }) {
val psiFile = psiFile
var hasModified = false
for (panel in additionalPanels.asSequence().filter { it.isModified() }) {
hasModified = true
applyPanel(panel)
}
if (hasModified) {
if (psiFile != null) {
InjectedLanguageManager.getInstance(project).dropFileCaches(psiFile)
}
daemonCodeAnalyzer.restart()
}
return true
if (!additionalPanels.all { it.canClose() }) {
return false
}
return false
val psiFile = psiFile
var hasModified = false
for (panel in additionalPanels.asSequence().filter { it.isModified() }) {
hasModified = true
applyPanel(panel)
}
if (hasModified) {
if (psiFile != null) {
InjectedLanguageManager.getInstance(project).dropFileCaches(psiFile)
}
daemonCodeAnalyzer.restart()
}
return true
}
override fun onClosePopup() {
@@ -575,7 +576,7 @@ open class TrafficLightRenderer private constructor(
protected open inner class DefaultUIController : AbstractUIController() {
// only create actions when daemon widget used
@Suppress("RemoveRedundantQualifierName")
@Suppress("RemoveRedundantQualifierName", "RedundantSuppression")
private val menuActions by lazy {
java.util.List.of(
ActionManager.getInstance().getAction("ConfigureInspectionsAction"),

View File

@@ -16,7 +16,7 @@ import com.intellij.openapi.editor.SpellCheckingEditorCustomizationProvider;
import com.intellij.openapi.editor.colors.EditorColorsManager;
import com.intellij.openapi.editor.colors.EditorColorsScheme;
import com.intellij.openapi.editor.ex.EditorEx;
import com.intellij.openapi.editor.impl.EditorMarkupModelImpl;
import com.intellij.openapi.editor.ex.EditorMarkupModel;
import com.intellij.openapi.editor.markup.AnalyzerStatus;
import com.intellij.openapi.fileTypes.FileTypes;
import com.intellij.openapi.project.Project;
@@ -39,7 +39,6 @@ import com.intellij.util.ui.components.BorderLayoutPanel;
import com.intellij.vcs.commit.CommitMessageUi;
import com.intellij.vcs.commit.message.BodyLimitSettings;
import com.intellij.vcs.commit.message.CommitMessageInspectionProfile;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -326,13 +325,13 @@ public class CommitMessage extends JPanel implements Disposable, UiCompatibleDat
}
}
private static class ConditionalTrafficLightRenderer extends TrafficLightRenderer {
private static final class ConditionalTrafficLightRenderer extends TrafficLightRenderer {
ConditionalTrafficLightRenderer(@NotNull Project project, @NotNull Document document) {
super(project, document);
}
@Override
protected void refresh(@Nullable EditorMarkupModelImpl editorMarkupModel) {
public void refresh(@Nullable EditorMarkupModel editorMarkupModel) {
super.refresh(editorMarkupModel);
if (editorMarkupModel != null) {
editorMarkupModel.setTrafficLightIconVisible(hasHighSeverities(getErrorCounts()));
@@ -356,8 +355,7 @@ public class CommitMessage extends JPanel implements Disposable, UiCompatibleDat
}
}
@ApiStatus.Internal
public static class CommitMessageTrafficLightRendererContributor implements TrafficLightRendererContributor {
static final class CommitMessageTrafficLightRendererContributor implements TrafficLightRendererContributor {
@Override
public @Nullable TrafficLightRenderer createRenderer(@NotNull Editor editor, @Nullable PsiFile file) {
Project project = editor.getProject();

View File

@@ -13,24 +13,28 @@ import org.jetbrains.plugins.gradle.codeInspection.GradleInspectionBundle
import org.jetbrains.plugins.gradle.config.isGradleFile
import org.jetbrains.plugins.gradle.service.resolve.getLinkedGradleProjectPath
class GradleGroovyTrafficLightRendererContributor : TrafficLightRendererContributor {
private class GradleGroovyTrafficLightRendererContributor : TrafficLightRendererContributor {
override fun createRenderer(editor: Editor, file: PsiFile?): TrafficLightRenderer? {
if (file == null || !file.isGradleFile()) {
return null
}
return GradleGroovyTrafficLightRenderer(file, editor)
}
}
private class GradleGroovyTrafficLightRenderer(val file: PsiFile, editor: Editor) : TrafficLightRenderer(file.project, editor) {
val linkedProjectPath: String? get() = file.getLinkedGradleProjectPath()
private class GradleGroovyTrafficLightRenderer(private val file: PsiFile, editor: Editor) : TrafficLightRenderer(file.project, editor) {
override fun getStatus(): AnalyzerStatus {
val thisLinkedProjectPath = linkedProjectPath
if (thisLinkedProjectPath == null) return super.getStatus()
val thisLinkedProjectPath = file.getLinkedGradleProjectPath() ?: return super.getStatus()
val service = project.service<GradleSuspendTypecheckingService>()
if (!service.isSuspended(thisLinkedProjectPath)) return super.getStatus()
return AnalyzerStatus(AllIcons.RunConfigurations.TestIgnored, GradleInspectionBundle.message("traffic.light.inspections.disabled"), GradleInspectionBundle.message("traffic.light.inspections.disabled.description"), uiController)
.withAnalyzingType(AnalyzingType.PARTIAL)
if (!service.isSuspended(thisLinkedProjectPath)) {
return super.getStatus()
}
return AnalyzerStatus(
icon = AllIcons.RunConfigurations.TestIgnored,
title = GradleInspectionBundle.message("traffic.light.inspections.disabled"),
details = GradleInspectionBundle.message("traffic.light.inspections.disabled.description"),
controller = uiController,
)
.withAnalyzingType(AnalyzingType.PARTIAL)
}
}