jskinner / DefaultPackages

Old bug tracker for Sublime Text's "Default Packages", e.g. bad syntax highlighting
http://web.archive.org/web/20150524043750/https://www.sublimetext.com/forum/viewtopic.php?f=2&t=12095
26 stars 2 forks source link

Java syntax highlighting broken when calling a method in field initialization #139

Closed codeman38 closed 8 years ago

codeman38 commented 9 years ago

The following Java snippet breaks Sublime Text's syntax highlighter:

import java.util.regex.Pattern;

public class SyntaxHighlightingTest {
    private static final Pattern failRegex = Pattern.compile("(\\w+)\\}");

    public static void main(String[] args) {
        System.out.println("Watch out for those brackets!");
    }
}

Here's how Sublime Text renders that:

highlightfail

codeman38 commented 9 years ago

Playing around with this further, it looks like this is a more generalized issue with calling methods in field initializers. The grammar is wrongly interpreting what's to the right of the equal sign as a method declaration, rather than a call.

You can see this to a less dramatic extent with:

public class SyntaxHighlightingTest2 {
    private static Thing thing = ThingFactory.makeThing("This is a TEST!");
}
FichteFoll commented 8 years ago

Closing this as duplicate since https://github.com/SublimeTextIssues/DefaultPackages/issues/172 has more details.

It has been fixed anyway.