Skip to content

Commit 20c2efc

Browse files
Support for Jetbrains plugin special marks
Supported markers: - <caret> - <error> - <fold>
1 parent 3b6d462 commit 20c2efc

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ dependencies {
3232
exclude group: 'com.jetbrains'
3333
}
3434
compile 'com.google.guava:guava:21.0'
35-
compile 'io.protostuff:protostuff-parser:2.1.11'
35+
compile 'io.protostuff:protostuff-parser:2.1.12'
3636
}
3737

3838
apply plugin: 'idea'

src/main/java/io/protostuff/jetbrains/plugin/ProtoParserDefinition.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import static io.protostuff.compiler.parser.ProtoLexer.COMMENT;
44
import static io.protostuff.compiler.parser.ProtoLexer.LINE_COMMENT;
55
import static io.protostuff.compiler.parser.ProtoLexer.NL;
6+
import static io.protostuff.compiler.parser.ProtoLexer.PLUGIN_DEV_MARKER;
67
import static io.protostuff.compiler.parser.ProtoLexer.STRING_VALUE;
78
import static io.protostuff.compiler.parser.ProtoLexer.WS;
89
import static io.protostuff.compiler.parser.ProtoParser.RULE_customFieldReference;
@@ -199,7 +200,8 @@ public class ProtoParserDefinition implements ParserDefinition {
199200
);
200201
public static final TokenSet COMMENT_TOKEN_SET = ELEMENT_FACTORY.createTokenSet(
201202
ProtoLexer.COMMENT,
202-
ProtoLexer.LINE_COMMENT
203+
ProtoLexer.LINE_COMMENT,
204+
ProtoLexer.PLUGIN_DEV_MARKER
203205
);
204206
public static final TokenSet LITERAL_TOKEN_SET = ELEMENT_FACTORY.createTokenSet(
205207
ProtoLexer.STRING_VALUE,
@@ -267,7 +269,7 @@ public class ProtoParserDefinition implements ParserDefinition {
267269
public static final IElementType R_FIELD_NAME = RULE_TYPES.get(RULE_fieldName);
268270
public static final IElementType R_TAG = RULE_TYPES.get(RULE_tag);
269271
private static final IFileElementType FILE = new IFileElementType(ProtoLanguage.INSTANCE);
270-
private static final TokenSet COMMENTS = ELEMENT_FACTORY.createTokenSet(COMMENT, LINE_COMMENT);
272+
private static final TokenSet COMMENTS = ELEMENT_FACTORY.createTokenSet(COMMENT, LINE_COMMENT, PLUGIN_DEV_MARKER);
271273
private static final TokenSet STRING = ELEMENT_FACTORY.createTokenSet(STRING_VALUE);
272274
private final Map<Integer, Function<ASTNode, AntlrPsiNode>> elementFactories = new HashMap<>();
273275

src/main/java/io/protostuff/jetbrains/plugin/ProtoSyntaxHighlighter.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ public class ProtoSyntaxHighlighter extends SyntaxHighlighterBase {
4747
createTextAttributesKey("PROTO_BLOCK_COMMENT", DefaultLanguageHighlighterColors.BLOCK_COMMENT);
4848
static final TextAttributesKey ENUM_CONSTANT =
4949
createTextAttributesKey("PROTO_ENUM_CONSTANT", DefaultLanguageHighlighterColors.CONSTANT);
50+
static final TextAttributesKey METADATA =
51+
createTextAttributesKey("PROTO_METADATA", DefaultLanguageHighlighterColors.METADATA);
5052

5153
private static final TextAttributesKey[] EMPTY_KEYS = new TextAttributesKey[0];
5254

@@ -80,6 +82,9 @@ public TextAttributesKey[] getTokenHighlights(IElementType tokenType) {
8082
case ProtoLexer.LINE_COMMENT:
8183
attrKey = LINE_COMMENT;
8284
break;
85+
case ProtoLexer.PLUGIN_DEV_MARKER:
86+
attrKey = METADATA;
87+
break;
8388
default:
8489
return EMPTY_KEYS;
8590
}

0 commit comments

Comments
 (0)