mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-13 17:00:09 -04:00
feat(smali): improve queries
This commit is contained in:
parent
c9d7f9c920
commit
8c4a22fd50
7 changed files with 191 additions and 36 deletions
12
queries/smali/folds.scm
Normal file
12
queries/smali/folds.scm
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
[
|
||||
(annotation_directive)
|
||||
(array_data_directive)
|
||||
(field_definition)
|
||||
(method_definition)
|
||||
(packed_switch_directive)
|
||||
(param_directive)
|
||||
(parameter_directive)
|
||||
(sparse_switch_directive)
|
||||
(subannotation_directive)
|
||||
(list)
|
||||
] @fold
|
||||
|
|
@ -4,52 +4,97 @@
|
|||
|
||||
(primitive_type) @type.builtin
|
||||
|
||||
(array_type
|
||||
"[" @punctuation.bracket)
|
||||
((class_identifier) @type.builtin
|
||||
(#vim-match? @type.builtin "^L(android|com/android|dalvik|java)/"))
|
||||
|
||||
; Methods
|
||||
|
||||
(method_declaration
|
||||
(method_identifier) @method)
|
||||
(method_definition
|
||||
(method_signature (method_identifier) @method))
|
||||
|
||||
(statement
|
||||
(expression
|
||||
(opcode) @_invoke
|
||||
(full_method_identifier
|
||||
(method_identifier) @method.call)
|
||||
(value
|
||||
(body
|
||||
(full_method_signature
|
||||
(method_signature (method_identifier) @method.call))))
|
||||
(#lua-match? @_invoke "^invoke"))
|
||||
|
||||
(method_identifier
|
||||
"<init>(" @constructor
|
||||
")" @constructor)
|
||||
(method_handle
|
||||
(full_method_signature
|
||||
(method_signature (method_identifier) @method.call)))
|
||||
|
||||
(method_identifier
|
||||
"<clinit>(" @constructor
|
||||
")" @constructor)
|
||||
(call_site) @method.call
|
||||
|
||||
(custom_invoke
|
||||
(method_signature (method_identifier) @method.call))
|
||||
|
||||
(annotation_value
|
||||
(body
|
||||
(method_signature (method_identifier) @method.call)))
|
||||
|
||||
(annotation_value
|
||||
(body
|
||||
(full_method_signature
|
||||
(method_signature (method_identifier) @method.call))))
|
||||
|
||||
(field_definition
|
||||
(value
|
||||
(body
|
||||
(method_signature (method_identifier) @method.call))))
|
||||
|
||||
(field_definition
|
||||
(value
|
||||
(body
|
||||
(full_method_signature
|
||||
(method_signature (method_identifier) @method.call)))))
|
||||
|
||||
((method_signature
|
||||
(method_identifier) @constructor)
|
||||
(#any-of? @constructor "<init>" "<clinit>"))
|
||||
|
||||
; Fields
|
||||
|
||||
(field_identifier) @field
|
||||
|
||||
; Parameters
|
||||
|
||||
(parameter) @parameter
|
||||
(annotation_key) @field
|
||||
|
||||
; Variables
|
||||
|
||||
(variable) @variable
|
||||
(variable) @variable.builtin
|
||||
|
||||
(local_directive
|
||||
(identifier) @variable)
|
||||
|
||||
; Parameters
|
||||
|
||||
(parameter) @parameter.builtin
|
||||
(param_identifier) @parameter
|
||||
|
||||
; Labels
|
||||
|
||||
(label) @label
|
||||
[
|
||||
(label)
|
||||
(jmp_label)
|
||||
] @label
|
||||
|
||||
; Operators
|
||||
|
||||
(opcode) @keyword.operator
|
||||
|
||||
((opcode) @keyword.return
|
||||
(#lua-match? @keyword.return "^return"))
|
||||
(#lua-match? @keyword.return "^return"))
|
||||
|
||||
"=" @operator
|
||||
((opcode) @conditional
|
||||
(#vim-match? @conditional "^(if|cmp)"))
|
||||
|
||||
((opcode) @exception
|
||||
(#lua-match? @exception "^throw"))
|
||||
|
||||
[
|
||||
"="
|
||||
".."
|
||||
] @operator
|
||||
|
||||
; Keywords
|
||||
|
||||
|
|
@ -59,11 +104,20 @@
|
|||
".source"
|
||||
".implements"
|
||||
".field"
|
||||
".end field"
|
||||
".annotation"
|
||||
".end annotation"
|
||||
".subannotation"
|
||||
".end subannotation"
|
||||
".param"
|
||||
".end param"
|
||||
".parameter"
|
||||
".end parameter"
|
||||
".line"
|
||||
".locals"
|
||||
".local"
|
||||
".end local"
|
||||
".restart local"
|
||||
".registers"
|
||||
".catch"
|
||||
".catchall"
|
||||
|
|
@ -77,38 +131,53 @@
|
|||
] @keyword
|
||||
|
||||
[
|
||||
(end_field)
|
||||
(end_annotation)
|
||||
(end_subannotation)
|
||||
(end_param)
|
||||
(prologue_directive)
|
||||
(epilogue_directive)
|
||||
] @keyword
|
||||
|
||||
[
|
||||
".method"
|
||||
(end_method)
|
||||
".end method"
|
||||
] @keyword.function
|
||||
|
||||
; Literals
|
||||
|
||||
(string_literal) @string
|
||||
(string) @string
|
||||
(escape_sequence) @string.escape
|
||||
|
||||
(number_literal) @number
|
||||
(character) @character
|
||||
|
||||
(boolean_literal) @boolean
|
||||
(number) @number
|
||||
|
||||
(character_literal) @character
|
||||
[
|
||||
(float)
|
||||
(NaN)
|
||||
(Infinity)
|
||||
] @float
|
||||
|
||||
(null_literal) @constant.builtin
|
||||
(boolean) @boolean
|
||||
|
||||
(null) @constant.builtin
|
||||
|
||||
; Misc
|
||||
|
||||
(annotation_visibility) @attribute
|
||||
(annotation_visibility) @storageclass
|
||||
|
||||
(access_modifiers) @type.qualifier
|
||||
|
||||
(array_type
|
||||
"[" @punctuation.special)
|
||||
|
||||
["{" "}"] @punctuation.bracket
|
||||
|
||||
"->" @punctuation.delimiter
|
||||
["(" ")"] @punctuation.bracket
|
||||
|
||||
[
|
||||
"->"
|
||||
":"
|
||||
","
|
||||
"@"
|
||||
] @punctuation.delimiter
|
||||
|
||||
; Comments
|
||||
|
||||
|
|
|
|||
32
queries/smali/indents.scm
Normal file
32
queries/smali/indents.scm
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
[
|
||||
(annotation_directive)
|
||||
(array_data_directive)
|
||||
(field_definition)
|
||||
(method_definition)
|
||||
(packed_switch_directive)
|
||||
(param_directive)
|
||||
(parameter_directive)
|
||||
(sparse_switch_directive)
|
||||
(subannotation_directive)
|
||||
(list)
|
||||
] @indent
|
||||
|
||||
[
|
||||
".end annotation"
|
||||
".end array-data"
|
||||
".end field"
|
||||
".end method"
|
||||
".end packed-switch"
|
||||
".end param"
|
||||
".end parameter"
|
||||
".end sparse-switch"
|
||||
".end subannotation"
|
||||
"}"
|
||||
] @indent_end
|
||||
|
||||
[ "{" "}" ] @branch
|
||||
|
||||
[
|
||||
(ERROR)
|
||||
(comment)
|
||||
] @auto
|
||||
43
queries/smali/locals.scm
Normal file
43
queries/smali/locals.scm
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
[
|
||||
(class_directive)
|
||||
(expression)
|
||||
(annotation_directive)
|
||||
(array_data_directive)
|
||||
(method_definition)
|
||||
(packed_switch_directive)
|
||||
(sparse_switch_directive)
|
||||
(subannotation_directive)
|
||||
] @scope
|
||||
|
||||
[
|
||||
(identifier)
|
||||
(class_identifier)
|
||||
(call_site)
|
||||
(label)
|
||||
(jmp_label)
|
||||
] @reference
|
||||
|
||||
(enum_reference
|
||||
(field_identifier) @definition.enum)
|
||||
|
||||
((field_definition
|
||||
modifiers: (access_modifiers) @_mod
|
||||
(field_identifier) @definition.enum)
|
||||
(#eq? @_mod "enum"))
|
||||
|
||||
(field_definition
|
||||
(field_identifier) @definition.field
|
||||
(field_type) @definition.associated)
|
||||
|
||||
(annotation_key) @definition.field
|
||||
|
||||
(method_definition
|
||||
(method_signature (method_identifier) @definition.method))
|
||||
|
||||
(param_identifier) @definition.parameter
|
||||
|
||||
(annotation_directive
|
||||
(class_identifier) @definition.type)
|
||||
|
||||
(class_directive
|
||||
(class_identifier) @definition.type)
|
||||
Loading…
Add table
Add a link
Reference in a new issue