More specifically, the following conditions seem to break java syntax highlighting in ST3…
- in-line comments in method signatures
- line comments in signatures
- parameterized annotations in java method signatures
See the examples below, (cut and paste into sublime and compare to the generated markdown below).
Note! I’m using Monokai Extended color scheme, however all the default color schemes I looked at have the same issues.
class Foo {
// Broken! (in-line comment)
public Foo(final String arg1 /*, final int arg2*/ ) {
// ... logic
}
// Broken! (line comment)
public Foo(final String arg1
// the next line is commented out because we don't want to use it yet.
// final int arg2
) {
// ... logic
}
}
-
the in-line comment highlights as though it is code, not a comment
-
the whole whole line text comment is the wrong color
-
the
final int arg2
line is highlighted as though it is code, not a comment -
Other ramifications… The closing braces and parrens are not calculated correctly if a comment contains any. For example change the line comment containing
final int arg2
tofinal int arg2 ) {
. This can cause issues with plugins like MarkdownExtended which does not think the the code block closed and then incorrectly highlights the rest of the page like though it were java. This may actually be an issue with markdown extended, but it is likely related to the internal highlighting, regardless.
class Foo {
// OKAY! (annotated, not parametrized)
public Foo(@Nullable final String arg1) {
// ... logic
}
// BROKEN! (parameterized annotations, added comments also )
public Foo(
/* comment for property; broken with wrong highlighted color */
// also broken
@JsonProperty("something") final String arg1,
/* ;comment for property broken no highlighting at all */
// ;broken comment
@JsonProperty("Test 2") final int arg2
) {
// ... logic
}
}
- the second method’s first argument:
- the annotation argument
"something"
is not higlighted like a String - the class
String
no longer has highlighting - the method argument
arg1
also has no highlighting.
- the annotation argument
- the second method’s second argument:
- now the annotation
@JsonProperty
is a different color - the annotation argument
"Test 2"
has a different annotation entirely it has the sameString arg1
highlighinting in the okay example in the first consturctor. - similarly
int
andarg2
are void of highlighting.
- now the annotation
- adding semi colons within comments can cause subsequent comments to render correctly, but does not fix everything.