generated from JetBrains/intellij-platform-plugin-template
-
-
Notifications
You must be signed in to change notification settings - Fork 26
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
1 parent
e127572
commit 77022f5
Showing
5 changed files
with
53 additions
and
4 deletions.
There are no files selected for viewing
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
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
38 changes: 38 additions & 0 deletions
38
src/main/kotlin/com/github/dinbtechit/vscodetheme/annotators/PhpAnnotator.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,38 @@ | ||
package com.github.dinbtechit.vscodetheme.annotators | ||
|
||
import com.intellij.openapi.editor.DefaultLanguageHighlighterColors | ||
import com.intellij.openapi.editor.colors.TextAttributesKey | ||
import com.intellij.psi.PsiComment | ||
import com.intellij.psi.PsiElement | ||
import com.intellij.util.ObjectUtils | ||
import com.jetbrains.php.lang.psi.elements.* | ||
|
||
class PhpAnnotator : BaseAnnotator() { | ||
companion object { | ||
val DEFAULT_KEYWORD: TextAttributesKey = ObjectUtils.notNull( | ||
TextAttributesKey.find("DEFAULT_KEYWORD"), DefaultLanguageHighlighterColors.KEYWORD | ||
) | ||
val SECONDARY_KEYWORD: TextAttributesKey = TextAttributesKey.createTextAttributesKey( | ||
"DEFAULT_SECONDARY_KEYWORD", | ||
DEFAULT_KEYWORD | ||
) | ||
|
||
} | ||
|
||
override fun getKeywordType(element: PsiElement): TextAttributesKey? { | ||
var type: TextAttributesKey? = null | ||
if (element is PsiComment) return null | ||
when(element.text) { | ||
"{", "}", "(", ")", ";", ":" -> return null | ||
} | ||
when (element.context) { | ||
is ControlStatement -> type = SECONDARY_KEYWORD | ||
is PhpSwitch, | ||
is Else, is PhpBreak, is Try, is PhpReturn -> type = SECONDARY_KEYWORD | ||
else -> {} | ||
} | ||
|
||
return type | ||
} | ||
|
||
} |
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,6 @@ | ||
<idea-plugin> | ||
<extensions defaultExtensionNs="com.intellij"> | ||
<annotator language="PHP" order="last" | ||
implementationClass="com.github.dinbtechit.vscodetheme.annotators.PhpAnnotator"/> | ||
</extensions> | ||
</idea-plugin> |
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