diff --git a/buildext/src/main/kotlin/gay/pizza/pork/buildext/ast/AstCodegen.kt b/buildext/src/main/kotlin/gay/pizza/pork/buildext/ast/AstCodegen.kt index 2769fc5..7750a65 100644 --- a/buildext/src/main/kotlin/gay/pizza/pork/buildext/ast/AstCodegen.kt +++ b/buildext/src/main/kotlin/gay/pizza/pork/buildext/ast/AstCodegen.kt @@ -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( diff --git a/support/pork-idea/src/main/kotlin/gay/pizza/pork/idea/PorkLexer.kt b/support/pork-idea/src/main/kotlin/gay/pizza/pork/idea/PorkLexer.kt index 6f3eeda..2bbf5d0 100644 --- a/support/pork-idea/src/main/kotlin/gay/pizza/pork/idea/PorkLexer.kt +++ b/support/pork-idea/src/main/kotlin/gay/pizza/pork/idea/PorkLexer.kt @@ -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)" } diff --git a/support/pork-idea/src/main/kotlin/gay/pizza/pork/idea/PorkSyntaxHighlighter.kt b/support/pork-idea/src/main/kotlin/gay/pizza/pork/idea/PorkSyntaxHighlighter.kt index edc40ef..4570e36 100644 --- a/support/pork-idea/src/main/kotlin/gay/pizza/pork/idea/PorkSyntaxHighlighter.kt +++ b/support/pork-idea/src/main/kotlin/gay/pizza/pork/idea/PorkSyntaxHighlighter.kt @@ -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) diff --git a/support/pork-idea/src/main/kotlin/gay/pizza/pork/idea/PorkTokenTypes.kt b/support/pork-idea/src/main/kotlin/gay/pizza/pork/idea/PorkTokenTypes.kt index cbe8d89..7f92c35 100644 --- a/support/pork-idea/src/main/kotlin/gay/pizza/pork/idea/PorkTokenTypes.kt +++ b/support/pork-idea/src/main/kotlin/gay/pizza/pork/idea/PorkTokenTypes.kt @@ -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) }