mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-18 03:10:04 -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] [scheme](https://github.com/6cdh/tree-sitter-scheme) (maintained by @6cdh)
|
||||||
- [x] [scss](https://github.com/serenadeai/tree-sitter-scss) (maintained by @elianiva)
|
- [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] [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] [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] [solidity](https://github.com/YongJieYongJie/tree-sitter-solidity) (maintained by @YongJieYongJie)
|
||||||
- [x] [sparql](https://github.com/BonaBeavis/tree-sitter-sparql) (maintained by @BonaBeavis)
|
- [x] [sparql](https://github.com/BonaBeavis/tree-sitter-sparql) (maintained by @BonaBeavis)
|
||||||
|
|
|
||||||
|
|
@ -378,7 +378,7 @@
|
||||||
"revision": "07547525cdf4627343dca5891f1743ae45e879bb"
|
"revision": "07547525cdf4627343dca5891f1743ae45e879bb"
|
||||||
},
|
},
|
||||||
"smali": {
|
"smali": {
|
||||||
"revision": "d7f535e176c928d33b0e202dd808ac247cacf2ff"
|
"revision": "5a742af7388864a3ff2ce8421328a33e7246a2d5"
|
||||||
},
|
},
|
||||||
"smithy": {
|
"smithy": {
|
||||||
"revision": "cf8c7eb9faf7c7049839585eac19c94af231e6a0"
|
"revision": "cf8c7eb9faf7c7049839585eac19c94af231e6a0"
|
||||||
|
|
|
||||||
|
|
@ -1193,11 +1193,10 @@ list.slint = {
|
||||||
|
|
||||||
list.smali = {
|
list.smali = {
|
||||||
install_info = {
|
install_info = {
|
||||||
url = "https://github.com/amaanq/tree-sitter-smali",
|
url = "https://git.sr.ht/~yotam/tree-sitter-smali",
|
||||||
files = { "src/parser.c" },
|
files = { "src/parser.c" },
|
||||||
},
|
},
|
||||||
maintainers = { "@amaanq" },
|
maintainers = { "@amaanq" },
|
||||||
experimental = true,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
list.smithy = {
|
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
|
(primitive_type) @type.builtin
|
||||||
|
|
||||||
(array_type
|
((class_identifier) @type.builtin
|
||||||
"[" @punctuation.bracket)
|
(#vim-match? @type.builtin "^L(android|com/android|dalvik|java)/"))
|
||||||
|
|
||||||
; Methods
|
; Methods
|
||||||
|
|
||||||
(method_declaration
|
(method_definition
|
||||||
(method_identifier) @method)
|
(method_signature (method_identifier) @method))
|
||||||
|
|
||||||
(statement
|
(expression
|
||||||
(opcode) @_invoke
|
(opcode) @_invoke
|
||||||
(full_method_identifier
|
(value
|
||||||
(method_identifier) @method.call)
|
(body
|
||||||
|
(full_method_signature
|
||||||
|
(method_signature (method_identifier) @method.call))))
|
||||||
(#lua-match? @_invoke "^invoke"))
|
(#lua-match? @_invoke "^invoke"))
|
||||||
|
|
||||||
(method_identifier
|
(method_handle
|
||||||
"<init>(" @constructor
|
(full_method_signature
|
||||||
")" @constructor)
|
(method_signature (method_identifier) @method.call)))
|
||||||
|
|
||||||
(method_identifier
|
(call_site) @method.call
|
||||||
"<clinit>(" @constructor
|
|
||||||
")" @constructor)
|
(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
|
; Fields
|
||||||
|
|
||||||
(field_identifier) @field
|
(field_identifier) @field
|
||||||
|
|
||||||
; Parameters
|
(annotation_key) @field
|
||||||
|
|
||||||
(parameter) @parameter
|
|
||||||
|
|
||||||
; Variables
|
; Variables
|
||||||
|
|
||||||
(variable) @variable
|
(variable) @variable.builtin
|
||||||
|
|
||||||
|
(local_directive
|
||||||
|
(identifier) @variable)
|
||||||
|
|
||||||
|
; Parameters
|
||||||
|
|
||||||
|
(parameter) @parameter.builtin
|
||||||
|
(param_identifier) @parameter
|
||||||
|
|
||||||
; Labels
|
; Labels
|
||||||
|
|
||||||
(label) @label
|
[
|
||||||
|
(label)
|
||||||
|
(jmp_label)
|
||||||
|
] @label
|
||||||
|
|
||||||
; Operators
|
; Operators
|
||||||
|
|
||||||
(opcode) @keyword.operator
|
(opcode) @keyword.operator
|
||||||
|
|
||||||
((opcode) @keyword.return
|
((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
|
; Keywords
|
||||||
|
|
||||||
|
|
@ -59,11 +104,20 @@
|
||||||
".source"
|
".source"
|
||||||
".implements"
|
".implements"
|
||||||
".field"
|
".field"
|
||||||
|
".end field"
|
||||||
".annotation"
|
".annotation"
|
||||||
|
".end annotation"
|
||||||
".subannotation"
|
".subannotation"
|
||||||
|
".end subannotation"
|
||||||
".param"
|
".param"
|
||||||
|
".end param"
|
||||||
|
".parameter"
|
||||||
|
".end parameter"
|
||||||
".line"
|
".line"
|
||||||
".locals"
|
".locals"
|
||||||
|
".local"
|
||||||
|
".end local"
|
||||||
|
".restart local"
|
||||||
".registers"
|
".registers"
|
||||||
".catch"
|
".catch"
|
||||||
".catchall"
|
".catchall"
|
||||||
|
|
@ -77,38 +131,53 @@
|
||||||
] @keyword
|
] @keyword
|
||||||
|
|
||||||
[
|
[
|
||||||
(end_field)
|
(prologue_directive)
|
||||||
(end_annotation)
|
(epilogue_directive)
|
||||||
(end_subannotation)
|
|
||||||
(end_param)
|
|
||||||
] @keyword
|
] @keyword
|
||||||
|
|
||||||
[
|
[
|
||||||
".method"
|
".method"
|
||||||
(end_method)
|
".end method"
|
||||||
] @keyword.function
|
] @keyword.function
|
||||||
|
|
||||||
; Literals
|
; 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
|
; Misc
|
||||||
|
|
||||||
(annotation_visibility) @attribute
|
(annotation_visibility) @storageclass
|
||||||
|
|
||||||
(access_modifiers) @type.qualifier
|
(access_modifiers) @type.qualifier
|
||||||
|
|
||||||
|
(array_type
|
||||||
|
"[" @punctuation.special)
|
||||||
|
|
||||||
["{" "}"] @punctuation.bracket
|
["{" "}"] @punctuation.bracket
|
||||||
|
|
||||||
"->" @punctuation.delimiter
|
["(" ")"] @punctuation.bracket
|
||||||
|
|
||||||
|
[
|
||||||
|
"->"
|
||||||
|
":"
|
||||||
|
","
|
||||||
|
"@"
|
||||||
|
] @punctuation.delimiter
|
||||||
|
|
||||||
; Comments
|
; 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