Sublime Forum

Java Syntax Highlighting Issue

#1

Java multiline comments are not parsed correctly by the highlighter in certain cases and this
results in the syntax highlighting of code and comments being mangled. I have only tested
the below code in ST2 and ST3 beta on OSX.

A screenshot of the code in ST3 is up at imgur.com/2RHoeEA.

public class Test {
	/**
	 * This is a clean
	 * comment block.
	 */

	/**
	 * This is a <malformed">
	 * comment highlighting
	 */
	public static void main(String] args){
		func1();
		return;
	}

	/**
	 * ">
	 */
	public static void func1(){
		System.out.println("Hello World!"); func2();
		return;
	}

	/* This is not <malformed"> */
	public static void func2(){
		System.out.println("Hello 2 you"); func3();
		return;
	}

	/**
	 * <notmalformed">
	 * comment highlighting
	 */
	public static void func3(){
		System.out.println("Hi Th3r3"); func4();
		return;
	}

	/*
	 * Not<malformed">
	 * comment highlighting
	 */
	public static void func4(){
		System.out.println("Function 4 you"); func5();
		return;
	}

	/**
	 * Something <strange">
	 * happens
	 */
	public static void func5(){
		System.out.println("When I"); func6();
		return;
	}

	// ">
	public static void func6(){
		System.out.println("do this.");
		return;
	}
}

The code compiles and runs just fine.

$ javac Test.java 
$ java Test 
Hello World!
Hello 2 you
Hi Th3r3
Function 4 you
When I
do this.
0 Likes

#2

Did you ever find a solution to this because I have a similar problem with multi-line split strings:

public static final String THREAD_POOL_INSERT = String.format(
        "INSERT INTO %s.%s (" +
                "node_ip," +
                "pool_name," +
                "active," +
                "pending," +
                "completed," +
                "blocked," +
                "all_time_blocked)" +
                "VALUES (?,?,?,?,?,?,?) " +     <<<<<<-------- Goes wrong at this point
                "USING TTL ? ;",
        KEYSPACE_NAME, THREAD_POOL_TABLE); <<<<<----- From this line onwards it considers everything to be a string constant

This is on ST3 build 3065 running on Linux Mint 17

0 Likes