[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve performance when using BracePair #48

Merged
merged 5 commits into from
May 2, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Simplify code
  • Loading branch information
izhangzhihao committed May 1, 2018
commit 2136fadd46ea6c266b4f2aca71d4258d32b23a2d
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.github.izhangzhihao.rainbow.brackets.visitor

import com.github.izhangzhihao.rainbow.brackets.RainbowHighlighter.isDoNOTRainbowifyBracketsWithoutContent
import com.github.izhangzhihao.rainbow.brackets.bracePairs
import com.github.izhangzhihao.rainbow.brackets.visitor.DefaultRainbowVisitor.Companion.filterPairs
import com.intellij.codeInsight.daemon.impl.HighlightVisitor
import com.intellij.lang.BracePair
import com.intellij.psi.PsiElement
Expand Down Expand Up @@ -85,12 +84,12 @@ class DefaultRainbowVisitor : RainbowHighlightVisitor() {

private fun filterPairs(type: IElementType, element: LeafPsiElement): BracePair? {
val pairs = element.language.bracePairs ?: return null
val filterBraceType = pairs[type.toString()]
val filterBraceType = pairs[type.toString()] ?: return null
return if (!isDoNOTRainbowifyBracketsWithoutContent) {
filterBraceType
} else {
filterBraceType
.takeUnless { it?.leftBraceType == type && element.nextSibling?.elementType() == it.rightBraceType }
.takeUnless { it.leftBraceType == type && element.nextSibling?.elementType() == it.rightBraceType }
.takeUnless { it?.rightBraceType == type && element.prevSibling?.elementType() == it.leftBraceType }
}
}
Expand Down