mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-238791: use icons from HighlightDisplayLevel
GitOrigin-RevId: 07bce6c76cc4dbff9d7a92a53c740d599277413d
This commit is contained in:
committed by
intellij-monorepo-bot
parent
0cfb4de02b
commit
7be390022e
@@ -27,14 +27,8 @@ internal class FileNode(parent: Node, val file: VirtualFile) : Node(parent) {
|
||||
presentation.addText(" ${getLocationRelativeToUserHome(url)}", GRAYED_ATTRIBUTES)
|
||||
}
|
||||
val root = findAncestor(Root::class.java)
|
||||
if (root != null) {
|
||||
val errors = root.getProblemsCount(file, Severity.ERROR)
|
||||
if (errors > 0) presentation.addText(" $errors errors", GRAYED_ATTRIBUTES)
|
||||
val warnings = root.getProblemsCount(file, Severity.WARNING)
|
||||
if (warnings > 0) presentation.addText(" $warnings warnings", GRAYED_ATTRIBUTES)
|
||||
val info = root.getProblemsCount(file, Severity.INFORMATION)
|
||||
if (info > 0) presentation.addText(" $warnings info", GRAYED_ATTRIBUTES)
|
||||
}
|
||||
val count = root?.getProblemsCount(file) ?: 0
|
||||
if (count > 0) presentation.addText(" $count problems", GRAYED_ATTRIBUTES)
|
||||
}
|
||||
|
||||
override fun getChildren(): Collection<Node> {
|
||||
|
||||
@@ -55,6 +55,4 @@ internal class FileProblems(val file: VirtualFile) {
|
||||
}
|
||||
|
||||
fun count() = problems.size
|
||||
|
||||
fun count(severity: Severity) = problems.count { it.severity == severity }
|
||||
}
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ internal class HighlightingFileRoot(panel: ProblemsViewPanel, val file: VirtualF
|
||||
|
||||
override fun getProblemsCount() = synchronized(problems) { problems.count() }
|
||||
|
||||
override fun getProblemsCount(file: VirtualFile, severity: Severity) = synchronized(problems) { problems.count(severity) }
|
||||
override fun getProblemsCount(file: VirtualFile) = synchronized(problems) { problems.count() }
|
||||
|
||||
override fun addProblem(file: VirtualFile, problem: Problem) {
|
||||
synchronized(problems) { problems.add(problem) }
|
||||
|
||||
+14
-9
@@ -1,11 +1,11 @@
|
||||
// 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.analysis.problemsView.toolWindow
|
||||
|
||||
import com.intellij.codeHighlighting.HighlightDisplayLevel
|
||||
import com.intellij.codeInsight.daemon.impl.HighlightInfo
|
||||
import com.intellij.codeInsight.intention.IntentionAction
|
||||
import com.intellij.codeInsight.intention.impl.ShowIntentionActionsHandler.chooseActionAndInvoke
|
||||
import com.intellij.icons.AllIcons.Actions.IntentionBulb
|
||||
import com.intellij.lang.annotation.HighlightSeverity
|
||||
import com.intellij.icons.AllIcons
|
||||
import com.intellij.lang.injection.InjectedLanguageManager
|
||||
import com.intellij.openapi.actionSystem.AnAction
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent
|
||||
@@ -13,18 +13,23 @@ import com.intellij.openapi.editor.RangeMarker
|
||||
import com.intellij.openapi.util.text.StringUtil.isEmpty
|
||||
import com.intellij.psi.PsiDocumentManager
|
||||
import com.intellij.psi.PsiFile
|
||||
import javax.swing.Icon
|
||||
|
||||
internal class HighlightingProblem(val info: HighlightInfo) : Problem {
|
||||
|
||||
private fun getIcon(level: HighlightDisplayLevel) = if (severity >= level.severity.myVal) level.icon else null
|
||||
|
||||
override val icon: Icon
|
||||
get() = HighlightDisplayLevel.find(info.severity)?.icon
|
||||
?: getIcon(HighlightDisplayLevel.ERROR)
|
||||
?: getIcon(HighlightDisplayLevel.WARNING)
|
||||
?: HighlightDisplayLevel.WEAK_WARNING.icon
|
||||
|
||||
override val description: String
|
||||
get() = info.description
|
||||
|
||||
override val severity: Severity
|
||||
get() = when (info.severity) {
|
||||
HighlightSeverity.ERROR -> Severity.ERROR
|
||||
HighlightSeverity.WARNING -> Severity.WARNING
|
||||
else -> Severity.INFORMATION
|
||||
}
|
||||
override val severity: Int
|
||||
get() = info.severity.myVal
|
||||
|
||||
override val offset: Int
|
||||
get() = info.actualStartOffset
|
||||
@@ -45,7 +50,7 @@ internal class HighlightingProblem(val info: HighlightInfo) : Problem {
|
||||
}
|
||||
|
||||
private class QuickFixAction(val action: IntentionAction, val marker: RangeMarker)
|
||||
: AnAction(action.text, action.text, IntentionBulb) {
|
||||
: AnAction(action.text, action.text, AllIcons.Actions.IntentionBulb) {
|
||||
|
||||
override fun update(event: AnActionEvent) {
|
||||
event.presentation.isEnabledAndVisible = getTopLevelFile(event) != null
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ internal data class NodeComparator(
|
||||
|
||||
private fun compare(problem1: Problem, problem2: Problem): Int {
|
||||
if (sortBySeverity) {
|
||||
val result = problem1.severity.compareTo(problem2.severity)
|
||||
val result = problem2.severity.compareTo(problem1.severity)
|
||||
if (result != 0) return result
|
||||
}
|
||||
return if (sortByName) {
|
||||
|
||||
@@ -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.analysis.problemsView.toolWindow
|
||||
|
||||
import com.intellij.lang.annotation.HighlightSeverity
|
||||
import java.util.function.Predicate
|
||||
|
||||
internal data class NodeFilter(
|
||||
@@ -10,11 +11,12 @@ internal data class NodeFilter(
|
||||
: Predicate<Node?> {
|
||||
|
||||
override fun test(node: Node?): Boolean {
|
||||
return if (node !is ProblemNode) true
|
||||
else when (node.problem.severity) {
|
||||
Severity.ERROR -> showErrors
|
||||
Severity.WARNING -> showWarnings
|
||||
Severity.INFORMATION -> showInformation
|
||||
// TODO: update filter
|
||||
return when {
|
||||
node !is ProblemNode -> true
|
||||
node.problem.severity < HighlightSeverity.WARNING.myVal -> showInformation
|
||||
node.problem.severity < HighlightSeverity.ERROR.myVal -> showWarnings
|
||||
else -> showErrors
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,10 +2,12 @@
|
||||
package com.intellij.analysis.problemsView.toolWindow
|
||||
|
||||
import com.intellij.openapi.actionSystem.AnAction
|
||||
import javax.swing.Icon
|
||||
|
||||
interface Problem {
|
||||
val icon: Icon
|
||||
val description: String
|
||||
val severity: Severity
|
||||
val severity: Int
|
||||
val offset: Int
|
||||
|
||||
fun hasQuickFixActions() = false
|
||||
|
||||
@@ -16,7 +16,7 @@ internal class ProblemNode(parent: FileNode, val problem: Problem) : Node(parent
|
||||
override fun getName() = problem.description
|
||||
|
||||
override fun update(project: Project, presentation: PresentationData) {
|
||||
presentation.setIcon(problem.severity.icon)
|
||||
presentation.setIcon(problem.icon)
|
||||
val document = ProblemsView.getDocument(project, file) ?: return // add nothing if no document
|
||||
if (!isValidOffset(problem.offset, document)) return
|
||||
val line = document.getLineNumber(problem.offset) + 1
|
||||
|
||||
@@ -32,8 +32,8 @@ internal open class Root(val panel: ProblemsViewPanel) : Node(panel.project), Di
|
||||
allProblems.values.sumBy { it.count() }
|
||||
}
|
||||
|
||||
open fun getProblemsCount(file: VirtualFile, severity: Severity): Int = synchronized(allProblems) {
|
||||
allProblems[file]?.count(severity) ?: 0
|
||||
open fun getProblemsCount(file: VirtualFile): Int = synchronized(allProblems) {
|
||||
allProblems[file]?.count() ?: 0
|
||||
}
|
||||
|
||||
open fun addProblem(file: VirtualFile, problem: Problem) {
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
// 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.analysis.problemsView.toolWindow
|
||||
|
||||
import com.intellij.icons.AllIcons.General
|
||||
import javax.swing.Icon
|
||||
|
||||
enum class Severity(val icon: Icon) {
|
||||
ERROR(General.Error),
|
||||
WARNING(General.Warning),
|
||||
INFORMATION(General.Information),
|
||||
}
|
||||
Reference in New Issue
Block a user