mirror of
https://github.com/GayPizzaSpecifications/pork.git
synced 2025-08-02 12:50:55 +00:00
idea: comment highlighting support
This commit is contained in:
parent
1be098d1c9
commit
f6d2fc5165
@ -19,7 +19,7 @@ class AstCodegen(val pkg: String, val outputDirectory: Path, val world: AstWorld
|
||||
writeAstType(type)
|
||||
}
|
||||
writeNodeType()
|
||||
writeNodeVisitor()
|
||||
writeNodeVisitors()
|
||||
writeNodeCoalescer()
|
||||
}
|
||||
|
||||
@ -45,8 +45,8 @@ class AstCodegen(val pkg: String, val outputDirectory: Path, val world: AstWorld
|
||||
write("NodeType.kt", KotlinWriter(enumClass))
|
||||
}
|
||||
|
||||
private fun writeNodeVisitor() {
|
||||
val visitorInterface = KotlinClass(
|
||||
private fun writeNodeVisitors() {
|
||||
val nodeVisitorInterface = KotlinClass(
|
||||
pkg,
|
||||
"NodeVisitor",
|
||||
typeParameters = mutableListOf("T"),
|
||||
@ -60,7 +60,7 @@ class AstCodegen(val pkg: String, val outputDirectory: Path, val world: AstWorld
|
||||
continue
|
||||
}
|
||||
|
||||
val visitFunction = KotlinFunction(
|
||||
val nodeVisitFunction = KotlinFunction(
|
||||
"visit${type.name}",
|
||||
returnType = "T",
|
||||
parameters = mutableListOf(
|
||||
@ -68,9 +68,9 @@ class AstCodegen(val pkg: String, val outputDirectory: Path, val world: AstWorld
|
||||
),
|
||||
isInterfaceMethod = true
|
||||
)
|
||||
visitorInterface.functions.add(visitFunction)
|
||||
nodeVisitorInterface.functions.add(nodeVisitFunction)
|
||||
}
|
||||
write("NodeVisitor.kt", KotlinWriter(visitorInterface))
|
||||
write("NodeVisitor.kt", KotlinWriter(nodeVisitorInterface))
|
||||
|
||||
val visitorExtensionSet = KotlinFunctionSet(pkg)
|
||||
val visitAnyFunction = KotlinFunction(
|
||||
|
@ -89,8 +89,13 @@ class PorkLexer : LexerBase() {
|
||||
PorkTokenTypes.Number
|
||||
token.type == TokenType.Whitespace ->
|
||||
PorkTokenTypes.Whitespace
|
||||
token.type == TokenType.BlockComment ->
|
||||
PorkTokenTypes.BlockComment
|
||||
token.type == TokenType.LineComment ->
|
||||
PorkTokenTypes.LineComment
|
||||
else -> PsiTokenType.CODE_FRAGMENT
|
||||
}
|
||||
|
||||
override fun toString(): String = "Lexer(start=$internalTokenStart, end=$internalTokenEnd)"
|
||||
override fun toString(): String =
|
||||
"PorkLexer(start=$internalTokenStart, end=$internalTokenEnd)"
|
||||
}
|
||||
|
@ -40,6 +40,16 @@ object PorkSyntaxHighlighter : SyntaxHighlighter {
|
||||
"PORK.NUMBER",
|
||||
DefaultLanguageHighlighterColors.NUMBER
|
||||
)
|
||||
PorkTokenTypes.BlockComment ->
|
||||
TextAttributesKey.createTextAttributesKey(
|
||||
"PORK.COMMENT.BLOCK",
|
||||
DefaultLanguageHighlighterColors.BLOCK_COMMENT
|
||||
)
|
||||
PorkTokenTypes.LineComment ->
|
||||
TextAttributesKey.createTextAttributesKey(
|
||||
"PORK.COMMENT.LINE",
|
||||
DefaultLanguageHighlighterColors.LINE_COMMENT
|
||||
)
|
||||
else -> null
|
||||
}
|
||||
return if (attributes == null)
|
||||
|
@ -10,4 +10,6 @@ object PorkTokenTypes {
|
||||
val Operator = IElementType("operator", PorkLanguage)
|
||||
val String = IElementType("string", PorkLanguage)
|
||||
val Number = IElementType("number", PorkLanguage)
|
||||
val BlockComment = IElementType("lineComment", PorkLanguage)
|
||||
val LineComment = IElementType("blockComment", PorkLanguage)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user