From d9639e1e5eeb623c59949cf523681111b71475be Mon Sep 17 00:00:00 2001 From: Chinmay Date: Thu, 11 Jun 2020 22:31:45 +0530 Subject: Add highlights.scm and locals.scm --- queries/java/highlights.scm | 146 ++++++++++++++++++++++++++++++++++++++++++++ queries/java/locals.scm | 8 +++ 2 files changed, 154 insertions(+) create mode 100644 queries/java/highlights.scm create mode 100644 queries/java/locals.scm diff --git a/queries/java/highlights.scm b/queries/java/highlights.scm new file mode 100644 index 000000000..398cfe13f --- /dev/null +++ b/queries/java/highlights.scm @@ -0,0 +1,146 @@ +; Methods + +(method_declaration + name: (identifier) @function.method) +(method_invocation + name: (identifier) @function.method) +(super) @function.builtin + +; Annotations + +(annotation + name: (identifier) @attribute) +(marker_annotation + name: (identifier) @attribute) + +"@" @operator + +; Types + +(interface_declaration + name: (identifier) @type) +(class_declaration + name: (identifier) @type) +(enum_declaration + name: (identifier) @type) + +((field_access + object: (identifier) @type) + (#match? @type "^[A-Z]")) +((scoped_identifier + scope: (identifier) @type) + (#match? @type "^[A-Z]")) + +(constructor_declaration + name: (identifier) @type) + +(type_identifier) @type +(boolean_type) @type.builtin +(integral_type) @type.builtin +(floating_point_type) @type.builtin +(floating_point_type) @type.builtin +(void_type) @type.builtin + +; Variables + +((identifier) @constant + (#match? @constant "^_*[A-Z][A-Z\d_]+")) + +(identifier) @variable + +(this) @variable.builtin + +; Literals + +(hex_integer_literal) @number +(decimal_integer_literal) @number +(octal_integer_literal) @number +(decimal_floating_point_literal) @number +(hex_floating_point_literal) @number +(character_literal) @string +(string_literal) @string +(null_literal) @constant.builtin + +(comment) @comment + +[ +(true) +(false) +] @boolean + +; Keywords + +[ +"abstract" +"assert" +"break" +"catch" +"class" +"continue" +"default" +"do" +"enum" +"exports" +"extends" +"final" +"finally" +"implements" +"instanceof" +"interface" +"module" +"native" +"new" +"open" +"opens" +"package" +"private" +"protected" +"provides" +"public" +"requires" +"return" +"static" +"strictfp" +"synchronized" +"throw" +"throws" +"to" +"transient" +"transitive" +"try" +"uses" +"volatile" +"with" +] @keyword + +; Conditionals + +[ +"if" +"else" +"switch" +"case" +] @conditional + +; + +[ +"for" +"while" +] @repeat + +; + +"import" @include + +; Punctuation + +";" @punctuation.delimiter +"." @punctuation.delimiter +"," @punctuation.delimiter +"[" @punctuation.bracket +"]" @punctuation.bracket +"{" @punctuation.bracket +"}" @punctuation.bracket +"(" @punctuation.bracket +")" @punctuation.bracket diff --git a/queries/java/locals.scm b/queries/java/locals.scm new file mode 100644 index 000000000..9044c98d7 --- /dev/null +++ b/queries/java/locals.scm @@ -0,0 +1,8 @@ +(class_declaration + name: (identifier) @name) @class + +(method_declaration + name: (identifier) @name) @method + +(method_invocation + name: (identifier) @name) @call -- cgit v1.2.3-70-g09d2 From 042464c1c5c4e1a88717430b26347b84a4adcdf0 Mon Sep 17 00:00:00 2001 From: Chinmay Date: Mon, 15 Jun 2020 21:48:50 +0530 Subject: Fix method highlighting --- queries/java/highlights.scm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/queries/java/highlights.scm b/queries/java/highlights.scm index 398cfe13f..59b803abf 100644 --- a/queries/java/highlights.scm +++ b/queries/java/highlights.scm @@ -1,9 +1,9 @@ ; Methods (method_declaration - name: (identifier) @function.method) + name: (identifier) @method) (method_invocation - name: (identifier) @function.method) + name: (identifier) @method) (super) @function.builtin ; Annotations -- cgit v1.2.3-70-g09d2 From d262d4101e55450e8c0092c2131f19e70dc1a261 Mon Sep 17 00:00:00 2001 From: Chinmay Date: Mon, 15 Jun 2020 22:45:56 +0530 Subject: Add operators --- queries/java/highlights.scm | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/queries/java/highlights.scm b/queries/java/highlights.scm index 59b803abf..71e8a74a4 100644 --- a/queries/java/highlights.scm +++ b/queries/java/highlights.scm @@ -13,7 +13,33 @@ (marker_annotation name: (identifier) @attribute) -"@" @operator +; Operators +[ +"@" +"+" +"++" +"-" +"--" +"&" +"&&" +"|" +"||" +"!=" +"==" +"*" +"/" +"%" +"<" +"<=" +">" +">=" +"=" +"-=" +"+=" +"*=" +"/=" +"%=" +] @operator ; Types -- cgit v1.2.3-70-g09d2 From 6a7ad3f01185f1da9a033f909386eb0bca0a6922 Mon Sep 17 00:00:00 2001 From: Chinmay Dalal Date: Mon, 15 Jun 2020 23:12:20 +0530 Subject: Add java to supported languages --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c31ce8985..139214b44 100644 --- a/README.md +++ b/README.md @@ -166,7 +166,7 @@ List of currently supported languages: - [x] html (maintained by @TravonteD) - [ ] csharp - [ ] swift -- [ ] java +- [x] java - [ ] ocaml - [x] css (maintained by @TravonteD) - [ ] julia -- cgit v1.2.3-70-g09d2 From a6c426b2bd60004a3b80e8727d50103747dbd4c0 Mon Sep 17 00:00:00 2001 From: Chinmay Dalal Date: Mon, 15 Jun 2020 23:23:17 +0530 Subject: Fix types --- queries/java/highlights.scm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/queries/java/highlights.scm b/queries/java/highlights.scm index 71e8a74a4..9b4a9555b 100644 --- a/queries/java/highlights.scm +++ b/queries/java/highlights.scm @@ -81,9 +81,9 @@ (hex_integer_literal) @number (decimal_integer_literal) @number (octal_integer_literal) @number -(decimal_floating_point_literal) @number -(hex_floating_point_literal) @number -(character_literal) @string +(decimal_floating_point_literal) @float +(hex_floating_point_literal) @float +(character_literal) @character (string_literal) @string (null_literal) @constant.builtin -- cgit v1.2.3-70-g09d2