1
0
mirror of https://github.com/chylex/IntelliJ-Inspection-Lens.git synced 2024-11-26 01:42:52 +01:00

Compare commits

...

3 Commits

5 changed files with 23 additions and 46 deletions

View File

@ -3,8 +3,8 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins { plugins {
kotlin("jvm") version "1.6.21" kotlin("jvm") version "1.8.0"
id("org.jetbrains.intellij") version "1.9.0" id("org.jetbrains.intellij") version "1.13.3"
} }
group = "com.chylex.intellij.inspectionlens" group = "com.chylex.intellij.inspectionlens"
@ -19,12 +19,12 @@ dependencies {
} }
intellij { intellij {
version.set("2022.2") version.set("2023.1")
updateSinceUntilBuild.set(false) updateSinceUntilBuild.set(false)
} }
tasks.patchPluginXml { tasks.patchPluginXml {
sinceBuild.set("222") sinceBuild.set("231")
} }
tasks.buildSearchableOptions { tasks.buildSearchableOptions {
@ -36,7 +36,7 @@ tasks.test {
} }
tasks.withType<KotlinCompile> { tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "11" kotlinOptions.jvmTarget = "17"
kotlinOptions.freeCompilerArgs = listOf( kotlinOptions.freeCompilerArgs = listOf(
"-Xjvm-default=enable" "-Xjvm-default=enable"
) )

View File

@ -1,7 +1,7 @@
package com.chylex.intellij.inspectionlens package com.chylex.intellij.inspectionlens
import com.intellij.openapi.fileEditor.FileEditorManager import com.intellij.openapi.fileEditor.FileEditorManager
import com.intellij.openapi.fileEditor.FileEditorManagerListener import com.intellij.openapi.fileEditor.FileOpenedSyncListener
import com.intellij.openapi.fileEditor.TextEditor import com.intellij.openapi.fileEditor.TextEditor
import com.intellij.openapi.fileEditor.ex.FileEditorWithProvider import com.intellij.openapi.fileEditor.ex.FileEditorWithProvider
import com.intellij.openapi.vfs.VirtualFile import com.intellij.openapi.vfs.VirtualFile
@ -9,8 +9,8 @@ import com.intellij.openapi.vfs.VirtualFile
/** /**
* Listens for newly opened editors, and installs a [LensMarkupModelListener] on them. * Listens for newly opened editors, and installs a [LensMarkupModelListener] on them.
*/ */
class LensFileEditorListener : FileEditorManagerListener { class LensFileOpenedListener : FileOpenedSyncListener {
override fun fileOpenedSync(source: FileEditorManager, file: VirtualFile, editorsWithProviders: MutableList<FileEditorWithProvider>) { override fun fileOpenedSync(source: FileEditorManager, file: VirtualFile, editorsWithProviders: List<FileEditorWithProvider>) {
for (editorWrapper in editorsWithProviders) { for (editorWrapper in editorsWithProviders) {
val fileEditor = editorWrapper.fileEditor val fileEditor = editorWrapper.fileEditor
if (fileEditor is TextEditor) { if (fileEditor is TextEditor) {

View File

@ -31,7 +31,7 @@ class LensRenderer(info: HighlightInfo) : HintRenderer(null) {
} }
override fun getTextAttributes(editor: Editor): TextAttributes { override fun getTextAttributes(editor: Editor): TextAttributes {
return ATTRIBUTES_SINGLETON.also { it.foregroundColor = severity.getColor(editor) } return ATTRIBUTES_SINGLETON.also { it.foregroundColor = severity.color }
} }
override fun useEditorFont(): Boolean { override fun useEditorFont(): Boolean {

View File

@ -1,50 +1,27 @@
package com.chylex.intellij.inspectionlens package com.chylex.intellij.inspectionlens
import com.intellij.lang.annotation.HighlightSeverity import com.intellij.lang.annotation.HighlightSeverity
import com.intellij.openapi.editor.Editor
import com.intellij.ui.ColorUtil import com.intellij.ui.ColorUtil
import com.intellij.ui.JBColor
import java.awt.Color import java.awt.Color
/** /**
* Determines properties of inspection lenses based on severity. * Determines properties of inspection lenses based on severity.
*/ */
enum class LensSeverity(color: Color, darkThemeBrightening: Int, lightThemeDarkening: Int) { @Suppress("UseJBColor", "InspectionUsingGrayColors")
ERROR( enum class LensSeverity(baseColor: Color, lightThemeDarkening: Int, darkThemeBrightening: Int) {
Color(158, 41, 39), ERROR (Color(158, 41, 39), lightThemeDarkening = 1, darkThemeBrightening = 4),
darkThemeBrightening = 4, WARNING (Color(190, 145, 23), lightThemeDarkening = 4, darkThemeBrightening = 1),
lightThemeDarkening = 1, WEAK_WARNING (Color(117, 109, 86), lightThemeDarkening = 3, darkThemeBrightening = 3),
), SERVER_PROBLEM (Color(176, 97, 0), lightThemeDarkening = 4, darkThemeBrightening = 2),
OTHER (Color(128, 128, 128), lightThemeDarkening = 1, darkThemeBrightening = 2);
WARNING( val color: JBColor
Color(190, 145, 23),
darkThemeBrightening = 1,
lightThemeDarkening = 4,
),
WEAK_WARNING( init {
Color(117, 109, 86), val lightThemeColor = ColorUtil.saturate(ColorUtil.darker(baseColor, lightThemeDarkening), 1)
darkThemeBrightening = 3, val darkThemeColor = ColorUtil.desaturate(ColorUtil.brighter(baseColor, darkThemeBrightening), 2)
lightThemeDarkening = 3, color = JBColor(lightThemeColor, darkThemeColor)
),
SERVER_PROBLEM(
Color(176, 97, 0),
darkThemeBrightening = 2,
lightThemeDarkening = 4,
),
OTHER(
Color(128, 128, 128),
darkThemeBrightening = 2,
lightThemeDarkening = 1,
);
private val darkThemeColor = ColorUtil.desaturate(ColorUtil.brighter(color, darkThemeBrightening), 2)
private val lightThemeColor = ColorUtil.saturate(ColorUtil.darker(color, lightThemeDarkening), 1)
fun getColor(editor: Editor): Color {
val isDarkTheme = ColorUtil.isDark(editor.colorsScheme.defaultBackground)
return if (isDarkTheme) darkThemeColor else lightThemeColor
} }
companion object { companion object {

View File

@ -44,6 +44,6 @@
</applicationListeners> </applicationListeners>
<projectListeners> <projectListeners>
<listener class="com.chylex.intellij.inspectionlens.LensFileEditorListener" topic="com.intellij.openapi.fileEditor.FileEditorManagerListener" /> <listener class="com.chylex.intellij.inspectionlens.LensFileOpenedListener" topic="com.intellij.openapi.fileEditor.FileOpenedSyncListener" />
</projectListeners> </projectListeners>
</idea-plugin> </idea-plugin>