Closed FichteFoll closed 8 years ago
I have a fix, but I don't seem to be able to apply it in Sublime Text in a way that it'll take notice.
ST3 actually gets its Java language grammar and highlighting from the Textmate Java bundle. I was able to fix the issue there with a regex change in the Syntaxes/Java.plist
file.
In the anonymous-classes-and-new
section, edit the begin
regex
from:
begin = '\bnew\b';
to
begin = '\b(?<!::)new\b';
Which makes it ignore the new
keyword when it's prefixed by two colons. This appears to fix it for me in TextMate if I make the change in the Bundle Editor but I don't seem to have the knack of applying a fixed bundle myself. As TextMate isn't my main editor, I don't propose to work hard at finding out why. No, I think I just have found out why; it's an XML file, I needed to entityise the <
in the regex!
The equivalent file in ST3 is: Packages/Java/Java.tmLanguage
. However, making that same change (and entityising the <
this time!) is being simply ignored. I deleted the cache files but I note the Java.tmLanguage.cache and .rcache files aren't being recreated. There's presumably something I've done to offend it but I can't see it, the change is just being silently ignored. There is a Java.sublime-syntax.cache and .rcache file pair, but I can't see any Java.sublime-syntax original anywhere. So if those are being generated out of the .tmLanguage file, I don't know why it's ignoring the change that works in Textmate.
I'm pretty sure this is the fix though, it's just how to apply fixes, both to this and the TextMate bundles system that seems to be unnecessarily difficult.
EDIT: TextMate Issue here: https://github.com/textmate/java.tmbundle/issues/37
EDIT: Fixed for me by moving my changed Java.tmLanguage file into Packages/User where it probably always should have been! :-} And it works.
@StrangeNoises, you can also file a pull request now to the official repository of ST's shipped packages: https://github.com/sublimehq/Packages
Note the new format however.
Yes I did just note the new format, now there is a Java.sublime-syntax instead. But I was able to make the same change in the equivalent place there, and it's working for me. Expect a PR soon (just got to check that procedure that I do it right...)
... and done: https://github.com/sublimehq/Packages/pull/89
@FichteFoll I believe you can close this now.
System.out::println
seems to not be an issue, butArrayList::new
is, seemingly because "new" is also a keyword.Okay:
Broken:
Mirror from http://www.sublimetext.com/forum/viewtopic.php?f=3&t=18921