mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-01 19:17:02 -04:00
feat(smali): improve queries
This commit is contained in:
parent
c9d7f9c920
commit
8c4a22fd50
7 changed files with 191 additions and 36 deletions
|
|
@ -299,7 +299,7 @@ We are looking for maintainers to add more parsers and to write query files for
|
|||
- [x] [scheme](https://github.com/6cdh/tree-sitter-scheme) (maintained by @6cdh)
|
||||
- [x] [scss](https://github.com/serenadeai/tree-sitter-scss) (maintained by @elianiva)
|
||||
- [x] [slint](https://github.com/jrmoulton/tree-sitter-slint) (experimental, maintained by @jrmoulton)
|
||||
- [x] [smali](https://github.com/amaanq/tree-sitter-smali) (experimental, maintained by @amaanq)
|
||||
- [x] [smali](https://github.com/amaanq/tree-sitter-smali) (maintained by @amaanq)
|
||||
- [x] [smithy](https://github.com/indoorvivants/tree-sitter-smithy) (maintained by @amaanq, @keynmol)
|
||||
- [x] [solidity](https://github.com/YongJieYongJie/tree-sitter-solidity) (maintained by @YongJieYongJie)
|
||||
- [x] [sparql](https://github.com/BonaBeavis/tree-sitter-sparql) (maintained by @BonaBeavis)
|
||||
|
|
|
|||
|
|
@ -378,7 +378,7 @@
|
|||
"revision": "07547525cdf4627343dca5891f1743ae45e879bb"
|
||||
},
|
||||
"smali": {
|
||||
"revision": "d7f535e176c928d33b0e202dd808ac247cacf2ff"
|
||||
"revision": "5a742af7388864a3ff2ce8421328a33e7246a2d5"
|
||||
},
|
||||
"smithy": {
|
||||
"revision": "cf8c7eb9faf7c7049839585eac19c94af231e6a0"
|
||||
|
|
|
|||
|
|
@ -1193,11 +1193,10 @@ list.slint = {
|
|||
|
||||
list.smali = {
|
||||
install_info = {
|
||||
url = "https://github.com/amaanq/tree-sitter-smali",
|
||||
url = "https://git.sr.ht/~yotam/tree-sitter-smali",
|
||||
files = { "src/parser.c" },
|
||||
},
|
||||
maintainers = { "@amaanq" },
|
||||
experimental = true,
|
||||
}
|
||||
|
||||
list.smithy = {
|
||||
|
|
|
|||
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