mirror of
https://github.com/chylex/IntelliJ-Inspection-Lens.git
synced 2024-11-26 01:42:52 +01:00
Compare commits
3 Commits
87f6eda572
...
86a3a87da2
Author | SHA1 | Date | |
---|---|---|---|
86a3a87da2 | |||
797efb48a2 | |||
33bb46d0be |
@ -3,8 +3,8 @@
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
|
||||
plugins {
|
||||
kotlin("jvm") version "1.6.21"
|
||||
id("org.jetbrains.intellij") version "1.9.0"
|
||||
kotlin("jvm") version "1.8.0"
|
||||
id("org.jetbrains.intellij") version "1.13.3"
|
||||
}
|
||||
|
||||
group = "com.chylex.intellij.inspectionlens"
|
||||
@ -19,12 +19,12 @@ dependencies {
|
||||
}
|
||||
|
||||
intellij {
|
||||
version.set("2022.2")
|
||||
version.set("2023.1")
|
||||
updateSinceUntilBuild.set(false)
|
||||
}
|
||||
|
||||
tasks.patchPluginXml {
|
||||
sinceBuild.set("222")
|
||||
sinceBuild.set("231")
|
||||
}
|
||||
|
||||
tasks.buildSearchableOptions {
|
||||
@ -36,7 +36,7 @@ tasks.test {
|
||||
}
|
||||
|
||||
tasks.withType<KotlinCompile> {
|
||||
kotlinOptions.jvmTarget = "11"
|
||||
kotlinOptions.jvmTarget = "17"
|
||||
kotlinOptions.freeCompilerArgs = listOf(
|
||||
"-Xjvm-default=enable"
|
||||
)
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.chylex.intellij.inspectionlens
|
||||
|
||||
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.ex.FileEditorWithProvider
|
||||
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.
|
||||
*/
|
||||
class LensFileEditorListener : FileEditorManagerListener {
|
||||
override fun fileOpenedSync(source: FileEditorManager, file: VirtualFile, editorsWithProviders: MutableList<FileEditorWithProvider>) {
|
||||
class LensFileOpenedListener : FileOpenedSyncListener {
|
||||
override fun fileOpenedSync(source: FileEditorManager, file: VirtualFile, editorsWithProviders: List<FileEditorWithProvider>) {
|
||||
for (editorWrapper in editorsWithProviders) {
|
||||
val fileEditor = editorWrapper.fileEditor
|
||||
if (fileEditor is TextEditor) {
|
@ -31,7 +31,7 @@ class LensRenderer(info: HighlightInfo) : HintRenderer(null) {
|
||||
}
|
||||
|
||||
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 {
|
||||
|
@ -1,50 +1,27 @@
|
||||
package com.chylex.intellij.inspectionlens
|
||||
|
||||
import com.intellij.lang.annotation.HighlightSeverity
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.ui.ColorUtil
|
||||
import com.intellij.ui.JBColor
|
||||
import java.awt.Color
|
||||
|
||||
/**
|
||||
* Determines properties of inspection lenses based on severity.
|
||||
*/
|
||||
enum class LensSeverity(color: Color, darkThemeBrightening: Int, lightThemeDarkening: Int) {
|
||||
ERROR(
|
||||
Color(158, 41, 39),
|
||||
darkThemeBrightening = 4,
|
||||
lightThemeDarkening = 1,
|
||||
),
|
||||
@Suppress("UseJBColor", "InspectionUsingGrayColors")
|
||||
enum class LensSeverity(baseColor: Color, lightThemeDarkening: Int, darkThemeBrightening: Int) {
|
||||
ERROR (Color(158, 41, 39), lightThemeDarkening = 1, darkThemeBrightening = 4),
|
||||
WARNING (Color(190, 145, 23), lightThemeDarkening = 4, darkThemeBrightening = 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(
|
||||
Color(190, 145, 23),
|
||||
darkThemeBrightening = 1,
|
||||
lightThemeDarkening = 4,
|
||||
),
|
||||
val color: JBColor
|
||||
|
||||
WEAK_WARNING(
|
||||
Color(117, 109, 86),
|
||||
darkThemeBrightening = 3,
|
||||
lightThemeDarkening = 3,
|
||||
),
|
||||
|
||||
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
|
||||
init {
|
||||
val lightThemeColor = ColorUtil.saturate(ColorUtil.darker(baseColor, lightThemeDarkening), 1)
|
||||
val darkThemeColor = ColorUtil.desaturate(ColorUtil.brighter(baseColor, darkThemeBrightening), 2)
|
||||
color = JBColor(lightThemeColor, darkThemeColor)
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
@ -44,6 +44,6 @@
|
||||
</applicationListeners>
|
||||
|
||||
<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>
|
||||
</idea-plugin>
|
||||
|
Loading…
Reference in New Issue
Block a user