Sublime Forum

Java 8 syntax highlighting error

#1

This is Sublime Text 3 - Build 3083 - on Mac OS X 10.10.3.

EDIT: Later confirmed still exactly the same in 3092.

Consider the following contrived trivial program:

(Oh great, your Preview button is unresponsive in Firefox. Continuing in Safari…)

In the above screenshot, everything about syntax colouring is fine. But if I make a simple change, to make it explicitly put the arguments in an ArrayList:

Suddenly, Sublime Text cannot any longer recognise any methods in the source file below that use of ArrayList::new The method names do not show in colour, and nor does it show on the list of methods found by cmd-R. Which in some real-world situations makes things less useful.

Note that in the first screenshot, the existence of that System.out::println seems to be unproblematic. The syntax recognition of the method below it is unaffected.

My guess is that SublimeText is having a problem with this aspect of the new Java 8 functional programming features; specifically the appearance of the keyword ‘new’ where it presumably wasn’t expected, given it seems to be tolerating the ‘System.out::println’ and other method names.

Both of the above examples compile and run just fine. Here is the code by the way, for ease of pasting to try it yourselves:

[code]import java.util.;
import java.util.stream.
;

/*
Lines entered so screenshot
can show the list of methods
*/

public class SyntaxTest {
public static void main(String… args) {
printList(Arrays.stream(args)
.collect(Collectors.toCollection(ArrayList::new)));
anotherMethod();
}

private static void printList(List<String> args) {
	args.stream().forEach(System.out::println);
}

private static void anotherMethod() {

}

}[/code]

0 Likes

#2

Mirrored at github.com/SublimeTextIssues/De … issues/140

0 Likes