1
0
mirror of https://github.com/chylex/IntelliJ-Rainbow-Brackets.git synced 2025-01-30 22:46:00 +01:00

Compare commits

..

4 Commits

Author SHA1 Message Date
2977a08009
Fix service initialization
Closes #1
2024-11-30 22:26:27 +01:00
ec78647a17
Fix support for CLion and Rider 2024-11-30 20:58:21 +01:00
4ad30ca3dc
Migrate packages 2024-11-30 20:56:26 +01:00
06765e9d7f
Fork Rainbow Brackets 6.26 2024-11-30 20:56:10 +01:00
93 changed files with 456 additions and 304 deletions

View File

@ -0,0 +1,24 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Run CLion" type="GradleRunConfiguration" factoryName="Gradle">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list>
<option value=":clion:runIde" />
</list>
</option>
<option name="vmOptions" />
</ExternalSystemSettings>
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<RunAsTest>false</RunAsTest>
<method v="2" />
</configuration>
</component>

View File

@ -0,0 +1,24 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Run IDEA" type="GradleRunConfiguration" factoryName="Gradle">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list>
<option value=":runIde" />
</list>
</option>
<option name="vmOptions" />
</ExternalSystemSettings>
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<RunAsTest>false</RunAsTest>
<method v="2" />
</configuration>
</component>

View File

@ -0,0 +1,24 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Run Rider" type="GradleRunConfiguration" factoryName="Gradle">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list>
<option value=":rider:runIde" />
</list>
</option>
<option name="vmOptions" />
</ExternalSystemSettings>
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<RunAsTest>false</RunAsTest>
<method v="2" />
</configuration>
</component>

View File

@ -1,3 +1,8 @@
# Colored Brackets # Colored Brackets
This is a fork of the [🌈Rainbow Brackets](https://github.com/izhangzhihao/intellij-rainbow-brackets) plugin by [izhangzhihao](https://github.com/izhangzhihao), based on version 6.26. This is a fork of the [🌈Rainbow Brackets](https://github.com/izhangzhihao/intellij-rainbow-brackets) plugin by [izhangzhihao](https://github.com/izhangzhihao), based on version 6.26.
## Key Changes
- Support for CLion and Rider
- Fixed service initialization warnings reported by 2024.2+

View File

@ -1,23 +1,54 @@
@file:Suppress("ConvertLambdaToReference") @file:Suppress("ConvertLambdaToReference")
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import kotlin.io.path.Path
plugins { plugins {
kotlin("jvm") version "1.9.21" kotlin("jvm")
id("org.jetbrains.intellij") version "1.17.4" id("org.jetbrains.intellij")
} }
group = "com.chylex.intellij.coloredbrackets" group = "com.chylex.intellij.coloredbrackets"
version = "0.0.1" version = "0.0.1"
repositories { allprojects {
mavenCentral() apply(plugin = "org.jetbrains.kotlin.jvm")
apply(plugin = "org.jetbrains.intellij")
repositories {
mavenCentral()
}
intellij {
version.set("2023.3")
updateSinceUntilBuild.set(false)
}
kotlin {
jvmToolchain(17)
}
tasks.withType<KotlinCompile> {
kotlinOptions.freeCompilerArgs = listOf(
"-Xjvm-default=all"
)
}
}
subprojects {
tasks.buildSearchableOptions {
enabled = false
}
}
idea {
module {
excludeDirs.add(file("gradle"))
}
} }
intellij { intellij {
type.set("IU") type.set("IU")
version.set("2023.3")
updateSinceUntilBuild.set(false)
plugins.set( plugins.set(
listOf( listOf(
@ -42,13 +73,7 @@ intellij {
) )
} }
kotlin {
jvmToolchain(17)
}
dependencies { dependencies {
compileOnly(fileTree("libs"))
testImplementation("junit:junit:4.13.2") testImplementation("junit:junit:4.13.2")
testImplementation("io.kotest:kotest-assertions-core:5.8.0") { testImplementation("io.kotest:kotest-assertions-core:5.8.0") {
exclude(group = "org.jetbrains.kotlin") exclude(group = "org.jetbrains.kotlin")
@ -63,8 +88,42 @@ tasks.test {
useJUnit() useJUnit()
} }
tasks.withType<KotlinCompile> { tasks.buildPlugin {
kotlinOptions.freeCompilerArgs = listOf( val projectName = rootProject.name
"-Xjvm-default=all" val instrumentedJarName = "instrumented-$projectName-$version"
)
for (ide in listOf("clion", "rider")) {
val task = project(":$ide").tasks.buildPlugin
dependsOn(task)
from(task.map { it.outputs.files.map(::zipTree) }) {
include("$ide/lib/instrumented-$ide.jar")
into("lib")
eachFile {
val newName = name.replace("instrumented-", "${instrumentedJarName}-")
val newPath = relativePath.segments.dropLast(3).plus(newName)
relativePath = RelativePath(true, *newPath.toTypedArray())
}
includeEmptyDirs = false
}
}
doLast {
val expectedPaths = listOf(
Path(projectName, "lib", "instrumented-$projectName-$version-clion.jar"),
Path(projectName, "lib", "instrumented-$projectName-$version-rider.jar"),
Path(projectName, "lib", "instrumented-$projectName-$version.jar"),
Path(projectName, "lib", "searchableOptions-$version.jar"),
)
val jarFiles = zipTree(outputs.files.singleFile)
for (expectedPath in expectedPaths) {
val found = jarFiles.find { it.toPath().endsWith(expectedPath) }
checkNotNull(found) { "Expected path not found: $expectedPath" }
}
}
} }

1
clion/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/build/

12
clion/build.gradle.kts Normal file
View File

@ -0,0 +1,12 @@
intellij {
type.set("CL")
plugins.set(listOf(
// Built-in
"cidr-base-plugin"
))
}
dependencies {
implementation(rootProject)
}

View File

@ -0,0 +1,8 @@
package com.chylex.intellij.coloredbrackets.provider
import com.intellij.lang.BracePair
import com.jetbrains.cidr.lang.parser.OCLexerTokenTypes
class OCBracePairProvider : BracePairProvider {
override fun pairs(): List<BracePair> = listOf(BracePair(OCLexerTokenTypes.LT, OCLexerTokenTypes.GT, false))
}

View File

@ -1,6 +1,6 @@
<idea-plugin> <idea-plugin>
<extensions defaultExtensionNs="com.chylex.coloredbrackets"> <extensions defaultExtensionNs="com.chylex.coloredbrackets">
<bracePairProvider language="ObjectiveC" <bracePairProvider language="ObjectiveC"
implementationClass="com.github.izhangzhihao.rainbow.brackets.provider.OCBracePairProvider" /> implementationClass="com.chylex.intellij.coloredbrackets.provider.OCBracePairProvider" />
</extensions> </extensions>
</idea-plugin> </idea-plugin>

Binary file not shown.

Binary file not shown.

1
rider/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/build/

7
rider/build.gradle.kts Normal file
View File

@ -0,0 +1,7 @@
intellij {
type.set("RD")
}
dependencies {
implementation(rootProject)
}

View File

@ -0,0 +1,13 @@
package com.chylex.intellij.coloredbrackets.provider
import com.intellij.lang.BracePair
import com.jetbrains.rider.languages.fileTypes.csharp.kotoparser.lexer.CSharpTokenType
class CSharpBracePairProvider : BracePairProvider {
override fun pairs(): List<BracePair> = listOf(
BracePair(CSharpTokenType.LPARENTH, CSharpTokenType.RPARENTH, false),
BracePair(CSharpTokenType.LBRACE, CSharpTokenType.RBRACE, false),
BracePair(CSharpTokenType.LBRACKET, CSharpTokenType.RBRACKET, false),
BracePair(CSharpTokenType.LT, CSharpTokenType.GT, false),
)
}

View File

@ -1,16 +1,14 @@
package com.github.izhangzhihao.rainbow.brackets.visitor package com.chylex.intellij.coloredbrackets.visitor
import com.github.izhangzhihao.rainbow.brackets.settings.RainbowSettings import com.chylex.intellij.coloredbrackets.settings.RainbowSettings
import com.intellij.codeInsight.daemon.impl.HighlightVisitor import com.intellij.codeInsight.daemon.impl.HighlightVisitor
import com.intellij.lang.BracePair import com.intellij.lang.BracePair
import com.intellij.psi.PsiElement import com.intellij.psi.PsiElement
import com.intellij.psi.PsiFile import com.intellij.psi.PsiFile
import com.intellij.psi.impl.source.tree.LeafPsiElement import com.intellij.psi.impl.source.tree.LeafPsiElement
import com.intellij.psi.tree.IElementType import com.intellij.psi.tree.IElementType
import com.jetbrains.rider.ideaInterop.fileTypes.csharp.lexer.CSharpTokenType.LPARENTH import com.jetbrains.rider.languages.fileTypes.csharp.kotoparser.lexer.CSharpTokenType
import com.jetbrains.rider.ideaInterop.fileTypes.csharp.lexer.CSharpTokenType.RPARENTH import com.jetbrains.rider.languages.fileTypes.csharp.psi.CSharpDummyNode
import com.jetbrains.rider.ideaInterop.fileTypes.csharp.psi.CSharpDummyNode
class CSharpRainbowVisitor : RainbowHighlightVisitor() { class CSharpRainbowVisitor : RainbowHighlightVisitor() {
@ -49,8 +47,8 @@ class CSharpRainbowVisitor : RainbowHighlightVisitor() {
companion object { companion object {
val map = mapOf( val map = mapOf(
LPARENTH to BracePair(LPARENTH, RPARENTH, true), CSharpTokenType.LPARENTH to BracePair(CSharpTokenType.LPARENTH, CSharpTokenType.RPARENTH, true),
RPARENTH to BracePair(LPARENTH, RPARENTH, true), CSharpTokenType.RPARENTH to BracePair(CSharpTokenType.LPARENTH, CSharpTokenType.RPARENTH, true),
//LT to BracePair(LT, GT, true), //LT to BracePair(LT, GT, true),
//GT to BracePair(LT, GT, true), //GT to BracePair(LT, GT, true),
) )
@ -113,7 +111,6 @@ class CSharpRainbowVisitor : RainbowHighlightVisitor() {
} }
} }
private tailrec fun PsiElement?.iterForPreDummyNode(): PsiElement? { private tailrec fun PsiElement?.iterForPreDummyNode(): PsiElement? {
return if (this == null) { return if (this == null) {
null null

View File

@ -0,0 +1,5 @@
<idea-plugin>
<extensions defaultExtensionNs="com.intellij">
<annotator language="C#" implementationClass="com.chylex.intellij.coloredbrackets.annotator.RainbowAnnotator" />
</extensions>
</idea-plugin>

View File

@ -0,0 +1,10 @@
<idea-plugin>
<extensions defaultExtensionNs="com.chylex.coloredbrackets">
<bracePairProvider language="C#"
implementationClass="com.chylex.intellij.coloredbrackets.provider.CSharpBracePairProvider" />
</extensions>
<extensions defaultExtensionNs="com.intellij">
<highlightVisitor implementation="com.chylex.intellij.coloredbrackets.visitor.CSharpRainbowVisitor" />
</extensions>
</idea-plugin>

View File

@ -1 +1,11 @@
rootProject.name = "ColoredBrackets" rootProject.name = "ColoredBrackets"
pluginManagement {
plugins {
kotlin("jvm") version "1.9.21"
id("org.jetbrains.intellij") version "1.17.4"
}
}
include("clion")
include("rider")

View File

@ -1,7 +1,7 @@
package com.github.izhangzhihao.rainbow.brackets package com.chylex.intellij.coloredbrackets
import com.github.izhangzhihao.rainbow.brackets.provider.BracePairProvider import com.chylex.intellij.coloredbrackets.provider.BracePairProvider
import com.github.izhangzhihao.rainbow.brackets.util.memoize import com.chylex.intellij.coloredbrackets.util.memoize
import com.intellij.codeInsight.highlighting.BraceMatchingUtil import com.intellij.codeInsight.highlighting.BraceMatchingUtil
import com.intellij.lang.BracePair import com.intellij.lang.BracePair
import com.intellij.lang.CompositeLanguage import com.intellij.lang.CompositeLanguage
@ -11,11 +11,12 @@ import com.intellij.lang.LanguageExtension
import com.intellij.lang.PairedBraceMatcher import com.intellij.lang.PairedBraceMatcher
import com.intellij.psi.tree.IElementType import com.intellij.psi.tree.IElementType
@Suppress("ConvertLambdaToReference")
object BracePairs { object BracePairs {
private val providers = LanguageExtension<BracePairProvider>("com.chylex.coloredbrackets.bracePairProvider") private val providers = LanguageExtension<BracePairProvider>("com.chylex.coloredbrackets.bracePairProvider")
private val bracePairs = private val bracePairs = lazy {
Language.getRegisteredLanguages() Language.getRegisteredLanguages()
.map { language -> .map { language ->
if (language is CompositeLanguage) { if (language is CompositeLanguage) {
@ -71,8 +72,9 @@ object BracePairs {
language.displayName to braceMap language.displayName to braceMap
} }
.toMap() .toMap()
}
fun getBracePairs(language: Language): MutableMap<String, MutableList<BracePair>>? = bracePairs[language.displayName] fun getBracePairs(language: Language): MutableMap<String, MutableList<BracePair>>? = bracePairs.value[language.displayName]
private fun getBraceTypeSetOf(language: Language): Set<IElementType> = getBracePairs(language)?.values?.flatten()?.map { listOf(it.leftBraceType, it.rightBraceType) }?.flatten()?.toSet() ?: emptySet() private fun getBraceTypeSetOf(language: Language): Set<IElementType> = getBracePairs(language)?.values?.flatten()?.map { listOf(it.leftBraceType, it.rightBraceType) }?.flatten()?.toSet() ?: emptySet()

View File

@ -1,7 +1,7 @@
package com.github.izhangzhihao.rainbow.brackets package com.chylex.intellij.coloredbrackets
import com.github.izhangzhihao.rainbow.brackets.settings.RainbowSettings import com.chylex.intellij.coloredbrackets.settings.RainbowSettings
import com.github.izhangzhihao.rainbow.brackets.util.memoize import com.chylex.intellij.coloredbrackets.util.memoize
import com.intellij.codeInsight.daemon.impl.HighlightInfo import com.intellij.codeInsight.daemon.impl.HighlightInfo
import com.intellij.codeInsight.daemon.impl.HighlightInfoType import com.intellij.codeInsight.daemon.impl.HighlightInfoType
import com.intellij.lang.annotation.HighlightSeverity import com.intellij.lang.annotation.HighlightSeverity
@ -39,16 +39,21 @@ object RainbowHighlighter {
private val squigglyBrackets: CharArray = charArrayOf('{', '}') private val squigglyBrackets: CharArray = charArrayOf('{', '}')
private val angleBrackets: CharArray = charArrayOf('<', '>') private val angleBrackets: CharArray = charArrayOf('<', '>')
private val settings = RainbowSettings.instance private val settings
get() = RainbowSettings.instance
private val roundBracketsRainbowColorKeys: Array<TextAttributesKey> = private val roundBracketsRainbowColorKeys = lazy {
createRainbowAttributesKeys(KEY_ROUND_BRACKETS, settings.numberOfColors) createRainbowAttributesKeys(KEY_ROUND_BRACKETS, settings.numberOfColors)
private val squareBracketsRainbowColorKeys: Array<TextAttributesKey> = }
private val squareBracketsRainbowColorKeys = lazy {
createRainbowAttributesKeys(KEY_SQUARE_BRACKETS, settings.numberOfColors) createRainbowAttributesKeys(KEY_SQUARE_BRACKETS, settings.numberOfColors)
private val squigglyBracketsRainbowColorKeys: Array<TextAttributesKey> = }
private val squigglyBracketsRainbowColorKeys = lazy {
createRainbowAttributesKeys(KEY_SQUIGGLY_BRACKETS, settings.numberOfColors) createRainbowAttributesKeys(KEY_SQUIGGLY_BRACKETS, settings.numberOfColors)
private val angleBracketsRainbowColorKeys: Array<TextAttributesKey> = }
private val angleBracketsRainbowColorKeys = lazy {
createRainbowAttributesKeys(KEY_ANGLE_BRACKETS, settings.numberOfColors) createRainbowAttributesKeys(KEY_ANGLE_BRACKETS, settings.numberOfColors)
}
private val rainbowElement: HighlightInfoType = HighlightInfoType private val rainbowElement: HighlightInfoType = HighlightInfoType
.HighlightInfoTypeImpl(HighlightSeverity.INFORMATION, DefaultLanguageHighlighterColors.CONSTANT) .HighlightInfoTypeImpl(HighlightSeverity.INFORMATION, DefaultLanguageHighlighterColors.CONSTANT)
@ -68,10 +73,10 @@ object RainbowHighlighter {
fun getRainbowAttributesKeys(rainbowName: String): Array<TextAttributesKey> { fun getRainbowAttributesKeys(rainbowName: String): Array<TextAttributesKey> {
return when (rainbowName) { return when (rainbowName) {
NAME_ROUND_BRACKETS -> roundBracketsRainbowColorKeys NAME_ROUND_BRACKETS -> roundBracketsRainbowColorKeys.value
NAME_SQUARE_BRACKETS -> squareBracketsRainbowColorKeys NAME_SQUARE_BRACKETS -> squareBracketsRainbowColorKeys.value
NAME_SQUIGGLY_BRACKETS -> squigglyBracketsRainbowColorKeys NAME_SQUIGGLY_BRACKETS -> squigglyBracketsRainbowColorKeys.value
NAME_ANGLE_BRACKETS -> angleBracketsRainbowColorKeys NAME_ANGLE_BRACKETS -> angleBracketsRainbowColorKeys.value
else -> throw IllegalArgumentException("Unknown rainbow name: $rainbowName") else -> throw IllegalArgumentException("Unknown rainbow name: $rainbowName")
} }
} }
@ -132,7 +137,7 @@ object RainbowHighlighter {
} }
private fun genByOption(option: String, rainbowName: String, level: Int) = private fun genByOption(option: String, rainbowName: String, level: Int) =
com.github.izhangzhihao.rainbow.brackets.util.create( com.chylex.intellij.coloredbrackets.util.create(
"$rainbowName-$level", "$rainbowName-$level",
TextAttributes(randomColor(option), null, null, null, 0) TextAttributes(randomColor(option), null, null, null, 0)
) )
@ -178,7 +183,6 @@ object RainbowHighlighter {
.create() .create()
} }
private val KEY_HTML_CODE: TextAttributesKey by lazy { TextAttributesKey.createTextAttributesKey("HTML_CODE") } private val KEY_HTML_CODE: TextAttributesKey by lazy { TextAttributesKey.createTextAttributesKey("HTML_CODE") }
private val KEY_KOTLIN_LABEL: TextAttributesKey by lazy { TextAttributesKey.createTextAttributesKey("KOTLIN_LABEL") } private val KEY_KOTLIN_LABEL: TextAttributesKey by lazy { TextAttributesKey.createTextAttributesKey("KOTLIN_LABEL") }
private val KEY_MATCHED_BRACE_ATTRIBUTES: TextAttributesKey by lazy { private val KEY_MATCHED_BRACE_ATTRIBUTES: TextAttributesKey by lazy {
@ -188,7 +192,6 @@ object RainbowHighlighter {
TextAttributesKey.createTextAttributesKey("KOTLIN_FUNCTION_LITERAL_BRACES_AND_ARROW") TextAttributesKey.createTextAttributesKey("KOTLIN_FUNCTION_LITERAL_BRACES_AND_ARROW")
} }
fun fixHighlighting(scheme: EditorColorsScheme = EditorColorsManager.getInstance().globalScheme) { fun fixHighlighting(scheme: EditorColorsScheme = EditorColorsManager.getInstance().globalScheme) {
// html code // html code
scheme.setInherited(KEY_HTML_CODE, !settings.isRainbowifyHTMLInsideJS) scheme.setInherited(KEY_HTML_CODE, !settings.isRainbowifyHTMLInsideJS)

View File

@ -1,4 +1,4 @@
package com.github.izhangzhihao.rainbow.brackets package com.chylex.intellij.coloredbrackets
import com.intellij.openapi.util.Key import com.intellij.openapi.util.Key
import com.intellij.psi.PsiElement import com.intellij.psi.PsiElement

View File

@ -1,10 +1,10 @@
package com.github.izhangzhihao.rainbow.brackets package com.chylex.intellij.coloredbrackets
import com.github.izhangzhihao.rainbow.brackets.settings.RainbowConfigurable import com.chylex.intellij.coloredbrackets.settings.RainbowConfigurable
import com.github.izhangzhihao.rainbow.brackets.settings.RainbowSettings import com.chylex.intellij.coloredbrackets.settings.RainbowSettings
import com.github.izhangzhihao.rainbow.brackets.util.memoizedFileExtension import com.chylex.intellij.coloredbrackets.util.memoizedFileExtension
import com.github.izhangzhihao.rainbow.brackets.util.toPsiFile import com.chylex.intellij.coloredbrackets.util.toPsiFile
import com.github.izhangzhihao.rainbow.brackets.visitor.RainbowHighlightVisitor.Companion.checkForBigFile import com.chylex.intellij.coloredbrackets.visitor.RainbowHighlightVisitor.Companion.checkForBigFile
import com.intellij.icons.AllIcons import com.intellij.icons.AllIcons
import com.intellij.ide.actions.ShowSettingsUtilImpl import com.intellij.ide.actions.ShowSettingsUtilImpl
import com.intellij.openapi.fileEditor.FileEditor import com.intellij.openapi.fileEditor.FileEditor
@ -20,19 +20,20 @@ class RainbowifyBanner : EditorNotifications.Provider<EditorNotificationPanel>()
override fun getKey(): Key<EditorNotificationPanel> = KEY override fun getKey(): Key<EditorNotificationPanel> = KEY
override fun createNotificationPanel(file: VirtualFile, fileEditor: FileEditor, project: Project): EditorNotificationPanel? { override fun createNotificationPanel(file: VirtualFile, fileEditor: FileEditor, project: Project): EditorNotificationPanel? {
val settings = RainbowSettings.instance
if (!RainbowSettings.instance.isRainbowEnabled) { if (!settings.isRainbowEnabled) {
if (RainbowSettings.instance.suppressDisabledCheck) return null if (settings.suppressDisabledCheck) return null
return EditorNotificationPanel().apply { return EditorNotificationPanel().apply {
text("Colored Brackets is now disabled") text("Colored Brackets is now disabled")
icon(AllIcons.General.GearPlain) icon(AllIcons.General.GearPlain)
createComponentActionLabel("got it, don't show again") { createComponentActionLabel("got it, don't show again") {
RainbowSettings.instance.suppressDisabledCheck = true settings.suppressDisabledCheck = true
EditorNotifications.getInstance(project).updateAllNotifications() EditorNotifications.getInstance(project).updateAllNotifications()
} }
createComponentActionLabel("enable Colored Brackets") { createComponentActionLabel("enable Colored Brackets") {
RainbowSettings.instance.isRainbowEnabled = true settings.isRainbowEnabled = true
EditorNotifications.getInstance(project).updateAllNotifications() EditorNotifications.getInstance(project).updateAllNotifications()
} }
} }
@ -40,12 +41,12 @@ class RainbowifyBanner : EditorNotifications.Provider<EditorNotificationPanel>()
val psiFile = file.toPsiFile(project) val psiFile = file.toPsiFile(project)
if (psiFile != null && !checkForBigFile(psiFile)) { if (psiFile != null && !checkForBigFile(psiFile)) {
if (RainbowSettings.instance.suppressBigFileCheck) return null if (settings.suppressBigFileCheck) return null
return EditorNotificationPanel().apply { return EditorNotificationPanel().apply {
text("Rainbowify is disabled for files > " + RainbowSettings.instance.bigFilesLinesThreshold + " lines") text("Rainbowify is disabled for files > " + settings.bigFilesLinesThreshold + " lines")
icon(AllIcons.General.InspectionsEye) icon(AllIcons.General.InspectionsEye)
createComponentActionLabel("got it, don't show again") { createComponentActionLabel("got it, don't show again") {
RainbowSettings.instance.suppressBigFileCheck = true settings.suppressBigFileCheck = true
EditorNotifications.getInstance(project).updateAllNotifications() EditorNotifications.getInstance(project).updateAllNotifications()
} }
@ -57,16 +58,16 @@ class RainbowifyBanner : EditorNotifications.Provider<EditorNotificationPanel>()
} }
if ( if (
RainbowSettings.instance.languageBlacklist.contains(file.fileType.name) || settings.languageBlacklist.contains(file.fileType.name) ||
RainbowSettings.instance.languageBlacklist.contains(memoizedFileExtension(file.name)) settings.languageBlacklist.contains(memoizedFileExtension(file.name))
) { ) {
if (RainbowSettings.instance.suppressBlackListCheck) return null if (settings.suppressBlackListCheck) return null
return EditorNotificationPanel().apply { return EditorNotificationPanel().apply {
text("Rainbowify is disabled because the language/file extension is in the black list") text("Rainbowify is disabled because the language/file extension is in the black list")
icon(AllIcons.General.InspectionsEye) icon(AllIcons.General.InspectionsEye)
createComponentActionLabel("got it, don't show again") { createComponentActionLabel("got it, don't show again") {
RainbowSettings.instance.suppressBlackListCheck = true settings.suppressBlackListCheck = true
EditorNotifications.getInstance(project).updateAllNotifications() EditorNotifications.getInstance(project).updateAllNotifications()
} }

View File

@ -1,17 +1,17 @@
package com.github.izhangzhihao.rainbow.brackets package com.chylex.intellij.coloredbrackets
import com.chylex.intellij.coloredbrackets.color.Luminosity
import com.chylex.intellij.coloredbrackets.color.fromString
import com.fasterxml.jackson.databind.ObjectMapper import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import com.fasterxml.jackson.module.kotlin.readValue import com.fasterxml.jackson.module.kotlin.readValue
import com.github.izhangzhihao.rainbow.brackets.color.Luminosity
import com.github.izhangzhihao.rainbow.brackets.color.fromString
import java.awt.Color import java.awt.Color
val mapper: ObjectMapper by lazy { jacksonObjectMapper() } val mapper: ObjectMapper by lazy { jacksonObjectMapper() }
fun randomColor(options: String): Color { fun randomColor(options: String): Color {
val ops: Map<String, String> = mapper.readValue(options) val ops: Map<String, String> = mapper.readValue(options)
return com.github.izhangzhihao.rainbow.brackets.color.randomColor( return com.chylex.intellij.coloredbrackets.color.randomColor(
fromString(ops.getOrDefault("hue", "random")), fromString(ops.getOrDefault("hue", "random")),
Luminosity.valueOf(ops.getOrDefault("luminosity", "random")) Luminosity.valueOf(ops.getOrDefault("luminosity", "random"))
) )

View File

@ -1,7 +1,8 @@
package com.github.izhangzhihao.rainbow.brackets.action package com.chylex.intellij.coloredbrackets.action
import com.github.izhangzhihao.rainbow.brackets.RainbowInfo import com.chylex.intellij.coloredbrackets.RainbowInfo
import com.intellij.codeInsight.highlighting.HighlightManager import com.intellij.codeInsight.highlighting.HighlightManager
import com.intellij.openapi.actionSystem.ActionUpdateThread
import com.intellij.openapi.actionSystem.AnAction import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.AnActionEvent import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.CommonDataKeys import com.intellij.openapi.actionSystem.CommonDataKeys
@ -17,9 +18,12 @@ import java.awt.event.FocusListener
import java.awt.event.KeyAdapter import java.awt.event.KeyAdapter
import java.awt.event.KeyEvent import java.awt.event.KeyEvent
abstract class AbstractScopeHighlightingAction : AnAction() { abstract class AbstractScopeHighlightingAction : AnAction() {
final override fun getActionUpdateThread(): ActionUpdateThread {
return ActionUpdateThread.BGT
}
final override fun update(e: AnActionEvent) { final override fun update(e: AnActionEvent) {
e.presentation.isEnabledAndVisible = e.editor.let { it != null && it !is TextComponentEditor } e.presentation.isEnabledAndVisible = e.editor.let { it != null && it !is TextComponentEditor }
} }

View File

@ -1,8 +1,8 @@
package com.github.izhangzhihao.rainbow.brackets.action package com.chylex.intellij.coloredbrackets.action
import com.github.izhangzhihao.rainbow.brackets.RainbowInfo import com.chylex.intellij.coloredbrackets.RainbowInfo
import com.github.izhangzhihao.rainbow.brackets.settings.RainbowSettings import com.chylex.intellij.coloredbrackets.settings.RainbowSettings
import com.github.izhangzhihao.rainbow.brackets.util.alphaBlend import com.chylex.intellij.coloredbrackets.util.alphaBlend
import com.intellij.codeInsight.highlighting.HighlightManager import com.intellij.codeInsight.highlighting.HighlightManager
import com.intellij.openapi.editor.Editor import com.intellij.openapi.editor.Editor
import com.intellij.openapi.editor.colors.EditorColorsManager import com.intellij.openapi.editor.colors.EditorColorsManager
@ -12,7 +12,6 @@ import com.intellij.openapi.editor.markup.TextAttributes
import java.awt.Font import java.awt.Font
import java.util.LinkedList import java.util.LinkedList
class ScopeHighlightingAction : AbstractScopeHighlightingAction() { class ScopeHighlightingAction : AbstractScopeHighlightingAction() {
override fun Editor.addHighlighter( override fun Editor.addHighlighter(

View File

@ -1,8 +1,8 @@
package com.github.izhangzhihao.rainbow.brackets.action package com.chylex.intellij.coloredbrackets.action
import com.github.izhangzhihao.rainbow.brackets.RainbowInfo import com.chylex.intellij.coloredbrackets.RainbowInfo
import com.github.izhangzhihao.rainbow.brackets.settings.RainbowSettings import com.chylex.intellij.coloredbrackets.settings.RainbowSettings
import com.github.izhangzhihao.rainbow.brackets.util.alphaBlend import com.chylex.intellij.coloredbrackets.util.alphaBlend
import com.intellij.codeInsight.highlighting.HighlightManager import com.intellij.codeInsight.highlighting.HighlightManager
import com.intellij.openapi.editor.Editor import com.intellij.openapi.editor.Editor
import com.intellij.openapi.editor.colors.EditorColorsManager import com.intellij.openapi.editor.colors.EditorColorsManager
@ -26,6 +26,8 @@ class ScopeOutsideHighlightingRestrainAction : AbstractScopeHighlightingAction()
val highlighters = LinkedList<RangeHighlighter>() val highlighters = LinkedList<RangeHighlighter>()
val startOffset = rainbowInfo.startOffset val startOffset = rainbowInfo.startOffset
val hideByAnyKey = RainbowSettings.instance.pressAnyKeyToRemoveTheHighlightingEffects
if (startOffset > 0) { if (startOffset > 0) {
highlightManager.addRangeHighlight( highlightManager.addRangeHighlight(
this, this,
@ -33,7 +35,7 @@ class ScopeOutsideHighlightingRestrainAction : AbstractScopeHighlightingAction()
startOffset, startOffset,
attributes, //create("ScopeOutsideHighlightingRestrainAction", attributes), attributes, //create("ScopeOutsideHighlightingRestrainAction", attributes),
false, //hideByTextChange false, //hideByTextChange
RainbowSettings.instance.pressAnyKeyToRemoveTheHighlightingEffects, //hideByAnyKey hideByAnyKey, //hideByAnyKey
highlighters highlighters
) )
} }
@ -47,7 +49,7 @@ class ScopeOutsideHighlightingRestrainAction : AbstractScopeHighlightingAction()
lastOffset, lastOffset,
attributes, //create("ScopeOutsideHighlightingRestrainAction", attributes), attributes, //create("ScopeOutsideHighlightingRestrainAction", attributes),
false, //hideByTextChange false, //hideByTextChange
RainbowSettings.instance.pressAnyKeyToRemoveTheHighlightingEffects, //hideByAnyKey hideByAnyKey, //hideByAnyKey
highlighters highlighters
) )
} }

View File

@ -1,8 +1,8 @@
package com.github.izhangzhihao.rainbow.brackets.annotator package com.chylex.intellij.coloredbrackets.annotator
import com.github.izhangzhihao.rainbow.brackets.RainbowHighlighter import com.chylex.intellij.coloredbrackets.RainbowHighlighter
import com.github.izhangzhihao.rainbow.brackets.RainbowInfo import com.chylex.intellij.coloredbrackets.RainbowInfo
import com.github.izhangzhihao.rainbow.brackets.settings.RainbowSettings import com.chylex.intellij.coloredbrackets.settings.RainbowSettings
import com.intellij.lang.annotation.AnnotationHolder import com.intellij.lang.annotation.AnnotationHolder
import com.intellij.lang.annotation.Annotator import com.intellij.lang.annotation.Annotator
import com.intellij.lang.annotation.HighlightSeverity import com.intellij.lang.annotation.HighlightSeverity
@ -23,7 +23,6 @@ import org.jetbrains.kotlin.psi.KtLabeledExpression
import org.jetbrains.kotlin.psi.KtLambdaExpression import org.jetbrains.kotlin.psi.KtLambdaExpression
import java.awt.Font import java.awt.Font
class KotlinLabelAnnotator : Annotator { class KotlinLabelAnnotator : Annotator {
override fun annotate(element: PsiElement, holder: AnnotationHolder) { override fun annotate(element: PsiElement, holder: AnnotationHolder) {
if (!RainbowSettings.instance.isRainbowifyKotlinLabel) { if (!RainbowSettings.instance.isRainbowifyKotlinLabel) {
@ -48,13 +47,13 @@ class KotlinLabelAnnotator : Annotator {
refElement = when (refElement) { refElement = when (refElement) {
is KtBlockExpression, is KtBlockExpression,
is KtFunctionLiteral, is KtFunctionLiteral,
-> refElement -> refElement
is KtFunction -> refElement.lastChild.takeIf { it is KtBlockExpression } is KtFunction -> refElement.lastChild.takeIf { it is KtBlockExpression }
is KtClass -> refElement.lastChild.takeIf { it is KtClassBody } is KtClass -> refElement.lastChild.takeIf { it is KtClassBody }
is KtCallExpression, is KtCallExpression,
is KtLambdaExpression, is KtLambdaExpression,
-> PsiTreeUtil.findChildOfType(refElement, KtFunctionLiteral::class.java) -> PsiTreeUtil.findChildOfType(refElement, KtFunctionLiteral::class.java)
else -> null else -> null
} }
@ -66,11 +65,11 @@ class KotlinLabelAnnotator : Annotator {
when (it) { when (it) {
is KtBlockExpression, is KtBlockExpression,
is KtFunctionLiteral, is KtFunctionLiteral,
-> it -> it
is KtCallExpression, is KtCallExpression,
is KtLambdaExpression, is KtLambdaExpression,
-> PsiTreeUtil.findChildOfType(it, KtFunctionLiteral::class.java) -> PsiTreeUtil.findChildOfType(it, KtFunctionLiteral::class.java)
else -> null else -> null
} }
@ -86,7 +85,7 @@ class KotlinLabelAnnotator : Annotator {
holder.newSilentAnnotation(HighlightSeverity.INFORMATION) holder.newSilentAnnotation(HighlightSeverity.INFORMATION)
.range(target) .range(target)
.textAttributes( .textAttributes(
com.github.izhangzhihao.rainbow.brackets.util.create( com.chylex.intellij.coloredbrackets.util.create(
"rainbow-kotlin-label", "rainbow-kotlin-label",
TextAttributes(it, null, null, EffectType.BOXED, Font.PLAIN) TextAttributes(it, null, null, EffectType.BOXED, Font.PLAIN)
) )

View File

@ -1,6 +1,6 @@
package com.github.izhangzhihao.rainbow.brackets.annotator package com.chylex.intellij.coloredbrackets.annotator
import com.github.izhangzhihao.rainbow.brackets.RainbowInfo import com.chylex.intellij.coloredbrackets.RainbowInfo
import com.intellij.lang.annotation.AnnotationHolder import com.intellij.lang.annotation.AnnotationHolder
import com.intellij.lang.annotation.Annotator import com.intellij.lang.annotation.Annotator
import com.intellij.lang.annotation.HighlightSeverity import com.intellij.lang.annotation.HighlightSeverity
@ -11,7 +11,6 @@ import com.intellij.psi.impl.source.tree.LeafPsiElement
import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.lexer.KtTokens
import java.awt.Font import java.awt.Font
class KotlinLambdaExpressionArrowAnnotator : Annotator { class KotlinLambdaExpressionArrowAnnotator : Annotator {
override fun annotate(element: PsiElement, holder: AnnotationHolder) { override fun annotate(element: PsiElement, holder: AnnotationHolder) {
if ((element as? LeafPsiElement)?.elementType == KtTokens.ARROW) { if ((element as? LeafPsiElement)?.elementType == KtTokens.ARROW) {
@ -19,7 +18,7 @@ class KotlinLambdaExpressionArrowAnnotator : Annotator {
holder.newSilentAnnotation(HighlightSeverity.INFORMATION) holder.newSilentAnnotation(HighlightSeverity.INFORMATION)
.range(element) .range(element)
.textAttributes( .textAttributes(
com.github.izhangzhihao.rainbow.brackets.util.create( com.chylex.intellij.coloredbrackets.util.create(
"rainbow-kotlin-arrow", "rainbow-kotlin-arrow",
TextAttributes(it, null, null, EffectType.BOXED, Font.PLAIN) TextAttributes(it, null, null, EffectType.BOXED, Font.PLAIN)
) )

View File

@ -1,13 +1,13 @@
package com.github.izhangzhihao.rainbow.brackets.annotator package com.chylex.intellij.coloredbrackets.annotator
import com.github.izhangzhihao.rainbow.brackets.RainbowHighlighter.NAME_ANGLE_BRACKETS import com.chylex.intellij.coloredbrackets.RainbowHighlighter.NAME_ANGLE_BRACKETS
import com.github.izhangzhihao.rainbow.brackets.RainbowHighlighter.NAME_ROUND_BRACKETS import com.chylex.intellij.coloredbrackets.RainbowHighlighter.NAME_ROUND_BRACKETS
import com.github.izhangzhihao.rainbow.brackets.RainbowHighlighter.NAME_SQUARE_BRACKETS import com.chylex.intellij.coloredbrackets.RainbowHighlighter.NAME_SQUARE_BRACKETS
import com.github.izhangzhihao.rainbow.brackets.RainbowHighlighter.NAME_SQUIGGLY_BRACKETS import com.chylex.intellij.coloredbrackets.RainbowHighlighter.NAME_SQUIGGLY_BRACKETS
import com.github.izhangzhihao.rainbow.brackets.RainbowHighlighter.getRainbowColorByLevel import com.chylex.intellij.coloredbrackets.RainbowHighlighter.getRainbowColorByLevel
import com.github.izhangzhihao.rainbow.brackets.annotator.RainbowUtils.annotateUtil import com.chylex.intellij.coloredbrackets.annotator.RainbowUtils.annotateUtil
import com.github.izhangzhihao.rainbow.brackets.annotator.RainbowUtils.settings import com.chylex.intellij.coloredbrackets.annotator.RainbowUtils.settings
import com.github.izhangzhihao.rainbow.brackets.settings.RainbowSettings import com.chylex.intellij.coloredbrackets.settings.RainbowSettings
import com.intellij.lang.annotation.AnnotationHolder import com.intellij.lang.annotation.AnnotationHolder
import com.intellij.lang.annotation.Annotator import com.intellij.lang.annotation.Annotator
import com.intellij.lang.annotation.HighlightSeverity import com.intellij.lang.annotation.HighlightSeverity
@ -18,6 +18,7 @@ import com.intellij.psi.impl.source.tree.LeafPsiElement
class RainbowAnnotator : Annotator { class RainbowAnnotator : Annotator {
override fun annotate(element: PsiElement, holder: AnnotationHolder) { override fun annotate(element: PsiElement, holder: AnnotationHolder) {
val settings = settings
if (settings.isRainbowEnabled && element is LeafPsiElement) { if (settings.isRainbowEnabled && element is LeafPsiElement) {
if (!settings.applyColorsOfRoundForAllBrackets) { if (!settings.applyColorsOfRoundForAllBrackets) {
if (settings.isEnableRainbowRoundBrackets) annotateUtil(element, holder, "(", ")", NAME_ROUND_BRACKETS) if (settings.isEnableRainbowRoundBrackets) annotateUtil(element, holder, "(", ")", NAME_ROUND_BRACKETS)
@ -35,13 +36,13 @@ class RainbowAnnotator : Annotator {
} }
} }
object RainbowUtils { object RainbowUtils {
private val leftBracketsSet = setOf("(", "[", "{", "<") private val leftBracketsSet = setOf("(", "[", "{", "<")
private val rightBracketsSet = setOf(")", "]", "}", ">") private val rightBracketsSet = setOf(")", "]", "}", ">")
val settings = RainbowSettings.instance val settings
get() = RainbowSettings.instance
private tailrec fun iterateChildren( private tailrec fun iterateChildren(
LEFT: String, LEFT: String,

View File

@ -1,4 +1,4 @@
package com.github.izhangzhihao.rainbow.brackets.color package com.chylex.intellij.coloredbrackets.color
import kotlin.math.floor import kotlin.math.floor

View File

@ -1,5 +1,4 @@
package com.github.izhangzhihao.rainbow.brackets.color package com.chylex.intellij.coloredbrackets.color
sealed class Hue sealed class Hue
object RandomHue : Hue() object RandomHue : Hue()

View File

@ -1,4 +1,4 @@
package com.github.izhangzhihao.rainbow.brackets.color package com.chylex.intellij.coloredbrackets.color
enum class Luminosity { enum class Luminosity {
random, random,

View File

@ -1,9 +1,8 @@
package com.github.izhangzhihao.rainbow.brackets.color package com.chylex.intellij.coloredbrackets.color
import kotlin.math.floor import kotlin.math.floor
import kotlin.random.Random import kotlin.random.Random
/** /**
* Generate a single random color with specified (or random) hue and luminosity. * Generate a single random color with specified (or random) hue and luminosity.
*/ */
@ -72,7 +71,6 @@ private fun toColor(hueValue: Int, saturation: Int, brightness: Int): java.awt.C
return java.awt.Color(rgb.first, rgb.second, rgb.third) return java.awt.Color(rgb.first, rgb.second, rgb.third)
} }
private fun HSVtoRGB(hueValue: Int, saturation: Int, brightness: Int): Triple<Int, Int, Int> { private fun HSVtoRGB(hueValue: Int, saturation: Int, brightness: Int): Triple<Int, Int, Int> {
// This doesn't work for the values of 0 and 360 // This doesn't work for the values of 0 and 360
// Here's the hacky fix // Here's the hacky fix

View File

@ -1,12 +1,12 @@
package com.github.izhangzhihao.rainbow.brackets.indents package com.chylex.intellij.coloredbrackets.indents
import com.github.izhangzhihao.rainbow.brackets.RainbowInfo import com.chylex.intellij.coloredbrackets.RainbowInfo
import com.github.izhangzhihao.rainbow.brackets.util.alphaBlend import com.chylex.intellij.coloredbrackets.util.alphaBlend
import com.github.izhangzhihao.rainbow.brackets.util.endOffset import com.chylex.intellij.coloredbrackets.util.endOffset
import com.github.izhangzhihao.rainbow.brackets.util.findNextSibling import com.chylex.intellij.coloredbrackets.util.findNextSibling
import com.github.izhangzhihao.rainbow.brackets.util.findPrevSibling import com.chylex.intellij.coloredbrackets.util.findPrevSibling
import com.github.izhangzhihao.rainbow.brackets.util.lineNumber import com.chylex.intellij.coloredbrackets.util.lineNumber
import com.github.izhangzhihao.rainbow.brackets.util.startOffset import com.chylex.intellij.coloredbrackets.util.startOffset
import com.intellij.openapi.editor.Document import com.intellij.openapi.editor.Document
import com.intellij.openapi.editor.Editor import com.intellij.openapi.editor.Editor
import com.intellij.openapi.editor.SoftWrap import com.intellij.openapi.editor.SoftWrap

View File

@ -1,11 +1,10 @@
package com.github.izhangzhihao.rainbow.brackets.indents package com.chylex.intellij.coloredbrackets.indents
import com.github.izhangzhihao.rainbow.brackets.settings.RainbowSettings import com.chylex.intellij.coloredbrackets.settings.RainbowSettings
import com.intellij.codeHighlighting.TextEditorHighlightingPass import com.intellij.codeHighlighting.TextEditorHighlightingPass
import com.intellij.codeInsight.highlighting.BraceMatchingUtil import com.intellij.codeInsight.highlighting.BraceMatchingUtil
import com.intellij.codeInsight.highlighting.CodeBlockSupportHandler import com.intellij.codeInsight.highlighting.CodeBlockSupportHandler
import com.intellij.ide.actions.ToggleZenModeAction import com.intellij.ide.actions.ToggleZenModeAction
import com.intellij.lang.Language
import com.intellij.lang.LanguageParserDefinitions import com.intellij.lang.LanguageParserDefinitions
import com.intellij.openapi.editor.Editor import com.intellij.openapi.editor.Editor
import com.intellij.openapi.editor.IndentGuideDescriptor import com.intellij.openapi.editor.IndentGuideDescriptor
@ -231,7 +230,7 @@ class RainbowIndentsPass internal constructor(
*/ */
private inner class IndentsCalculator { private inner class IndentsCalculator {
val myComments: MutableMap<Language, TokenSet> = HashMap() val myComments: MutableMap<String, TokenSet> = HashMap()
val lineIndents = IntArray(document.lineCount) // negative value means the line is empty (or contains a comment) and indent val lineIndents = IntArray(document.lineCount) // negative value means the line is empty (or contains a comment) and indent
// (denoted by absolute value) was deduced from enclosing non-empty lines // (denoted by absolute value) was deduced from enclosing non-empty lines
@ -317,7 +316,7 @@ class RainbowIndentsPass internal constructor(
return false return false
} }
val language = tokenType.language val language = tokenType.language
var comments: TokenSet? = myComments[language] var comments: TokenSet? = myComments[language.id]
if (comments == null) { if (comments == null) {
val definition = LanguageParserDefinitions.INSTANCE.forLanguage(language) val definition = LanguageParserDefinitions.INSTANCE.forLanguage(language)
if (definition != null) { if (definition != null) {
@ -327,7 +326,7 @@ class RainbowIndentsPass internal constructor(
return false return false
} }
else { else {
myComments[language] = comments myComments[language.id] = comments
} }
} }
return comments.contains(tokenType) return comments.contains(tokenType)

View File

@ -1,4 +1,4 @@
package com.github.izhangzhihao.rainbow.brackets.indents package com.chylex.intellij.coloredbrackets.indents
import com.intellij.codeHighlighting.Pass import com.intellij.codeHighlighting.Pass
import com.intellij.codeHighlighting.TextEditorHighlightingPass import com.intellij.codeHighlighting.TextEditorHighlightingPass

View File

@ -1,6 +1,6 @@
package com.github.izhangzhihao.rainbow.brackets.listener package com.chylex.intellij.coloredbrackets.listener
import com.github.izhangzhihao.rainbow.brackets.RainbowHighlighter import com.chylex.intellij.coloredbrackets.RainbowHighlighter
import com.intellij.openapi.editor.colors.EditorColorsListener import com.intellij.openapi.editor.colors.EditorColorsListener
import com.intellij.openapi.editor.colors.EditorColorsScheme import com.intellij.openapi.editor.colors.EditorColorsScheme

View File

@ -1,4 +1,4 @@
package com.github.izhangzhihao.rainbow.brackets.provider package com.chylex.intellij.coloredbrackets.provider
import com.intellij.lang.BracePair import com.intellij.lang.BracePair

View File

@ -1,4 +1,4 @@
package com.github.izhangzhihao.rainbow.brackets.provider package com.chylex.intellij.coloredbrackets.provider
import com.intellij.lang.BracePair import com.intellij.lang.BracePair
import com.jetbrains.lang.dart.DartTokenTypes.GT import com.jetbrains.lang.dart.DartTokenTypes.GT

View File

@ -1,4 +1,4 @@
package com.github.izhangzhihao.rainbow.brackets.provider package com.chylex.intellij.coloredbrackets.provider
import com.goide.template.GoTemplateTypes.LDOUBLE_BRACE import com.goide.template.GoTemplateTypes.LDOUBLE_BRACE
import com.goide.template.GoTemplateTypes.LPAREN import com.goide.template.GoTemplateTypes.LPAREN

View File

@ -1,4 +1,4 @@
package com.github.izhangzhihao.rainbow.brackets.provider package com.chylex.intellij.coloredbrackets.provider
import com.intellij.lang.BracePair import com.intellij.lang.BracePair
import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.mGT import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.mGT

View File

@ -1,10 +1,9 @@
package com.github.izhangzhihao.rainbow.brackets.provider package com.chylex.intellij.coloredbrackets.provider
import com.intellij.lang.BracePair import com.intellij.lang.BracePair
import org.jetbrains.kotlin.lexer.KtTokens.GT import org.jetbrains.kotlin.lexer.KtTokens.GT
import org.jetbrains.kotlin.lexer.KtTokens.LT import org.jetbrains.kotlin.lexer.KtTokens.LT
class KotlinBracePairProvider : BracePairProvider { class KotlinBracePairProvider : BracePairProvider {
override fun pairs(): List<BracePair> = listOf(BracePair(LT, GT, false)) override fun pairs(): List<BracePair> = listOf(BracePair(LT, GT, false))
} }

View File

@ -1,4 +1,4 @@
package com.github.izhangzhihao.rainbow.brackets.provider package com.chylex.intellij.coloredbrackets.provider
import com.intellij.lang.BracePair import com.intellij.lang.BracePair
import com.jetbrains.php.lang.lexer.PhpTokenTypes import com.jetbrains.php.lang.lexer.PhpTokenTypes

View File

@ -1,4 +1,4 @@
package com.github.izhangzhihao.rainbow.brackets.provider package com.chylex.intellij.coloredbrackets.provider
import com.intellij.lang.BracePair import com.intellij.lang.BracePair
import com.intellij.sh.ShTypes import com.intellij.sh.ShTypes

View File

@ -1,4 +1,4 @@
package com.github.izhangzhihao.rainbow.brackets.provider package com.chylex.intellij.coloredbrackets.provider
import com.intellij.lang.BracePair import com.intellij.lang.BracePair
import com.intellij.sql.psi.SqlCommonKeywords.SQL_CASE import com.intellij.sql.psi.SqlCommonKeywords.SQL_CASE

View File

@ -1,4 +1,4 @@
package com.github.izhangzhihao.rainbow.brackets.provider package com.chylex.intellij.coloredbrackets.provider
import com.intellij.lang.BracePair import com.intellij.lang.BracePair
import com.intellij.lang.javascript.JSTokenTypes.GT import com.intellij.lang.javascript.JSTokenTypes.GT

View File

@ -1,7 +1,7 @@
package com.github.izhangzhihao.rainbow.brackets.settings package com.chylex.intellij.coloredbrackets.settings
import com.github.izhangzhihao.rainbow.brackets.RainbowHighlighter import com.chylex.intellij.coloredbrackets.RainbowHighlighter
import com.github.izhangzhihao.rainbow.brackets.settings.form.RainbowOptionsPanel import com.chylex.intellij.coloredbrackets.settings.form.RainbowOptionsPanel
import com.intellij.application.options.colors.ColorAndFontOptions import com.intellij.application.options.colors.ColorAndFontOptions
import com.intellij.application.options.colors.ColorAndFontPanelFactory import com.intellij.application.options.colors.ColorAndFontPanelFactory
import com.intellij.application.options.colors.ColorAndFontSettingsListener import com.intellij.application.options.colors.ColorAndFontSettingsListener
@ -14,7 +14,6 @@ import com.intellij.openapi.options.colors.ColorDescriptor
import com.intellij.psi.codeStyle.DisplayPriority import com.intellij.psi.codeStyle.DisplayPriority
import com.intellij.psi.codeStyle.DisplayPrioritySortable import com.intellij.psi.codeStyle.DisplayPrioritySortable
class RainbowColorsPageFactory : ColorAndFontPanelFactory, ColorAndFontDescriptorsProvider, DisplayPrioritySortable { class RainbowColorsPageFactory : ColorAndFontPanelFactory, ColorAndFontDescriptorsProvider, DisplayPrioritySortable {
override fun getDisplayName(): String = RAINBOW_BRACKETS_GROUP override fun getDisplayName(): String = RAINBOW_BRACKETS_GROUP

View File

@ -1,6 +1,6 @@
package com.github.izhangzhihao.rainbow.brackets.settings package com.chylex.intellij.coloredbrackets.settings
import com.github.izhangzhihao.rainbow.brackets.settings.form.RainbowSettingsForm import com.chylex.intellij.coloredbrackets.settings.form.RainbowSettingsForm
import com.intellij.openapi.options.ConfigurationException import com.intellij.openapi.options.ConfigurationException
import com.intellij.openapi.options.SearchableConfigurable import com.intellij.openapi.options.SearchableConfigurable
import org.jetbrains.annotations.Nls import org.jetbrains.annotations.Nls
@ -61,6 +61,6 @@ class RainbowConfigurable : SearchableConfigurable {
override fun getId(): String = ID override fun getId(): String = ID
companion object { companion object {
const val ID = "preferences.rainbow.brackets" const val ID = "com.chylex.coloredbrackets.settings"
} }
} }

View File

@ -1,4 +1,4 @@
package com.github.izhangzhihao.rainbow.brackets.settings package com.chylex.intellij.coloredbrackets.settings
import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.components.PersistentStateComponent import com.intellij.openapi.components.PersistentStateComponent
@ -7,8 +7,7 @@ import com.intellij.openapi.components.Storage
import com.intellij.util.xmlb.XmlSerializerUtil.copyBean import com.intellij.util.xmlb.XmlSerializerUtil.copyBean
import org.jetbrains.annotations.Nullable import org.jetbrains.annotations.Nullable
@State(name = "ColoredBracketsSettings", storages = [Storage("colored_brackets.xml")])
@State(name = "RainbowSettings", storages = [(Storage("rainbow_brackets.xml"))])
class RainbowSettings : PersistentStateComponent<RainbowSettings> { class RainbowSettings : PersistentStateComponent<RainbowSettings> {
/** /**
* default value * default value

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.github.izhangzhihao.rainbow.brackets.settings.form.RainbowOptionsPanel"> <form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.chylex.intellij.coloredbrackets.settings.form.RainbowOptionsPanel">
<grid id="d747" binding="rootPanel" layout-manager="BorderLayout" hgap="0" vgap="0"> <grid id="d747" binding="rootPanel" layout-manager="BorderLayout" hgap="0" vgap="0">
<constraints> <constraints>
<xy x="20" y="20" width="500" height="400"/> <xy x="20" y="20" width="500" height="400"/>

View File

@ -1,7 +1,7 @@
package com.github.izhangzhihao.rainbow.brackets.settings.form package com.chylex.intellij.coloredbrackets.settings.form
import com.github.izhangzhihao.rainbow.brackets.RainbowHighlighter import com.chylex.intellij.coloredbrackets.RainbowHighlighter
import com.github.izhangzhihao.rainbow.brackets.settings.RainbowSettings import com.chylex.intellij.coloredbrackets.settings.RainbowSettings
import com.intellij.application.options.colors.ColorAndFontOptions import com.intellij.application.options.colors.ColorAndFontOptions
import com.intellij.application.options.colors.ColorAndFontSettingsListener import com.intellij.application.options.colors.ColorAndFontSettingsListener
import com.intellij.application.options.colors.OptionsPanel import com.intellij.application.options.colors.OptionsPanel
@ -22,7 +22,6 @@ import javax.swing.tree.DefaultTreeModel
import javax.swing.tree.TreePath import javax.swing.tree.TreePath
import javax.swing.tree.TreeSelectionModel import javax.swing.tree.TreeSelectionModel
class RainbowOptionsPanel( class RainbowOptionsPanel(
private val options: ColorAndFontOptions, private val options: ColorAndFontOptions,
private val schemesProvider: SchemesPanel, private val schemesProvider: SchemesPanel,
@ -172,7 +171,6 @@ class RainbowOptionsPanel(
} }
} }
override fun applyChangesToScheme() { override fun applyChangesToScheme() {
val scheme = options.selectedScheme val scheme = options.selectedScheme
val (rainbowName, descriptions) = optionsTree.selectedDescriptions ?: return val (rainbowName, descriptions) = optionsTree.selectedDescriptions ?: return

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.github.izhangzhihao.rainbow.brackets.settings.form.RainbowSettingsForm"> <form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.chylex.intellij.coloredbrackets.settings.form.RainbowSettingsForm">
<grid id="27dc6" binding="panel" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> <grid id="27dc6" binding="panel" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/> <margin top="0" left="0" bottom="0" right="0"/>
<constraints> <constraints>

View File

@ -1,6 +1,6 @@
package com.github.izhangzhihao.rainbow.brackets.settings.form package com.chylex.intellij.coloredbrackets.settings.form
import com.github.izhangzhihao.rainbow.brackets.settings.RainbowSettings import com.chylex.intellij.coloredbrackets.settings.RainbowSettings
import javax.swing.JCheckBox import javax.swing.JCheckBox
import javax.swing.JComponent import javax.swing.JComponent
import javax.swing.JPanel import javax.swing.JPanel
@ -8,6 +8,7 @@ import javax.swing.JTextField
class RainbowSettingsForm { class RainbowSettingsForm {
private var panel: JPanel? = null private var panel: JPanel? = null
@Suppress("unused") @Suppress("unused")
private var appearancePanel: JPanel? = null private var appearancePanel: JPanel? = null
private var enableRainbow: JCheckBox? = null private var enableRainbow: JCheckBox? = null

View File

@ -1,8 +1,7 @@
package com.github.izhangzhihao.rainbow.brackets.util package com.chylex.intellij.coloredbrackets.util
import java.awt.Color import java.awt.Color
fun Color.alphaBlend(background: Color, alpha: Float): Color { fun Color.alphaBlend(background: Color, alpha: Float): Color {
require(alpha in 0.0..1.0) { "alpha(0.0 <= alpha <= 1.0): $alpha" } require(alpha in 0.0..1.0) { "alpha(0.0 <= alpha <= 1.0): $alpha" }

View File

@ -1,4 +1,4 @@
package com.github.izhangzhihao.rainbow.brackets.util package com.chylex.intellij.coloredbrackets.util
import com.intellij.openapi.editor.Document import com.intellij.openapi.editor.Document

View File

@ -1,4 +1,4 @@
package com.github.izhangzhihao.rainbow.brackets.util package com.chylex.intellij.coloredbrackets.util
import java.util.concurrent.ConcurrentHashMap import java.util.concurrent.ConcurrentHashMap
@ -17,7 +17,6 @@ fun <A, B, C, R> ((A, B, C) -> R).memoize(): (A, B, C) -> R = object : (A, B, C)
override fun invoke(a: A, b: B, c: C) = m(MemoizeKey3(a, b, c)) override fun invoke(a: A, b: B, c: C) = m(MemoizeKey3(a, b, c))
} }
private interface MemoizedCall<in F, out R> { private interface MemoizedCall<in F, out R> {
operator fun invoke(f: F): R operator fun invoke(f: F): R
} }

View File

@ -1,4 +1,4 @@
package com.github.izhangzhihao.rainbow.brackets.util package com.chylex.intellij.coloredbrackets.util
import com.intellij.openapi.project.Project import com.intellij.openapi.project.Project
import com.intellij.openapi.vfs.VirtualFile import com.intellij.openapi.vfs.VirtualFile

View File

@ -1,4 +1,4 @@
package com.github.izhangzhihao.rainbow.brackets.util package com.chylex.intellij.coloredbrackets.util
import com.intellij.psi.PsiElement import com.intellij.psi.PsiElement

View File

@ -1,5 +1,4 @@
package com.github.izhangzhihao.rainbow.brackets.util package com.chylex.intellij.coloredbrackets.util
fun fileExtension(fileName: String) = fileName.substring(fileName.lastIndexOf(".") + 1) fun fileExtension(fileName: String) = fileName.substring(fileName.lastIndexOf(".") + 1)

View File

@ -1,4 +1,4 @@
package com.github.izhangzhihao.rainbow.brackets.util package com.chylex.intellij.coloredbrackets.util
import com.intellij.openapi.editor.colors.TextAttributesKey import com.intellij.openapi.editor.colors.TextAttributesKey
import com.intellij.openapi.editor.markup.TextAttributes import com.intellij.openapi.editor.markup.TextAttributes

View File

@ -1,8 +1,8 @@
package com.github.izhangzhihao.rainbow.brackets.visitor package com.chylex.intellij.coloredbrackets.visitor
import com.github.izhangzhihao.rainbow.brackets.bracePairs import com.chylex.intellij.coloredbrackets.bracePairs
import com.github.izhangzhihao.rainbow.brackets.braceTypeSet import com.chylex.intellij.coloredbrackets.braceTypeSet
import com.github.izhangzhihao.rainbow.brackets.settings.RainbowSettings import com.chylex.intellij.coloredbrackets.settings.RainbowSettings
import com.intellij.codeInsight.daemon.impl.HighlightVisitor import com.intellij.codeInsight.daemon.impl.HighlightVisitor
import com.intellij.lang.BracePair import com.intellij.lang.BracePair
import com.intellij.psi.PsiElement import com.intellij.psi.PsiElement
@ -10,25 +10,27 @@ import com.intellij.psi.PsiFile
import com.intellij.psi.impl.source.tree.LeafPsiElement import com.intellij.psi.impl.source.tree.LeafPsiElement
import com.intellij.psi.tree.IElementType import com.intellij.psi.tree.IElementType
class DefaultRainbowVisitor : RainbowHighlightVisitor() { class DefaultRainbowVisitor : RainbowHighlightVisitor() {
override fun clone(): HighlightVisitor = DefaultRainbowVisitor() override fun clone(): HighlightVisitor = DefaultRainbowVisitor()
override fun visit(element: PsiElement) { override fun visit(element: PsiElement) {
val type = (element as? LeafPsiElement)?.elementType ?: return val type = (element as? LeafPsiElement)?.elementType ?: return
val matching = filterPairs(type, element) ?: return
val settings = RainbowSettings.instance
val processor = Processor(settings)
val matching = processor.filterPairs(type, element) ?: return
val pair = val pair =
if (matching.size == 1) { if (matching.size == 1) {
matching[0] matching[0]
} }
else { else {
matching.find { element.isValidBracket(it) } matching.find { processor.isValidBracket(element, it) }
} ?: return } ?: return
val level = element.getBracketLevel(pair) val level = processor.getBracketLevel(element, pair)
if (RainbowSettings.instance.isDoNOTRainbowifyTheFirstLevel) { if (settings.isDoNOTRainbowifyTheFirstLevel) {
if (level >= 1) { if (level >= 1) {
rainbowPairs(element, pair, level) rainbowPairs(element, pair, level)
} }
@ -46,9 +48,9 @@ class DefaultRainbowVisitor : RainbowHighlightVisitor() {
element.setHighlightInfo(element.parent, level, startElement, endElement) element.setHighlightInfo(element.parent, level, startElement, endElement)
} }
companion object { private class Processor(private val settings: RainbowSettings) {
private fun LeafPsiElement.getBracketLevel(pair: BracePair): Int = iterateBracketParents(parent, pair, -1) fun getBracketLevel(element: LeafPsiElement, pair: BracePair): Int = iterateBracketParents(element.parent, pair, -1)
private tailrec fun iterateBracketParents(element: PsiElement?, pair: BracePair, count: Int): Int { private tailrec fun iterateBracketParents(element: PsiElement?, pair: BracePair, count: Int): Int {
if (element == null || element is PsiFile) { if (element == null || element is PsiFile) {
@ -56,7 +58,7 @@ class DefaultRainbowVisitor : RainbowHighlightVisitor() {
} }
var nextCount = count var nextCount = count
if (!RainbowSettings.instance.cycleCountOnAllBrackets) { if (!settings.cycleCountOnAllBrackets) {
if (element.haveBrackets( if (element.haveBrackets(
{ it.elementType() == pair.leftBraceType }, { it.elementType() == pair.leftBraceType },
{ it.elementType() == pair.rightBraceType }) { it.elementType() == pair.rightBraceType })
@ -110,7 +112,7 @@ class DefaultRainbowVisitor : RainbowHighlightVisitor() {
} }
//For https://github.com/izhangzhihao/intellij-rainbow-brackets/issues/830 //For https://github.com/izhangzhihao/intellij-rainbow-brackets/issues/830
if (RainbowSettings.instance.doNOTRainbowifyTemplateString) { if (settings.doNOTRainbowifyTemplateString) {
if (left?.prevSibling?.textMatches("$") == true) return false if (left?.prevSibling?.textMatches("$") == true) return false
} }
@ -121,18 +123,18 @@ class DefaultRainbowVisitor : RainbowHighlightVisitor() {
return (this as? LeafPsiElement)?.elementType return (this as? LeafPsiElement)?.elementType
} }
private fun LeafPsiElement.isValidBracket(pair: BracePair): Boolean { fun isValidBracket(element: LeafPsiElement, pair: BracePair): Boolean {
val pairType = when (elementType) { val pairType = when (element.elementType) {
pair.leftBraceType -> pair.rightBraceType pair.leftBraceType -> pair.rightBraceType
pair.rightBraceType -> pair.leftBraceType pair.rightBraceType -> pair.leftBraceType
else -> return false else -> return false
} }
return if (pairType == pair.leftBraceType) { return if (pairType == pair.leftBraceType) {
checkBracePair(this, parent.firstChild, pairType, PsiElement::getNextSibling) checkBracePair(element, element.parent.firstChild, pairType, PsiElement::getNextSibling)
} }
else { else {
checkBracePair(this, parent.lastChild, pairType, PsiElement::getPrevSibling) checkBracePair(element, element.parent.lastChild, pairType, PsiElement::getPrevSibling)
} }
} }
@ -154,25 +156,25 @@ class DefaultRainbowVisitor : RainbowHighlightVisitor() {
return false return false
} }
private fun filterPairs(type: IElementType, element: LeafPsiElement): List<BracePair>? { fun filterPairs(type: IElementType, element: LeafPsiElement): List<BracePair>? {
val pairs = element.language.bracePairs ?: return null val pairs = element.language.bracePairs ?: return null
val filterBraceType = pairs[type.toString()] val filterBraceType = pairs[type.toString()]
return when { return when {
filterBraceType.isNullOrEmpty() -> { filterBraceType.isNullOrEmpty() -> {
null null
} }
// https://github.com/izhangzhihao/intellij-rainbow-brackets/issues/198 // https://github.com/izhangzhihao/intellij-rainbow-brackets/issues/198
element.javaClass.simpleName == "OCMacroForeignLeafElement" -> { element.javaClass.simpleName == "OCMacroForeignLeafElement" -> {
null null
} }
RainbowSettings.instance.isDoNOTRainbowifyBracketsWithoutContent -> { settings.isDoNOTRainbowifyBracketsWithoutContent -> {
filterBraceType filterBraceType
.filterNot { it.leftBraceType == type && element.nextSibling?.elementType() == it.rightBraceType } .filterNot { it.leftBraceType == type && element.nextSibling?.elementType() == it.rightBraceType }
.filterNot { it.rightBraceType == type && element.prevSibling?.elementType() == it.leftBraceType } .filterNot { it.rightBraceType == type && element.prevSibling?.elementType() == it.leftBraceType }
} }
else -> { else -> {
filterBraceType filterBraceType
} }
} }

View File

@ -1,8 +1,8 @@
package com.github.izhangzhihao.rainbow.brackets.visitor package com.chylex.intellij.coloredbrackets.visitor
import com.github.izhangzhihao.rainbow.brackets.settings.RainbowSettings import com.chylex.intellij.coloredbrackets.settings.RainbowSettings
import com.github.izhangzhihao.rainbow.brackets.visitor.XmlRainbowVisitor.Companion.iterateXmlTagParents import com.chylex.intellij.coloredbrackets.visitor.XmlRainbowVisitor.Companion.iterateXmlTagParents
import com.github.izhangzhihao.rainbow.brackets.visitor.XmlRainbowVisitor.Companion.xmlParent import com.chylex.intellij.coloredbrackets.visitor.XmlRainbowVisitor.Companion.xmlParent
import com.intellij.codeInsight.daemon.impl.HighlightVisitor import com.intellij.codeInsight.daemon.impl.HighlightVisitor
import com.intellij.psi.PsiElement import com.intellij.psi.PsiElement
import com.intellij.psi.PsiFile import com.intellij.psi.PsiFile
@ -10,7 +10,6 @@ import com.intellij.psi.xml.XmlTag
import com.intellij.psi.xml.XmlToken import com.intellij.psi.xml.XmlToken
import com.intellij.psi.xml.XmlTokenType import com.intellij.psi.xml.XmlTokenType
class PugRainbowVisitor : RainbowHighlightVisitor() { class PugRainbowVisitor : RainbowHighlightVisitor() {
override fun suitableForFile(file: PsiFile) override fun suitableForFile(file: PsiFile)

View File

@ -1,6 +1,6 @@
package com.github.izhangzhihao.rainbow.brackets.visitor package com.chylex.intellij.coloredbrackets.visitor
import com.github.izhangzhihao.rainbow.brackets.settings.RainbowSettings import com.chylex.intellij.coloredbrackets.settings.RainbowSettings
import com.intellij.codeInsight.daemon.impl.HighlightVisitor import com.intellij.codeInsight.daemon.impl.HighlightVisitor
import com.intellij.psi.PsiElement import com.intellij.psi.PsiElement
import com.intellij.psi.PsiFile import com.intellij.psi.PsiFile
@ -23,7 +23,6 @@ import com.jetbrains.python.PyTokenTypes.WITH_KEYWORD
import com.jetbrains.python.PyTokenTypes.YIELD_KEYWORD import com.jetbrains.python.PyTokenTypes.YIELD_KEYWORD
import com.jetbrains.python.psi.PyStatement import com.jetbrains.python.psi.PyStatement
class PythonRainbowVisitor : RainbowHighlightVisitor() { class PythonRainbowVisitor : RainbowHighlightVisitor() {
override fun suitableForFile(file: PsiFile) override fun suitableForFile(file: PsiFile)

View File

@ -1,9 +1,9 @@
package com.github.izhangzhihao.rainbow.brackets.visitor package com.chylex.intellij.coloredbrackets.visitor
import com.github.izhangzhihao.rainbow.brackets.RainbowHighlighter.getHighlightInfo import com.chylex.intellij.coloredbrackets.RainbowHighlighter.getHighlightInfo
import com.github.izhangzhihao.rainbow.brackets.RainbowInfo import com.chylex.intellij.coloredbrackets.RainbowInfo
import com.github.izhangzhihao.rainbow.brackets.settings.RainbowSettings import com.chylex.intellij.coloredbrackets.settings.RainbowSettings
import com.github.izhangzhihao.rainbow.brackets.util.memoizedFileExtension import com.chylex.intellij.coloredbrackets.util.memoizedFileExtension
import com.intellij.codeInsight.daemon.impl.HighlightVisitor import com.intellij.codeInsight.daemon.impl.HighlightVisitor
import com.intellij.codeInsight.daemon.impl.analysis.HighlightInfoHolder import com.intellij.codeInsight.daemon.impl.analysis.HighlightInfoHolder
import com.intellij.ide.plugins.PluginManagerCore import com.intellij.ide.plugins.PluginManagerCore
@ -16,16 +16,17 @@ import com.intellij.psi.PsiElement
import com.intellij.psi.PsiFile import com.intellij.psi.PsiFile
import java.awt.Color import java.awt.Color
abstract class RainbowHighlightVisitor : HighlightVisitor { abstract class RainbowHighlightVisitor : HighlightVisitor {
private var highlightInfoHolder: HighlightInfoHolder? = null private var highlightInfoHolder: HighlightInfoHolder? = null
override fun suitableForFile(file: PsiFile): Boolean { override fun suitableForFile(file: PsiFile): Boolean {
return RainbowSettings.instance.isRainbowEnabled && val settings = RainbowSettings.instance
return settings.isRainbowEnabled &&
checkForBigFile(file) && checkForBigFile(file) &&
!RainbowSettings.instance.languageBlacklist.contains(file.fileType.name) && !settings.languageBlacklist.contains(file.fileType.name) &&
!RainbowSettings.instance.languageBlacklist.contains(memoizedFileExtension(file.name)) && !settings.languageBlacklist.contains(memoizedFileExtension(file.name)) &&
fileIsNotHaskellOrIntelliJHaskellPluginNotEnabled(file.fileType.name) fileIsNotHaskellOrIntelliJHaskellPluginNotEnabled(file.fileType.name)
} }

View File

@ -1,4 +1,4 @@
package com.github.izhangzhihao.rainbow.brackets.visitor package com.chylex.intellij.coloredbrackets.visitor
import com.intellij.codeInsight.daemon.impl.HighlightVisitor import com.intellij.codeInsight.daemon.impl.HighlightVisitor
import com.intellij.lang.javascript.DialectDetector import com.intellij.lang.javascript.DialectDetector

View File

@ -1,6 +1,6 @@
package com.github.izhangzhihao.rainbow.brackets.visitor package com.chylex.intellij.coloredbrackets.visitor
import com.github.izhangzhihao.rainbow.brackets.settings.RainbowSettings import com.chylex.intellij.coloredbrackets.settings.RainbowSettings
import com.intellij.codeInsight.daemon.impl.HighlightVisitor import com.intellij.codeInsight.daemon.impl.HighlightVisitor
import com.intellij.psi.PsiElement import com.intellij.psi.PsiElement
import com.intellij.psi.PsiFile import com.intellij.psi.PsiFile
@ -9,7 +9,6 @@ import com.intellij.psi.xml.XmlTag
import com.intellij.psi.xml.XmlToken import com.intellij.psi.xml.XmlToken
import com.intellij.psi.xml.XmlTokenType import com.intellij.psi.xml.XmlTokenType
open class XmlRainbowVisitor : RainbowHighlightVisitor() { open class XmlRainbowVisitor : RainbowHighlightVisitor() {
override fun suitableForFile(file: PsiFile) override fun suitableForFile(file: PsiFile)

View File

@ -1,18 +0,0 @@
package com.github.izhangzhihao.rainbow.brackets.provider
import com.intellij.lang.BracePair
import com.jetbrains.rider.ideaInterop.fileTypes.csharp.lexer.CSharpTokenType.GT
import com.jetbrains.rider.ideaInterop.fileTypes.csharp.lexer.CSharpTokenType.LBRACE
import com.jetbrains.rider.ideaInterop.fileTypes.csharp.lexer.CSharpTokenType.LBRACKET
import com.jetbrains.rider.ideaInterop.fileTypes.csharp.lexer.CSharpTokenType.LT
import com.jetbrains.rider.ideaInterop.fileTypes.csharp.lexer.CSharpTokenType.RBRACE
import com.jetbrains.rider.ideaInterop.fileTypes.csharp.lexer.CSharpTokenType.RBRACKET
class CSharpBracePairProvider : BracePairProvider {
override fun pairs(): List<BracePair> = listOf(
//BracePair(LPARENTH, RPARENTH, false),
BracePair(LBRACE, RBRACE, false),
BracePair(LBRACKET, RBRACKET, false),
BracePair(LT, GT, false),
)
}

View File

@ -1,8 +0,0 @@
package com.github.izhangzhihao.rainbow.brackets.provider
import com.intellij.lang.BracePair
import com.jetbrains.cidr.lang.parser.OCTokenTypes
class OCBracePairProvider : BracePairProvider {
override fun pairs(): List<BracePair> = listOf(BracePair(OCTokenTypes.LT, OCTokenTypes.GT, false))
}

View File

@ -1,9 +1,9 @@
<idea-plugin> <idea-plugin>
<extensions defaultExtensionNs="com.intellij"> <extensions defaultExtensionNs="com.intellij">
<highlightVisitor implementation="com.github.izhangzhihao.rainbow.brackets.visitor.ReactJSXRainbowVisitor" /> <highlightVisitor implementation="com.chylex.intellij.coloredbrackets.visitor.ReactJSXRainbowVisitor" />
</extensions> </extensions>
<extensions defaultExtensionNs="com.chylex.coloredbrackets"> <extensions defaultExtensionNs="com.chylex.coloredbrackets">
<bracePairProvider language="JavaScript" <bracePairProvider language="JavaScript"
implementationClass="com.github.izhangzhihao.rainbow.brackets.provider.TSBracePairProvider" /> implementationClass="com.chylex.intellij.coloredbrackets.provider.TSBracePairProvider" />
</extensions> </extensions>
</idea-plugin> </idea-plugin>

View File

@ -1,5 +0,0 @@
<idea-plugin>
<extensions defaultExtensionNs="com.intellij">
<annotator language="C#" implementationClass="com.github.izhangzhihao.rainbow.brackets.annotator.RainbowAnnotator" />
</extensions>
</idea-plugin>

View File

@ -1,10 +0,0 @@
<idea-plugin>
<extensions defaultExtensionNs="com.chylex.coloredbrackets">
<bracePairProvider language="C#"
implementationClass="com.github.izhangzhihao.rainbow.brackets.provider.CSharpBracePairProvider" />
</extensions>
<extensions defaultExtensionNs="com.intellij">
<highlightVisitor implementation="com.github.izhangzhihao.rainbow.brackets.visitor.CSharpRainbowVisitor" />
</extensions>
</idea-plugin>

View File

@ -1,6 +1,6 @@
<idea-plugin> <idea-plugin>
<extensions defaultExtensionNs="com.chylex.coloredbrackets"> <extensions defaultExtensionNs="com.chylex.coloredbrackets">
<bracePairProvider language="Dart" <bracePairProvider language="Dart"
implementationClass="com.github.izhangzhihao.rainbow.brackets.provider.DartBracePairProvider" /> implementationClass="com.chylex.intellij.coloredbrackets.provider.DartBracePairProvider" />
</extensions> </extensions>
</idea-plugin> </idea-plugin>

View File

@ -1,6 +1,6 @@
<idea-plugin> <idea-plugin>
<extensions defaultExtensionNs="com.chylex.coloredbrackets"> <extensions defaultExtensionNs="com.chylex.coloredbrackets">
<bracePairProvider language="GoTemplate" <bracePairProvider language="GoTemplate"
implementationClass="com.github.izhangzhihao.rainbow.brackets.provider.GoTemplateProvider" /> implementationClass="com.chylex.intellij.coloredbrackets.provider.GoTemplateProvider" />
</extensions> </extensions>
</idea-plugin> </idea-plugin>

View File

@ -1,6 +1,6 @@
<idea-plugin> <idea-plugin>
<extensions defaultExtensionNs="com.chylex.coloredbrackets"> <extensions defaultExtensionNs="com.chylex.coloredbrackets">
<bracePairProvider language="Groovy" <bracePairProvider language="Groovy"
implementationClass="com.github.izhangzhihao.rainbow.brackets.provider.GroovyBracePairProvider" /> implementationClass="com.chylex.intellij.coloredbrackets.provider.GroovyBracePairProvider" />
</extensions> </extensions>
</idea-plugin> </idea-plugin>

View File

@ -1,5 +1,5 @@
<idea-plugin> <idea-plugin>
<extensions defaultExtensionNs="com.intellij"> <extensions defaultExtensionNs="com.intellij">
<annotator language="Haskell" implementationClass="com.github.izhangzhihao.rainbow.brackets.annotator.RainbowAnnotator" /> <annotator language="Haskell" implementationClass="com.chylex.intellij.coloredbrackets.annotator.RainbowAnnotator" />
</extensions> </extensions>
</idea-plugin> </idea-plugin>

View File

@ -1,5 +1,5 @@
<idea-plugin> <idea-plugin>
<extensions defaultExtensionNs="com.intellij"> <extensions defaultExtensionNs="com.intellij">
<highlightVisitor implementation="com.github.izhangzhihao.rainbow.brackets.visitor.PugRainbowVisitor" /> <highlightVisitor implementation="com.chylex.intellij.coloredbrackets.visitor.PugRainbowVisitor" />
</extensions> </extensions>
</idea-plugin> </idea-plugin>

View File

@ -1,12 +1,12 @@
<idea-plugin> <idea-plugin>
<extensions defaultExtensionNs="com.chylex.coloredbrackets"> <extensions defaultExtensionNs="com.chylex.coloredbrackets">
<bracePairProvider language="kotlin" <bracePairProvider language="kotlin"
implementationClass="com.github.izhangzhihao.rainbow.brackets.provider.KotlinBracePairProvider" /> implementationClass="com.chylex.intellij.coloredbrackets.provider.KotlinBracePairProvider" />
</extensions> </extensions>
<extensions defaultExtensionNs="com.intellij"> <extensions defaultExtensionNs="com.intellij">
<annotator language="kotlin" <annotator language="kotlin"
implementationClass="com.github.izhangzhihao.rainbow.brackets.annotator.KotlinLambdaExpressionArrowAnnotator" /> implementationClass="com.chylex.intellij.coloredbrackets.annotator.KotlinLambdaExpressionArrowAnnotator" />
<annotator language="kotlin" <annotator language="kotlin"
implementationClass="com.github.izhangzhihao.rainbow.brackets.annotator.KotlinLabelAnnotator" /> implementationClass="com.chylex.intellij.coloredbrackets.annotator.KotlinLabelAnnotator" />
</extensions> </extensions>
</idea-plugin> </idea-plugin>

View File

@ -1,6 +1,6 @@
<idea-plugin> <idea-plugin>
<extensions defaultExtensionNs="com.chylex.coloredbrackets"> <extensions defaultExtensionNs="com.chylex.coloredbrackets">
<bracePairProvider language="PHP" <bracePairProvider language="PHP"
implementationClass="com.github.izhangzhihao.rainbow.brackets.provider.PHPBracePairProvider" /> implementationClass="com.chylex.intellij.coloredbrackets.provider.PHPBracePairProvider" />
</extensions> </extensions>
</idea-plugin> </idea-plugin>

View File

@ -33,34 +33,34 @@
<extensionPoints> <extensionPoints>
<extensionPoint name="bracePairProvider" beanClass="com.intellij.lang.LanguageExtensionPoint" dynamic="true"> <extensionPoint name="bracePairProvider" beanClass="com.intellij.lang.LanguageExtensionPoint" dynamic="true">
<with attribute="implementationClass" <with attribute="implementationClass"
implements="com.github.izhangzhihao.rainbow.brackets.provider.BracePairProvider" /> implements="com.chylex.intellij.coloredbrackets.provider.BracePairProvider" />
</extensionPoint> </extensionPoint>
</extensionPoints> </extensionPoints>
<extensions defaultExtensionNs="com.intellij"> <extensions defaultExtensionNs="com.intellij">
<highlightVisitor implementation="com.github.izhangzhihao.rainbow.brackets.visitor.DefaultRainbowVisitor" /> <highlightVisitor implementation="com.chylex.intellij.coloredbrackets.visitor.DefaultRainbowVisitor" />
<highlightVisitor implementation="com.github.izhangzhihao.rainbow.brackets.visitor.XmlRainbowVisitor" /> <highlightVisitor implementation="com.chylex.intellij.coloredbrackets.visitor.XmlRainbowVisitor" />
<applicationConfigurable instance="com.github.izhangzhihao.rainbow.brackets.settings.RainbowConfigurable" displayName="Colored Brackets" parentId="appearance" /> <applicationConfigurable instance="com.chylex.intellij.coloredbrackets.settings.RainbowConfigurable" displayName="Colored Brackets" parentId="appearance" />
<applicationService <applicationService
serviceImplementation="com.github.izhangzhihao.rainbow.brackets.settings.RainbowSettings" /> serviceImplementation="com.chylex.intellij.coloredbrackets.settings.RainbowSettings" />
<colorAndFontPanelFactory <colorAndFontPanelFactory
implementation="com.github.izhangzhihao.rainbow.brackets.settings.RainbowColorsPageFactory" /> implementation="com.chylex.intellij.coloredbrackets.settings.RainbowColorsPageFactory" />
<colorAndFontDescriptorProvider <colorAndFontDescriptorProvider
implementation="com.github.izhangzhihao.rainbow.brackets.settings.RainbowColorsPageFactory" /> implementation="com.chylex.intellij.coloredbrackets.settings.RainbowColorsPageFactory" />
<additionalTextAttributes scheme="Default" file="colorSchemes/rainbow-color-default.xml" /> <additionalTextAttributes scheme="Default" file="colorSchemes/rainbow-color-default.xml" />
<additionalTextAttributes scheme="Darcula" file="colorSchemes/rainbow-color-default-darcula.xml" /> <additionalTextAttributes scheme="Darcula" file="colorSchemes/rainbow-color-default-darcula.xml" />
<highlightingPassFactory implementation="com.github.izhangzhihao.rainbow.brackets.indents.RainbowIndentsPassFactory" /> <highlightingPassFactory implementation="com.chylex.intellij.coloredbrackets.indents.RainbowIndentsPassFactory" />
<editorNotificationProvider implementation="com.github.izhangzhihao.rainbow.brackets.RainbowifyBanner" /> <editorNotificationProvider implementation="com.chylex.intellij.coloredbrackets.RainbowifyBanner" />
</extensions> </extensions>
<applicationListeners> <applicationListeners>
<listener class="com.github.izhangzhihao.rainbow.brackets.listener.RainbowColorsSchemeListener" topic="com.intellij.openapi.editor.colors.EditorColorsListener" /> <listener class="com.chylex.intellij.coloredbrackets.listener.RainbowColorsSchemeListener" topic="com.intellij.openapi.editor.colors.EditorColorsListener" />
</applicationListeners> </applicationListeners>
<actions> <actions>
<action class="com.github.izhangzhihao.rainbow.brackets.action.ScopeHighlightingAction" <action class="com.chylex.intellij.coloredbrackets.action.ScopeHighlightingAction"
id="Rainbow.ScopeHighlightingAction" id="Rainbow.ScopeHighlightingAction"
text="Highlight Current Scope" text="Highlight Current Scope"
description="Highlight current scope."> description="Highlight current scope.">
@ -68,7 +68,7 @@
<mouse-shortcut keymap="Mac OS X" keystroke="meta button3" /> <mouse-shortcut keymap="Mac OS X" keystroke="meta button3" />
<mouse-shortcut keymap="Mac OS X 10.5+" keystroke="meta button3" /> <mouse-shortcut keymap="Mac OS X 10.5+" keystroke="meta button3" />
</action> </action>
<action class="com.github.izhangzhihao.rainbow.brackets.action.ScopeOutsideHighlightingRestrainAction" <action class="com.chylex.intellij.coloredbrackets.action.ScopeOutsideHighlightingRestrainAction"
id="Rainbow.ScopeOutsideHighlightingRestrainAction" id="Rainbow.ScopeOutsideHighlightingRestrainAction"
text="Restrain Scope Highlighting" text="Restrain Scope Highlighting"
description="Restrain outside of current scope highlighting."> description="Restrain outside of current scope highlighting.">

View File

@ -1,5 +1,5 @@
<idea-plugin> <idea-plugin>
<extensions defaultExtensionNs="com.intellij"> <extensions defaultExtensionNs="com.intellij">
<highlightVisitor implementation="com.github.izhangzhihao.rainbow.brackets.visitor.PythonRainbowVisitor" /> <highlightVisitor implementation="com.chylex.intellij.coloredbrackets.visitor.PythonRainbowVisitor" />
</extensions> </extensions>
</idea-plugin> </idea-plugin>

View File

@ -1,6 +1,6 @@
<idea-plugin> <idea-plugin>
<extensions defaultExtensionNs="com.chylex.coloredbrackets"> <extensions defaultExtensionNs="com.chylex.coloredbrackets">
<bracePairProvider language="Shell Script" <bracePairProvider language="Shell Script"
implementationClass="com.github.izhangzhihao.rainbow.brackets.provider.SHBracePairProvider" /> implementationClass="com.chylex.intellij.coloredbrackets.provider.SHBracePairProvider" />
</extensions> </extensions>
</idea-plugin> </idea-plugin>

View File

@ -1,6 +1,6 @@
<idea-plugin> <idea-plugin>
<extensions defaultExtensionNs="com.chylex.coloredbrackets"> <extensions defaultExtensionNs="com.chylex.coloredbrackets">
<bracePairProvider language="SQL" <bracePairProvider language="SQL"
implementationClass="com.github.izhangzhihao.rainbow.brackets.provider.SqlBracePairProvider" /> implementationClass="com.chylex.intellij.coloredbrackets.provider.SqlBracePairProvider" />
</extensions> </extensions>
</idea-plugin> </idea-plugin>

View File

@ -1,4 +1,4 @@
package com.github.izhangzhihao.rainbow.brackets package com.chylex.intellij.coloredbrackets
import com.intellij.psi.PsiDocumentManager import com.intellij.psi.PsiDocumentManager
import com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase import com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase

View File

@ -1,4 +1,4 @@
package com.github.izhangzhihao.rainbow.brackets package com.chylex.intellij.coloredbrackets
import com.intellij.psi.PsiDocumentManager import com.intellij.psi.PsiDocumentManager
import com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase import com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase

View File

@ -1,4 +1,4 @@
package com.github.izhangzhihao.rainbow.brackets package com.chylex.intellij.coloredbrackets
import com.intellij.ide.plugins.PluginManagerCore import com.intellij.ide.plugins.PluginManagerCore
import com.intellij.lang.ecmascript6.JSXHarmonyFileType import com.intellij.lang.ecmascript6.JSXHarmonyFileType

View File

@ -1,6 +1,6 @@
package com.github.izhangzhihao.rainbow.brackets package com.chylex.intellij.coloredbrackets
import com.github.izhangzhihao.rainbow.brackets.settings.RainbowSettings import com.chylex.intellij.coloredbrackets.settings.RainbowSettings
import com.intellij.ide.highlighter.JavaFileType import com.intellij.ide.highlighter.JavaFileType
import com.intellij.psi.PsiDocumentManager import com.intellij.psi.PsiDocumentManager
import com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase import com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase

View File

@ -1,4 +1,4 @@
package com.github.izhangzhihao.rainbow.brackets package com.chylex.intellij.coloredbrackets
import com.intellij.psi.PsiDocumentManager import com.intellij.psi.PsiDocumentManager
import com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase import com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase
@ -57,7 +57,6 @@ fun <T> filter(l: List<T>, f: (T) -> Boolean): MutableList<T> {
squigglyLevel(1), squigglyLevel(1),
squigglyLevel(0) squigglyLevel(0)
) )
@ -99,7 +98,6 @@ val a: (Int) -> Unit = { aa ->
squigglyLevel(1), squigglyLevel(1),
squigglyLevel(1), squigglyLevel(1),
roundLevel(0), roundLevel(0),
roundLevel(0), roundLevel(0),
@ -112,12 +110,10 @@ val a: (Int) -> Unit = { aa ->
squigglyLevel(3), squigglyLevel(3),
squigglyLevel(3), squigglyLevel(3),
squigglyLevel(3), squigglyLevel(3),
squigglyLevel(2), squigglyLevel(2),
squigglyLevel(1), squigglyLevel(1),
squigglyLevel(0) squigglyLevel(0)

View File

@ -1,4 +1,4 @@
package com.github.izhangzhihao.rainbow.brackets package com.chylex.intellij.coloredbrackets
import com.intellij.codeInsight.daemon.impl.HighlightInfoType import com.intellij.codeInsight.daemon.impl.HighlightInfoType
import com.intellij.psi.PsiDocumentManager import com.intellij.psi.PsiDocumentManager

View File

@ -1,4 +1,4 @@
package com.github.izhangzhihao.rainbow.brackets package com.chylex.intellij.coloredbrackets
import com.intellij.ide.plugins.PluginManagerCore import com.intellij.ide.plugins.PluginManagerCore
import com.intellij.openapi.extensions.PluginId import com.intellij.openapi.extensions.PluginId
@ -13,7 +13,6 @@ class RainbowRubyTest : LightJavaCodeInsightFixtureTestCase() {
assertTrue(PluginManagerCore.getPlugin(PluginId.getId("org.jetbrains.plugins.ruby"))?.isEnabled!!) assertTrue(PluginManagerCore.getPlugin(PluginId.getId("org.jetbrains.plugins.ruby"))?.isEnabled!!)
} }
fun testRainbowForIssue53Part0() { fun testRainbowForIssue53Part0() {
val code = val code =
""" """

View File

@ -1,6 +1,6 @@
package com.github.izhangzhihao.rainbow.brackets package com.chylex.intellij.coloredbrackets
import com.github.izhangzhihao.rainbow.brackets.settings.RainbowSettings import com.chylex.intellij.coloredbrackets.settings.RainbowSettings
import com.intellij.psi.PsiDocumentManager import com.intellij.psi.PsiDocumentManager
import com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase import com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase
import io.kotest.matchers.shouldBe import io.kotest.matchers.shouldBe

View File

@ -1,6 +1,6 @@
package com.github.izhangzhihao.rainbow.brackets package com.chylex.intellij.coloredbrackets
import com.github.izhangzhihao.rainbow.brackets.settings.RainbowSettings import com.chylex.intellij.coloredbrackets.settings.RainbowSettings
import com.intellij.ide.highlighter.XmlFileType import com.intellij.ide.highlighter.XmlFileType
import com.intellij.psi.PsiDocumentManager import com.intellij.psi.PsiDocumentManager
import com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase import com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase

View File

@ -1,6 +1,6 @@
package com.github.izhangzhihao.rainbow.brackets package com.chylex.intellij.coloredbrackets
import com.github.izhangzhihao.rainbow.brackets.settings.RainbowSettings import com.chylex.intellij.coloredbrackets.settings.RainbowSettings
import com.intellij.ide.highlighter.JavaFileType import com.intellij.ide.highlighter.JavaFileType
import com.intellij.psi.PsiDocumentManager import com.intellij.psi.PsiDocumentManager
import com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase import com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase

View File

@ -1,5 +1,4 @@
package com.github.izhangzhihao.rainbow.brackets package com.chylex.intellij.coloredbrackets
val brackets = RainbowHighlighter.getBrackets() val brackets = RainbowHighlighter.getBrackets()