-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
24 additions
and
0 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
src/main/kotlin/ris58h/webcalm/javascript/JavaScriptRainbowVisitor.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package ris58h.webcalm.javascript | ||
|
||
import com.intellij.codeInsight.daemon.RainbowVisitor | ||
import com.intellij.codeInsight.daemon.impl.HighlightVisitor | ||
import com.intellij.openapi.editor.DefaultLanguageHighlighterColors | ||
import com.intellij.psi.PsiElement | ||
import com.intellij.psi.PsiFile | ||
import ris58h.webcalm.javascript.psi.* | ||
|
||
class JavaScriptRainbowVisitor : RainbowVisitor() { | ||
override fun suitableForFile(file: PsiFile): Boolean = file is JavaScriptFile | ||
|
||
override fun visit(element: PsiElement) { | ||
if (element !is JavaScriptIdentifier) return | ||
if (element.introducesName() || element.parent is JavaScriptIdentifierOwner | ||
|| element.parent is JavaScriptBreakStatement || element.parent is JavaScriptContinueStatement | ||
|| element.parent is JavaScriptIdentifierExpression) { | ||
addInfo(getInfo(element.containingFile, element, element.text, DefaultLanguageHighlighterColors.IDENTIFIER)) | ||
} | ||
} | ||
|
||
override fun clone(): HighlightVisitor = JavaScriptRainbowVisitor() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters