我刚刚意识到以下一行
private final Pattern pattern = Pattern.compile("(a|b)\\d{3}");
被Sublime的Java语法高亮完全误解了。最后一个引号被视为String
的开头,即使它已经结束了。
我该怎么办?
编辑:要重现错误,请在Sublime中尝试以下操作:
public class SublimeBug{
private static final long serialVersionUID = 700308123417786640L;
private final Pattern pattern = Pattern.compile("(a|b)\\d{3}");
private final String a,b,c,d,e;
}
答案 0 :(得分:0)
Sublime Text论坛上的这个错误是brought up in 2012。用户facelessuser发布了一个修复程序,但它看起来还没有进入最新版本的Sublime Text。
从Java.tmLanguage的第425行开始,用这个替换整个“class-body”dict:
<key>class-body</key>
<dict>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#comments</string>
</dict>
<dict>
<key>include</key>
<string>#class</string>
</dict>
<dict>
<key>include</key>
<string>#enums</string>
</dict>
<dict>
<key>begin</key>
<string>=</string>
<key>beginCaptures</key>
<dict>
<key>0</key>
<dict>
<key>name</key>
<string>keyword.operator.assignment.java</string>
</dict>
</dict>
<key>end</key>
<string>;</string>
<key>endCaptures</key>
<dict>
<key>0</key>
<dict>
<key>name</key>
<string>punctuation.terminator.java</string>
</dict>
</dict>
<key>name</key>
<string></string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#code</string>
</dict>
</array>
</dict>
<dict>
<key>include</key>
<string>#methods</string>
</dict>
<dict>
<key>include</key>
<string>#annotations</string>
</dict>
<dict>
<key>include</key>
<string>#storage-modifiers</string>
</dict>
<dict>
<key>include</key>
<string>#code</string>
</dict>
</array>
</dict>