Sublime Forum

Bad Syntax highlighting in Java?

#1

foo.java, the syntax highlighting with the quotes is incorrect:

private class foo { bar(String arg) { try { doSomething(arg); } catch (Exception e) { throw new IllegalArgumentException ("You did something wrong: " + bar + " (example: baz)"); } alwaysDo(); } }

The string color starts at the last " and continues to the end of the line, instead of what is appropriate (where the two strings are what is highlighted). This works correctly if the syntax is changed to C++. My syntax is set as Java > Java (on Ubuntu 12.04, ST3 Stable build 3059.)

is this a known issue? Is there a workaround (editing the syntax definition somewhere?)

1 Like

#2

Found this as well. It’s when the opening parentheses of the constructor is on the next line.

to reproduce, try these two to see how the editor behaves. Its worse when there’s brackets in the string.

myVar = new MyClass ("test");

myVar = new MyClass ("test {this}"); System.out.println("test2");

0 Likes

#3

I know it’s been a while since you posted this but I am having the same issue with sublime now and was wondering if you ever found a fix for this issue?

0 Likes

#4

Can’t reproduce any of the issues in this post:

Usually when people are having issues with the syntax definitions, its because they have old and conflicted syntax definitions that are partially-overriding the default.

2 Likes

#5

it’s also possible that the latest Dev build has some fixes/improvements to the Java syntax definition that aren’t in build 3143, you could try following the instructions at https://github.com/sublimehq/Packages to ensure you have the latest changes

0 Likes

#6

Oh wow. I had completely forgotten about this.

I’m using 3143 now. Everything’s fine (haven’t tried it on Ubuntu yet, though I hardly imagine that would make a difference here).

0 Likes