-
-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored syntax highlight to support multiple languages
- Loading branch information
1 parent
6011b62
commit 284597c
Showing
9 changed files
with
304 additions
and
135 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
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
7 changes: 7 additions & 0 deletions
7
...ain/kotlin/com/jetpackduba/gitnuro/ui/diff/syntax_highlighter/DefaultSyntaxHighlighter.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,7 @@ | ||
package com.jetpackduba.gitnuro.ui.diff.syntax_highlighter | ||
|
||
class DefaultSyntaxHighlighter : SyntaxHighlighter() { | ||
override fun loadKeywords(): List<String> = emptyList() | ||
override fun isAnnotation(word: String): Boolean = false | ||
override fun isComment(line: String): Boolean = false | ||
} |
74 changes: 74 additions & 0 deletions
74
...main/kotlin/com/jetpackduba/gitnuro/ui/diff/syntax_highlighter/KotlinSyntaxHighlighter.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,74 @@ | ||
package com.jetpackduba.gitnuro.ui.diff.syntax_highlighter | ||
|
||
class KotlinSyntaxHighlighter : SyntaxHighlighter() { | ||
override fun loadKeywords(): List<String> = listOf( | ||
"as", | ||
"as?", | ||
"break", | ||
"by", | ||
"catch", | ||
"class", | ||
"constructor", | ||
"continue", | ||
"do", | ||
"dynamic", | ||
"else", | ||
"false", | ||
"finally", | ||
"for", | ||
"fun", | ||
"if", | ||
"import", | ||
"in", | ||
"!in", | ||
"interface", | ||
"is", | ||
"!is", | ||
"null", | ||
"object", | ||
"package", | ||
"return", | ||
"super", | ||
"this", | ||
"throw", | ||
"true", | ||
"try", | ||
"val", | ||
"var", | ||
"when", | ||
"where", | ||
"while", | ||
"actual", | ||
"abstract", | ||
"annotation", | ||
"companion", | ||
"const", | ||
"crossinline", | ||
"data", | ||
"enum", | ||
"expect", | ||
"external", | ||
"final", | ||
"infix", | ||
"inline", | ||
"inner", | ||
"internal", | ||
"lateinit", | ||
"noinline", | ||
"open", | ||
"operator", | ||
"out", | ||
"override", | ||
"private", | ||
"protected", | ||
"public", | ||
"reified", | ||
"sealed", | ||
"suspend", | ||
"tailrec", | ||
"vararg", | ||
) | ||
|
||
override fun isAnnotation(word: String): Boolean = word.startsWith("@") | ||
override fun isComment(line: String): Boolean = line.startsWith("//") | ||
} |
49 changes: 49 additions & 0 deletions
49
src/main/kotlin/com/jetpackduba/gitnuro/ui/diff/syntax_highlighter/RustSyntaxHighlighter.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,49 @@ | ||
package com.jetpackduba.gitnuro.ui.diff.syntax_highlighter | ||
|
||
class RustSyntaxHighlighter : SyntaxHighlighter() { | ||
override fun loadKeywords(): List<String> = listOf( | ||
"as", | ||
"async", | ||
"await", | ||
"break", | ||
"const", | ||
"continue", | ||
"crate", | ||
"dyn", | ||
"else", | ||
"enum", | ||
"extern", | ||
"false", | ||
"fn", | ||
"for", | ||
"if", | ||
"impl", | ||
"in", | ||
"let", | ||
"loop", | ||
"match", | ||
"mod", | ||
"move", | ||
"mut", | ||
"pub", | ||
"ref", | ||
"return", | ||
"Self", | ||
"self", | ||
"static", | ||
"struct", | ||
"super", | ||
"trait", | ||
"true", | ||
"type", | ||
"union", | ||
"unsafe", | ||
"use", | ||
"where", | ||
"while", | ||
) | ||
|
||
override fun isAnnotation(word: String): Boolean = word.startsWith("#[") && word.endsWith("]") | ||
|
||
override fun isComment(line: String): Boolean = line.startsWith("//") | ||
} |
Oops, something went wrong.