mirror of
https://github.com/chylex/IntelliJ-Inspection-Lens.git
synced 2024-11-26 01:42:52 +01:00
Compare commits
No commits in common. "86a3a87da2a2eea14e05d7e3deee4b15dd92d3ca" and "87f6eda57269e1bb877e9aacf6f07bdb23fd05f3" have entirely different histories.
86a3a87da2
...
87f6eda572
@ -3,8 +3,8 @@
|
|||||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
kotlin("jvm") version "1.8.0"
|
kotlin("jvm") version "1.6.21"
|
||||||
id("org.jetbrains.intellij") version "1.13.3"
|
id("org.jetbrains.intellij") version "1.9.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "com.chylex.intellij.inspectionlens"
|
group = "com.chylex.intellij.inspectionlens"
|
||||||
@ -19,12 +19,12 @@ dependencies {
|
|||||||
}
|
}
|
||||||
|
|
||||||
intellij {
|
intellij {
|
||||||
version.set("2023.1")
|
version.set("2022.2")
|
||||||
updateSinceUntilBuild.set(false)
|
updateSinceUntilBuild.set(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.patchPluginXml {
|
tasks.patchPluginXml {
|
||||||
sinceBuild.set("231")
|
sinceBuild.set("222")
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.buildSearchableOptions {
|
tasks.buildSearchableOptions {
|
||||||
@ -36,7 +36,7 @@ tasks.test {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType<KotlinCompile> {
|
tasks.withType<KotlinCompile> {
|
||||||
kotlinOptions.jvmTarget = "17"
|
kotlinOptions.jvmTarget = "11"
|
||||||
kotlinOptions.freeCompilerArgs = listOf(
|
kotlinOptions.freeCompilerArgs = listOf(
|
||||||
"-Xjvm-default=enable"
|
"-Xjvm-default=enable"
|
||||||
)
|
)
|
||||||
|
@ -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.FileOpenedSyncListener
|
import com.intellij.openapi.fileEditor.FileEditorManagerListener
|
||||||
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 LensFileOpenedListener : FileOpenedSyncListener {
|
class LensFileEditorListener : FileEditorManagerListener {
|
||||||
override fun fileOpenedSync(source: FileEditorManager, file: VirtualFile, editorsWithProviders: List<FileEditorWithProvider>) {
|
override fun fileOpenedSync(source: FileEditorManager, file: VirtualFile, editorsWithProviders: MutableList<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) {
|
@ -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.color }
|
return ATTRIBUTES_SINGLETON.also { it.foregroundColor = severity.getColor(editor) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun useEditorFont(): Boolean {
|
override fun useEditorFont(): Boolean {
|
||||||
|
@ -1,27 +1,50 @@
|
|||||||
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.
|
||||||
*/
|
*/
|
||||||
@Suppress("UseJBColor", "InspectionUsingGrayColors")
|
enum class LensSeverity(color: Color, darkThemeBrightening: Int, lightThemeDarkening: Int) {
|
||||||
enum class LensSeverity(baseColor: Color, lightThemeDarkening: Int, darkThemeBrightening: Int) {
|
ERROR(
|
||||||
ERROR (Color(158, 41, 39), lightThemeDarkening = 1, darkThemeBrightening = 4),
|
Color(158, 41, 39),
|
||||||
WARNING (Color(190, 145, 23), lightThemeDarkening = 4, darkThemeBrightening = 1),
|
darkThemeBrightening = 4,
|
||||||
WEAK_WARNING (Color(117, 109, 86), lightThemeDarkening = 3, darkThemeBrightening = 3),
|
lightThemeDarkening = 1,
|
||||||
SERVER_PROBLEM (Color(176, 97, 0), lightThemeDarkening = 4, darkThemeBrightening = 2),
|
),
|
||||||
OTHER (Color(128, 128, 128), lightThemeDarkening = 1, darkThemeBrightening = 2);
|
|
||||||
|
|
||||||
val color: JBColor
|
WARNING(
|
||||||
|
Color(190, 145, 23),
|
||||||
|
darkThemeBrightening = 1,
|
||||||
|
lightThemeDarkening = 4,
|
||||||
|
),
|
||||||
|
|
||||||
init {
|
WEAK_WARNING(
|
||||||
val lightThemeColor = ColorUtil.saturate(ColorUtil.darker(baseColor, lightThemeDarkening), 1)
|
Color(117, 109, 86),
|
||||||
val darkThemeColor = ColorUtil.desaturate(ColorUtil.brighter(baseColor, darkThemeBrightening), 2)
|
darkThemeBrightening = 3,
|
||||||
color = JBColor(lightThemeColor, darkThemeColor)
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
@ -44,6 +44,6 @@
|
|||||||
</applicationListeners>
|
</applicationListeners>
|
||||||
|
|
||||||
<projectListeners>
|
<projectListeners>
|
||||||
<listener class="com.chylex.intellij.inspectionlens.LensFileOpenedListener" topic="com.intellij.openapi.fileEditor.FileOpenedSyncListener" />
|
<listener class="com.chylex.intellij.inspectionlens.LensFileEditorListener" topic="com.intellij.openapi.fileEditor.FileEditorManagerListener" />
|
||||||
</projectListeners>
|
</projectListeners>
|
||||||
</idea-plugin>
|
</idea-plugin>
|
||||||
|
Loading…
Reference in New Issue
Block a user