mirror of
https://github.com/chylex/IntelliJ-Rainbow-Brackets.git
synced 2025-06-01 19:34:06 +02:00
Remove unused code
This commit is contained in:
parent
75e0cb6d26
commit
b1743c4487
@ -10,19 +10,11 @@ import com.intellij.psi.PsiElement
|
|||||||
import com.intellij.psi.impl.source.tree.LeafPsiElement
|
import com.intellij.psi.impl.source.tree.LeafPsiElement
|
||||||
import java.awt.Color
|
import java.awt.Color
|
||||||
import java.awt.Font
|
import java.awt.Font
|
||||||
import java.util.regex.Pattern
|
|
||||||
|
|
||||||
|
|
||||||
class RainbowBrackets : Annotator {
|
class RainbowBrackets : Annotator {
|
||||||
private val bracketsList = arrayOf("(", ")", "{", "}", "[", "]")
|
private val bracketsList = arrayOf("(", ")", "{", "}", "[", "]")
|
||||||
|
|
||||||
private val haskellMultiLineCommentPattern = Pattern.compile(
|
|
||||||
"\\{-.*?-\\}"
|
|
||||||
)
|
|
||||||
private val normalMultiLineCommentPattern = Pattern.compile(
|
|
||||||
"/\\*.*?\\*/"
|
|
||||||
)
|
|
||||||
|
|
||||||
private fun getAttributesColor(level: Int, bracket: String): Color {
|
private fun getAttributesColor(level: Int, bracket: String): Color {
|
||||||
return when (bracket) {
|
return when (bracket) {
|
||||||
"(", ")" -> dynamicallySelectColor(level, roundBracketsColor)
|
"(", ")" -> dynamicallySelectColor(level, roundBracketsColor)
|
||||||
@ -79,28 +71,10 @@ class RainbowBrackets : Annotator {
|
|||||||
|
|
||||||
private val isString = { element: PsiElement -> visitParent(element, { e -> isString(e.text) }) }
|
private val isString = { element: PsiElement -> visitParent(element, { e -> isString(e.text) }) }
|
||||||
|
|
||||||
private val isMultiLineComment = { element: PsiElement, pattern: Pattern ->
|
|
||||||
val matcher = pattern.matcher(element.containingFile.text.replace("\n", " "))
|
|
||||||
var isInMultiLineComment = false
|
|
||||||
while (matcher.find()) {
|
|
||||||
isInMultiLineComment = matcher.start() <= element.textOffset && element.textOffset <= matcher.end()
|
|
||||||
if (isInMultiLineComment) break
|
|
||||||
}
|
|
||||||
isInMultiLineComment
|
|
||||||
}
|
|
||||||
|
|
||||||
private val isHaskellMultiLineComment = { element: PsiElement -> isMultiLineComment(element, haskellMultiLineCommentPattern) }
|
|
||||||
|
|
||||||
private val isNormalMultiLineComment = { element: PsiElement -> isMultiLineComment(element, normalMultiLineCommentPattern) }
|
|
||||||
|
|
||||||
override fun annotate(element: PsiElement, holder: AnnotationHolder) {
|
override fun annotate(element: PsiElement, holder: AnnotationHolder) {
|
||||||
val languageID = element.language.id
|
|
||||||
if (element is LeafPsiElement
|
if (element is LeafPsiElement
|
||||||
&& bracketsList.contains(element.text)
|
&& bracketsList.contains(element.text)
|
||||||
&& languageID != "Clojure"
|
&& !isString(element)) {
|
||||||
&& !isString(element)
|
|
||||||
&& !isHaskellMultiLineComment(element)
|
|
||||||
&& !isNormalMultiLineComment(element)) {
|
|
||||||
val level = getBracketLevel(element)
|
val level = getBracketLevel(element)
|
||||||
val attrs = getBracketAttributes(level, element.text)
|
val attrs = getBracketAttributes(level, element.text)
|
||||||
holder.createInfoAnnotation(element as PsiElement, null).enforcedTextAttributes = attrs
|
holder.createInfoAnnotation(element as PsiElement, null).enforcedTextAttributes = attrs
|
||||||
|
Loading…
Reference in New Issue
Block a user