Skip to content

Commit dafb5c9

Browse files
committed
Improve AT lexer to handle really bad naming
If some poor unfortunate soul tires to use Spigot mappings in an AT file they'll find highlighting doesn't work right. This commit should fix that. The regex for class names and field names has also been expanded to more correctly accept unicode identifiers and non dollar sign currency symbols.
1 parent cf6e5f0 commit dafb5c9

File tree

4 files changed

+28
-16
lines changed

4 files changed

+28
-16
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ ideaVersion = 2018.2
1313

1414
name = MinecraftDev
1515
group = com.demonwav.minecraft-dev
16-
version = 2018.2-1.2.9
16+
version = 2018.2-1.2.10
1717
downloadIdeaSources = true

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Minecraft Development for IntelliJ
1111
| **Travis (macOS)** |[![Travis macOS Build Status](https://travis-matrix-badges.herokuapp.com/repos/minecraft-dev/MinecraftDev/branches/dev/2)](https://travis-ci.org/minecraft-dev/MinecraftDev/)|
1212
| **TeamCity (Windows)** |[![TeamCity Windows Build Status](https://tc.demonwav.com/app/rest/builds/buildType:(id:MinecraftDev_WindowsBuild)/statusIcon)](https://ci.demonwav.com/viewType.html?buildTypeId=MinecraftDev_WindowsBuild)|
1313

14-
Info and Documentation [![Current Release](https://img.shields.io/badge/release-2018.2--1.2.9-orange.svg?style=flat-square)](https://plugins.jetbrains.com/plugin/8327)
14+
Info and Documentation [![Current Release](https://img.shields.io/badge/release-2018.2--1.2.10-orange.svg?style=flat-square)](https://plugins.jetbrains.com/plugin/8327)
1515
----------------------
1616

1717
<a href="https://discord.gg/j6UNcfr"><img src="https://i.imgur.com/JXu9C1G.png" height="48px"></img></a>

src/main/grammars/AtLexer.flex

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,34 +28,46 @@ import static com.intellij.psi.TokenType.*;
2828
%implements FlexLexer
2929
%function advance
3030
%type IElementType
31+
32+
%s CLASS_NAME
33+
%s MEMBER_NAME
34+
%s TYPES
35+
3136
%unicode
3237

3338
PRIMITIVE=[ZBCSIFDJV]
34-
CLASS_VALUE=\[*([ZBCSIFDJ]|L[^;\n]+;)
39+
CLASS_VALUE=(\[+[ZBCSIFDJ]|(\[*L[^;\n]+;))
3540
KEYWORD_ELEMENT=(public|private|protected|default)([-+]f)?
36-
NAME_ELEMENT=[a-zA-Z0-9_]+|<init>
37-
CLASS_NAME_ELEMENT=[a-zA-Z_$0-9\.]*[a-zA-Z_$0-9]
41+
NAME_ELEMENT=([\p{L}_\p{Sc}][\p{L}\p{N}_\p{Sc}]*)|<init>
42+
CLASS_NAME_ELEMENT=([\p{L}_\p{Sc}][\p{L}\p{N}_\p{Sc}]*\.)*[\p{L}_\p{Sc}][\p{L}\p{N}_\p{Sc}]*
3843
COMMENT=#.*
3944
CRLF=\n|\r|\r\n
4045
WHITE_SPACE=\s
4146

4247
%%
4348

4449
<YYINITIAL> {
45-
{CRLF} { return CRLF; }
46-
{WHITE_SPACE} { return WHITE_SPACE; }
50+
{KEYWORD_ELEMENT} { yybegin(CLASS_NAME); return KEYWORD_ELEMENT; }
51+
}
4752

48-
"(" { return OPEN_PAREN; }
49-
")" { return CLOSE_PAREN; }
50-
"*" | "*()" { return ASTERISK_ELEMENT; }
53+
<CLASS_NAME> {
54+
{CLASS_NAME_ELEMENT} { yybegin(MEMBER_NAME); return CLASS_NAME_ELEMENT; }
55+
}
5156

52-
{PRIMITIVE} ({PRIMITIVE}|{CLASS_VALUE})* { zzMarkedPos = zzStartRead + 1; return PRIMITIVE; }
57+
<MEMBER_NAME> {
58+
"*" | "*()" { return ASTERISK_ELEMENT; }
59+
{NAME_ELEMENT} { yybegin(TYPES); return NAME_ELEMENT; }
60+
}
5361

62+
<TYPES> {
63+
"(" { return OPEN_PAREN; }
64+
")" { return CLOSE_PAREN; }
5465
{CLASS_VALUE} { return CLASS_VALUE; }
55-
{KEYWORD_ELEMENT} { return KEYWORD_ELEMENT; }
56-
{NAME_ELEMENT} { return NAME_ELEMENT; }
57-
{CLASS_NAME_ELEMENT} { return CLASS_NAME_ELEMENT; }
58-
{COMMENT} { return COMMENT; }
66+
{PRIMITIVE} ({PRIMITIVE}|{CLASS_VALUE})* { zzMarkedPos = zzStartRead + 1; return PRIMITIVE; }
5967
}
6068

69+
{CRLF} { yybegin(YYINITIAL); return CRLF; }
70+
{WHITE_SPACE} { return WHITE_SPACE; }
71+
72+
{COMMENT} { return COMMENT; }
6173
[^] { return BAD_CHARACTER; }

src/main/resources/META-INF/plugin.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
<div>
2929
Please report issues to <a href="https://github.com/minecraft-dev/MinecraftDev/issues">the issue tracker</a>!
3030
<p>
31-
v. 2018.2-1.2.9
31+
v. 2018.2-1.2.10
3232
</div>
3333
]]>
3434
</change-notes>

0 commit comments

Comments
 (0)