Skip to content

Commit

Permalink
[JavaScript] Semantic Highlighting.
Browse files Browse the repository at this point in the history
  • Loading branch information
ris58h committed Jun 21, 2023
1 parent 99d8ab2 commit 778a6d0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
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()
}
1 change: 1 addition & 0 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
<lang.refactoringSupport
language="JavaScript"
implementationClass="ris58h.webcalm.javascript.JavaScriptRefactoringSupportProvider"/>
<highlightVisitor implementation="ris58h.webcalm.javascript.JavaScriptRainbowVisitor"/>
<!-- CSS -->
<!-- <fileType-->
<!-- name="CSS"-->
Expand Down

0 comments on commit 778a6d0

Please sign in to comment.