diff --git a/Java/Java.sublime-syntax b/Java/Java.sublime-syntax index 1c93c17c78..9c78615598 100644 --- a/Java/Java.sublime-syntax +++ b/Java/Java.sublime-syntax @@ -162,7 +162,7 @@ contexts: - include: punctuations - include: operators - include: type-comparisons - - include: primitive-types + - include: primitive-maybe-class-literals - include: var-types - include: array-modifiers - include: storage-modifiers @@ -2137,7 +2137,7 @@ contexts: - include: else-pop type-pattern-type: - - include: primitive-maybe-array-type + - include: primitive-maybe-class-literal - include: var-type - match: (?={{identifier}}) set: @@ -3239,20 +3239,37 @@ contexts: ###[ PRIMITIVE TYPES ]######################################################### - primitive-types: + primitive-maybe-class-literals: - match: '{{storage_types}}{{break}}' scope: storage.type.primitive.java - push: maybe-only-array-modifiers + push: maybe-only-class-literal - primitive-type: + primitive-maybe-class-literal: - match: '{{storage_types}}{{break}}' scope: storage.type.primitive.java + set: maybe-only-class-literal + + maybe-only-class-literal: + # https://docs.oracle.com/javase/specs/jls/se13/html/jls-15.html#jls-15.8.2 + - match: '{{single_dot}}' + scope: punctuation.accessor.dot.java + set: maybe-class-literal + - include: array-modifiers + - include: annotation-else-pop + + maybe-class-literal: + - match: class{{break}} + scope: variable.language.class.java pop: 1 + - match: '{{id}}' + scope: invalid.illegal.unexpected-member.java + set: maybe-only-class-literal + - include: else-pop - primitive-maybe-array-type: + primitive-type: - match: '{{storage_types}}{{break}}' scope: storage.type.primitive.java - set: maybe-only-array-modifiers + pop: 1 var-types: - match: var{{break}} @@ -3270,9 +3287,8 @@ contexts: maybe-only-array-modifiers: - include: array-modifiers - - include: annotations - include: illegal-members - - include: else-pop + - include: annotation-else-pop array-modifiers: - match: \[\s*\] diff --git a/Java/tests/syntax_test_java.java b/Java/tests/syntax_test_java.java index 60f00ffd05..1f52b0b0ff 100644 --- a/Java/tests/syntax_test_java.java +++ b/Java/tests/syntax_test_java.java @@ -1941,12 +1941,82 @@ public enum TokenKind extends MyEnum, FooBaz> implements Foo, B // ^ punctuation.section.group.end.java // ^ punctuation.separator.comma.java - integerToken {}; + integerToken {}, // ^^^^^^^^^^^^ meta.constant.identifier.java entity.name.constant.java // ^ meta.constant.identifier.java - constant // ^ meta.constant.java meta.block.java punctuation.section.block.begin.java // ^ meta.constant.java meta.block.java punctuation.section.block.end.java -// ^ punctuation.terminator.java +// ^ punctuation.separator.comma.java + + BYTE (0x01, Byte.FOO, Byte.FOO, Byte[].FOO, byte.FOO, byte[].FOO) {}, +// ^^^^^ meta.constant.identifier.java +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.constant.arguments.java meta.group.java +// ^^^ meta.constant.java +// ^ - meta.constant +// ^^^^ entity.name.constant.java +// ^ punctuation.section.group.begin.java +// ^^^^ meta.number.integer.hexadecimal.java +// ^ punctuation.separator.comma.java +// ^^^^ support.class.java +// ^ punctuation.accessor.dot.java +// ^^^ constant.other.java +// ^ punctuation.separator.comma.java +// ^^^^ support.class.java +// ^ punctuation.accessor.dot.java +// ^^^ constant.other.java +// ^ punctuation.separator.comma.java +// ^^^^ support.class.java +// ^^ storage.modifier.array.java +// ^ punctuation.accessor.dot.java +// ^^^ constant.other.java +// ^ punctuation.separator.comma.java +// ^^^^ storage.type.primitive.java +// ^ punctuation.accessor.dot.java +// ^^^ invalid.illegal.unexpected-member.java +// ^ punctuation.separator.comma.java +// ^^^^ storage.type.primitive.java +// ^^ storage.modifier.array.java +// ^ punctuation.accessor.dot.java +// ^^^ invalid.illegal.unexpected-member.java +// ^ punctuation.section.group.end.java +// ^ meta.block.java punctuation.section.block.begin.java +// ^ meta.block.java punctuation.section.block.end.java +// ^ punctuation.separator.comma.java + + BYTE (0x01, Byte.FOO, Byte.class, Byte[].class, byte.class, byte[].class) {}; +// ^^^^^ meta.constant.identifier.java +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.constant.arguments.java meta.group.java +// ^^^ meta.constant.java +// ^ - meta.constant +// ^^^^ entity.name.constant.java +// ^ punctuation.section.group.begin.java +// ^^^^ meta.number.integer.hexadecimal.java +// ^ punctuation.separator.comma.java +// ^^^^ support.class.java +// ^ punctuation.accessor.dot.java +// ^^^ constant.other.java +// ^ punctuation.separator.comma.java +// ^^^^ support.class.java +// ^ punctuation.accessor.dot.java +// ^^^^^ variable.language.class.java +// ^ punctuation.separator.comma.java +// ^^^^ support.class.java +// ^^ storage.modifier.array.java +// ^ punctuation.accessor.dot.java +// ^^^^^ variable.language.class.java +// ^ punctuation.separator.comma.java +// ^^^^ storage.type.primitive.java +// ^ punctuation.accessor.dot.java +// ^^^^^ variable.language.class.java +// ^ punctuation.separator.comma.java +// ^^^^ storage.type.primitive.java +// ^^ storage.modifier.array.java +// ^ punctuation.accessor.dot.java +// ^^^^^ variable.language.class.java +// ^ punctuation.section.group.end.java +// ^ meta.block.java punctuation.section.block.begin.java +// ^ meta.block.java punctuation.section.block.end.java +// ^ punctuation.terminator.java int {} // ^^^ storage.type.primitive.java