From 86ef389c0dfc445ba2888a81edcc13113d1638bc Mon Sep 17 00:00:00 2001 From: Gammut Date: Fri, 26 May 2023 16:37:19 -0500 Subject: [PATCH] Highlight query improvements for java and typescript (#7145) * Add missing queries to java highlights * Fix generic type bracket highlights in typescript --- runtime/queries/java/highlights.scm | 83 ++++++++++++++++++++++- runtime/queries/typescript/highlights.scm | 19 ++++-- 2 files changed, 93 insertions(+), 9 deletions(-) diff --git a/runtime/queries/java/highlights.scm b/runtime/queries/java/highlights.scm index f049b8d25..ae99a33ab 100644 --- a/runtime/queries/java/highlights.scm +++ b/runtime/queries/java/highlights.scm @@ -13,8 +13,6 @@ (marker_annotation name: (identifier) @attribute) -"@" @operator - ; Types (interface_declaration @@ -48,6 +46,9 @@ (void_type) ] @type.builtin +(type_arguments + (wildcard "?" @type.builtin)) + ; Variables ((identifier) @constant @@ -87,6 +88,84 @@ (line_comment) @comment (block_comment) @comment +; Punctuation + +[ + "::" + "." + ";" + "," +] @punctuation.delimiter + +[ + "@" + "..." +] @punctuation.special + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +(type_arguments + [ + "<" + ">" + ] @punctuation.bracket) + +(type_parameters + [ + "<" + ">" + ] @punctuation.bracket) + +; Operators + +[ + "=" + ">" + "<" + "!" + "~" + "?" + ":" + "->" + "==" + ">=" + "<=" + "!=" + "&&" + "||" + "++" + "--" + "+" + "-" + "*" + "/" + "&" + "|" + "^" + "%" + "<<" + ">>" + ">>>" + "+=" + "-=" + "*=" + "/=" + "&=" + "|=" + "^=" + "%=" + "<<=" + ">>=" + ">>>=" +] @operator + ; Keywords [ diff --git a/runtime/queries/typescript/highlights.scm b/runtime/queries/typescript/highlights.scm index fc8d110d1..3ab9c7466 100644 --- a/runtime/queries/typescript/highlights.scm +++ b/runtime/queries/typescript/highlights.scm @@ -5,7 +5,6 @@ (ambient_declaration "global" @namespace) - ; Variables (required_parameter (identifier) @variable.parameter) @@ -22,8 +21,6 @@ (conditional_type ["?" ":"] @operator) - - ; Keywords [ @@ -50,16 +47,22 @@ "readonly" ] @keyword.storage.modifier -; inherits: ecma - ; Types (type_identifier) @type (predefined_type) @type.builtin (type_arguments - "<" @punctuation.bracket - ">" @punctuation.bracket) + [ + "<" + ">" + ] @punctuation.bracket) + +(type_parameters + [ + "<" + ">" + ] @punctuation.bracket) ((identifier) @type (#match? @type "^[A-Z]")) @@ -75,3 +78,5 @@ (template_type "${" @punctuation.special "}" @punctuation.special) @embedded + +; inherits: ecma