feat!: drop modules, general refactor and cleanup

This commit is contained in:
Christian Clason 2023-06-12 09:54:30 -06:00
parent c13e28f894
commit 2c8f2f2fad
829 changed files with 4905 additions and 8010 deletions

View file

@ -0,0 +1,7 @@
[
(block)
(class_body)
(constructor_declaration)
(argument_list)
(annotation_argument_list)
] @fold

View file

@ -0,0 +1,298 @@
; CREDITS @maxbrunsfeld (maxbrunsfeld@gmail.com)
; Variables
(identifier) @variable
; Methods
(method_declaration
name: (identifier) @method)
(method_invocation
name: (identifier) @method.call)
(super) @function.builtin
; Parameters
(formal_parameter
name: (identifier) @parameter)
(catch_formal_parameter
name: (identifier) @parameter)
(spread_parameter
(variable_declarator
name: (identifier) @parameter)) ; int... foo
;; Lambda parameter
(inferred_parameters (identifier) @parameter) ; (x,y) -> ...
(lambda_expression
parameters: (identifier) @parameter) ; x -> ...
; Annotations
(annotation
name: (identifier) @attribute)
(marker_annotation
name: (identifier) @attribute)
; Operators
[
"@"
"+"
":"
"++"
"-"
"--"
"&"
"&&"
"|"
"||"
"!"
"!="
"=="
"*"
"/"
"%"
"<"
"<="
">"
">="
"="
"-="
"+="
"*="
"/="
"%="
"->"
"^"
"^="
"&="
"|="
"~"
">>"
">>>"
"<<"
"::"
] @operator
; Types
(interface_declaration
name: (identifier) @type)
(annotation_type_declaration
name: (identifier) @type)
(class_declaration
name: (identifier) @type)
(record_declaration
name: (identifier) @type)
(enum_declaration
name: (identifier) @type)
(constructor_declaration
name: (identifier) @type)
(type_identifier) @type
((method_invocation
object: (identifier) @type)
(#lua-match? @type "^[A-Z]"))
((method_reference
. (identifier) @type)
(#lua-match? @type "^[A-Z]"))
((field_access
object: (identifier) @type)
(#lua-match? @type "^[A-Z]"))
((scoped_identifier
scope: (identifier) @type)
(#lua-match? @type "^[A-Z]"))
; Fields
(field_declaration
declarator: (variable_declarator
name: (identifier) @field))
(field_access
field: (identifier) @field)
[
(boolean_type)
(integral_type)
(floating_point_type)
(void_type)
] @type.builtin
; Variables
((identifier) @constant
(#lua-match? @constant "^[A-Z_][A-Z%d_]+$"))
(this) @variable.builtin
; Literals
(string_literal) @string
(escape_sequence) @string.escape
(character_literal) @character
[
(hex_integer_literal)
(decimal_integer_literal)
(octal_integer_literal)
(binary_integer_literal)
] @number
[
(decimal_floating_point_literal)
(hex_floating_point_literal)
] @float
[
(true)
(false)
] @boolean
(null_literal) @constant.builtin
; Keywords
[
"assert"
"class"
"record"
"default"
"enum"
"extends"
"implements"
"instanceof"
"interface"
"@interface"
"permits"
"to"
"with"
] @keyword
(synchronized_statement
"synchronized" @keyword)
[
"abstract"
"final"
"native"
"non-sealed"
"open"
"private"
"protected"
"public"
"sealed"
"static"
"strictfp"
"transitive"
] @type.qualifier
(modifiers
"synchronized" @type.qualifier)
[
"transient"
"volatile"
] @storageclass
[
"return"
"yield"
] @keyword.return
[
"new"
] @keyword.operator
; Conditionals
[
"if"
"else"
"switch"
"case"
] @conditional
(ternary_expression ["?" ":"] @conditional.ternary)
; Loops
[
"for"
"while"
"do"
"continue"
"break"
] @repeat
; Includes
[
"exports"
"import"
"module"
"opens"
"package"
"provides"
"requires"
"uses"
] @include
; Punctuation
[
";"
"."
"..."
","
] @punctuation.delimiter
[ "{" "}" ] @punctuation.bracket
[ "[" "]" ] @punctuation.bracket
[ "(" ")" ] @punctuation.bracket
(type_arguments [ "<" ">" ] @punctuation.bracket)
(type_parameters [ "<" ">" ] @punctuation.bracket)
(string_interpolation [ "\\{" "}" ] @punctuation.special)
; Exceptions
[
"throw"
"throws"
"finally"
"try"
"catch"
] @exception
; Labels
(labeled_statement
(identifier) @label)
; Comments
[
(line_comment)
(block_comment)
] @comment @spell
((block_comment) @comment.documentation
(#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$"))
((line_comment) @comment.documentation
(#lua-match? @comment.documentation "^///[^/]"))
((line_comment) @comment.documentation
(#lua-match? @comment.documentation "^///$"))

View file

@ -0,0 +1,37 @@
[
; ... refers to the portion that this indent query will have effects on
(class_body) ; { ... } of `class X`
(enum_body) ; { ... } of `enum X`
(interface_body) ; { ... } of `interface X`
(constructor_body) ; { `modifier` X() {...} } inside `class X`
(annotation_type_body) ; { ... } of `@interface X`
(block) ; { ... } that's not mentioned in this scope
(switch_block) ; { ... } in `switch X`
(array_initializer) ; [1, 2]
(argument_list) ; foo(...)
(formal_parameters) ; method foo(...)
(annotation_argument_list) ; @Annotation(...)
(element_value_array_initializer) ; { a, b } inside @Annotation()
] @indent.begin
(expression_statement (method_invocation) @indent.begin)
[
"("
")"
"{"
"}"
"["
"]"
] @indent.branch
(annotation_argument_list ")" @indent.end) ; This should be a special cased as `()` here doesn't have ending `;`
"}" @indent.end
(line_comment) @indent.ignore
[
(ERROR)
(block_comment)
] @indent.auto

View file

@ -0,0 +1,9 @@
([
(block_comment)
(line_comment)
] @injection.content
(#set! injection.language "comment"))
((block_comment) @injection.content
(#lua-match? @injection.content "/[*][!<*][^a-zA-Z]")
(#set! injection.language "doxygen"))

View file

@ -0,0 +1,89 @@
;; SCOPES
; declarations
(program) @scope
(class_declaration
body: (_) @scope)
(record_declaration
body: (_) @scope)
(enum_declaration
body: (_) @scope)
(lambda_expression) @scope
(enhanced_for_statement) @scope
; block
(block) @scope
; if/else
(if_statement) @scope ; if+else
(if_statement
consequence: (_) @scope) ; if body in case there are no braces
(if_statement
alternative: (_) @scope) ; else body in case there are no braces
; try/catch
(try_statement) @scope ; covers try+catch, individual try and catch are covered by (block)
(catch_clause) @scope ; needed because `Exception` variable
; loops
(for_statement) @scope ; whole for_statement because loop iterator variable
(for_statement ; "for" body in case there are no braces
body: (_) @scope)
(do_statement
body: (_) @scope)
(while_statement
body: (_) @scope)
; Functions
(constructor_declaration) @scope
(method_declaration) @scope
;; DEFINITIONS
(package_declaration
(identifier) @definition.namespace)
(class_declaration
name: (identifier) @definition.type)
(record_declaration
name: (identifier) @definition.type)
(enum_declaration
name: (identifier) @definition.enum)
(method_declaration
name: (identifier) @definition.method)
(local_variable_declaration
declarator: (variable_declarator
name: (identifier) @definition.var))
(enhanced_for_statement ; for (var item : items) {
name: (identifier) @definition.var)
(formal_parameter
name: (identifier) @definition.parameter)
(catch_formal_parameter
name: (identifier) @definition.parameter)
(inferred_parameters (identifier) @definition.parameter) ; (x,y) -> ...
(lambda_expression
parameters: (identifier) @definition.parameter) ; x -> ...
((scoped_identifier
(identifier) @definition.import)
(#has-ancestor? @definition.import import_declaration))
(field_declaration
declarator: (variable_declarator
name: (identifier) @definition.field))
;; REFERENCES
(identifier) @reference
(type_identifier) @reference