add smali language support (#9089)
This commit is contained in:
parent
63218a5126
commit
a98b8ddd1a
7 changed files with 317 additions and 0 deletions
|
@ -148,6 +148,7 @@
|
|||
| scheme | ✓ | | ✓ | |
|
||||
| scss | ✓ | | | `vscode-css-language-server` |
|
||||
| slint | ✓ | | ✓ | `slint-lsp` |
|
||||
| smali | ✓ | | ✓ | |
|
||||
| smithy | ✓ | | | `cs` |
|
||||
| sml | ✓ | | | |
|
||||
| solidity | ✓ | | | `solc` |
|
||||
|
|
|
@ -956,6 +956,19 @@ indent = { tab-width = 2, unit = " " }
|
|||
name = "java"
|
||||
source = { git = "https://github.com/tree-sitter/tree-sitter-java", rev = "09d650def6cdf7f479f4b78f595e9ef5b58ce31e" }
|
||||
|
||||
[[language]]
|
||||
name = "smali"
|
||||
scope = "source.smali"
|
||||
injection-regex = "smali"
|
||||
file-types = ["smali"]
|
||||
comment-token = "#"
|
||||
roots = []
|
||||
indent = { tab-width = 4, unit = " " }
|
||||
|
||||
[[grammar]]
|
||||
name = "smali"
|
||||
source = { git = "https://github.com/amaanq/tree-sitter-smali", rev = "5ae51e15c4d1ac93cba6127caf3d1f0a072c140c" }
|
||||
|
||||
[[language]]
|
||||
name = "ledger"
|
||||
scope = "source.ledger"
|
||||
|
|
12
runtime/queries/smali/folds.scm
Normal file
12
runtime/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
|
216
runtime/queries/smali/highlights.scm
Normal file
216
runtime/queries/smali/highlights.scm
Normal file
|
@ -0,0 +1,216 @@
|
|||
; Types
|
||||
|
||||
(class_identifier
|
||||
(identifier) @type)
|
||||
|
||||
(primitive_type) @type.builtin
|
||||
|
||||
((class_identifier
|
||||
. (identifier) @_first @type.builtin
|
||||
(identifier) @type.builtin)
|
||||
(#match? @_first "^(android|dalvik|java|kotlinx)$"))
|
||||
|
||||
((class_identifier
|
||||
. (identifier) @_first @type.builtin
|
||||
. (identifier) @_second @type.builtin
|
||||
(identifier) @type.builtin)
|
||||
(#eq? @_first "com")
|
||||
(#match? @_second "^(android|google)$"))
|
||||
|
||||
; Methods
|
||||
|
||||
(method_definition
|
||||
(method_signature (method_identifier) @function.method))
|
||||
|
||||
(expression
|
||||
(opcode) @_invoke
|
||||
(body
|
||||
(full_method_signature
|
||||
(method_signature (method_identifier) @function.method)))
|
||||
(#match? @_invoke "^invoke"))
|
||||
|
||||
(expression
|
||||
(opcode) @_field_access
|
||||
(body
|
||||
(field_identifier) @variable.other.member)
|
||||
(#match? @_field_access "^[is](get|put)-"))
|
||||
|
||||
(method_handle
|
||||
(full_method_signature
|
||||
(method_signature (method_identifier) @function.method)))
|
||||
|
||||
(custom_invoke
|
||||
. (identifier) @function.method
|
||||
(method_signature (method_identifier) @function.method))
|
||||
|
||||
(annotation_value
|
||||
(body
|
||||
(method_signature (method_identifier) @function.method)))
|
||||
|
||||
(annotation_value
|
||||
(body
|
||||
(full_method_signature
|
||||
(method_signature (method_identifier) @function.method))))
|
||||
|
||||
(field_definition
|
||||
(body
|
||||
(method_signature (method_identifier) @function.method)))
|
||||
|
||||
(field_definition
|
||||
(body
|
||||
(full_method_signature
|
||||
(method_signature (method_identifier) @function.method))))
|
||||
|
||||
((method_identifier) @constructor
|
||||
(#match? @constructor "^(<init>|<clinit>)$"))
|
||||
|
||||
"constructor" @constructor
|
||||
|
||||
; Fields
|
||||
|
||||
[
|
||||
(field_identifier)
|
||||
(annotation_key)
|
||||
] @variable.other.member
|
||||
|
||||
((field_identifier) @constant
|
||||
(#match? @constant "^[%u_]*$"))
|
||||
|
||||
; Variables
|
||||
|
||||
(variable) @variable.builtin
|
||||
|
||||
(local_directive
|
||||
(identifier) @variable)
|
||||
|
||||
; Parameters
|
||||
|
||||
(parameter) @variable.parameter
|
||||
(param_identifier) @variable.parameter
|
||||
|
||||
; Labels
|
||||
|
||||
[
|
||||
(label)
|
||||
(jmp_label)
|
||||
] @label
|
||||
|
||||
; Operators
|
||||
|
||||
; (opcode) @keyword.operator
|
||||
|
||||
((opcode) @keyword.control.return
|
||||
(#match? @keyword.control.return "^return"))
|
||||
|
||||
((opcode) @keyword.control.conditional
|
||||
(#match? @keyword.control.conditional "^if"))
|
||||
|
||||
((opcode) @keyword.control.conditional
|
||||
(#match? @keyword.control.conditional "^cmp"))
|
||||
|
||||
((opcode) @keyword.control.exception
|
||||
(#match? @keyword.control.exception "^throw"))
|
||||
|
||||
[
|
||||
"="
|
||||
".."
|
||||
] @operator
|
||||
|
||||
; Keywords
|
||||
|
||||
[
|
||||
".class"
|
||||
".super"
|
||||
".implements"
|
||||
".field"
|
||||
".end field"
|
||||
".annotation"
|
||||
".end annotation"
|
||||
".subannotation"
|
||||
".end subannotation"
|
||||
".param"
|
||||
".end param"
|
||||
".parameter"
|
||||
".end parameter"
|
||||
".local"
|
||||
".end local"
|
||||
".restart local"
|
||||
".registers"
|
||||
".packed-switch"
|
||||
".end packed-switch"
|
||||
".sparse-switch"
|
||||
".end sparse-switch"
|
||||
".array-data"
|
||||
".end array-data"
|
||||
".enum"
|
||||
(prologue_directive)
|
||||
(epilogue_directive)
|
||||
] @keyword
|
||||
|
||||
[
|
||||
".source"
|
||||
] @keyword.directive
|
||||
|
||||
[
|
||||
".method"
|
||||
".end method"
|
||||
] @keyword.function
|
||||
|
||||
[
|
||||
".catch"
|
||||
".catchall"
|
||||
] @keyword.control.exception
|
||||
|
||||
; Literals
|
||||
|
||||
(string) @string
|
||||
(source_directive (string "\"" _ @string.special.url "\""))
|
||||
(escape_sequence) @constant.character.escape
|
||||
|
||||
(character) @constant.character
|
||||
|
||||
"L" @punctuation
|
||||
|
||||
(line_directive (number) @comment) @comment
|
||||
(".locals" (number) @comment) @comment
|
||||
|
||||
(number) @constant.numeric.integer
|
||||
|
||||
[
|
||||
(float)
|
||||
(NaN)
|
||||
(Infinity)
|
||||
] @constant.numeric.float
|
||||
|
||||
(boolean) @constant.builtin.boolean
|
||||
|
||||
(null) @constant.builtin
|
||||
|
||||
; Misc
|
||||
|
||||
(annotation_visibility) @keyword.storage.modifier
|
||||
|
||||
(access_modifier) @keyword.storage.type
|
||||
|
||||
(array_type
|
||||
"[" @punctuation.special)
|
||||
|
||||
["{" "}"] @punctuation.bracket
|
||||
|
||||
["(" ")"] @punctuation.bracket
|
||||
|
||||
[
|
||||
"->"
|
||||
","
|
||||
":"
|
||||
";"
|
||||
"@"
|
||||
"/"
|
||||
] @punctuation.delimiter
|
||||
|
||||
; Comments
|
||||
|
||||
(comment) @comment
|
||||
|
||||
(class_definition
|
||||
(comment) @comment.block.documentation)
|
31
runtime/queries/smali/indents.scm
Normal file
31
runtime/queries/smali/indents.scm
Normal file
|
@ -0,0 +1,31 @@
|
|||
[
|
||||
(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"
|
||||
"\}"
|
||||
] @outdent
|
||||
|
||||
[
|
||||
(ERROR)
|
||||
(comment)
|
||||
] @indent.always
|
2
runtime/queries/smali/injections.scm
Normal file
2
runtime/queries/smali/injections.scm
Normal file
|
@ -0,0 +1,2 @@
|
|||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
42
runtime/queries/smali/locals.scm
Normal file
42
runtime/queries/smali/locals.scm
Normal file
|
@ -0,0 +1,42 @@
|
|||
[
|
||||
(class_directive)
|
||||
(expression)
|
||||
(annotation_directive)
|
||||
(array_data_directive)
|
||||
(method_definition)
|
||||
(packed_switch_directive)
|
||||
(sparse_switch_directive)
|
||||
(subannotation_directive)
|
||||
] @local.scope
|
||||
|
||||
[
|
||||
(identifier)
|
||||
(class_identifier)
|
||||
(label)
|
||||
(jmp_label)
|
||||
] @local.reference
|
||||
|
||||
(enum_reference
|
||||
(field_identifier) @local.definition)
|
||||
|
||||
((field_definition
|
||||
(access_modifiers) @_mod
|
||||
(field_identifier) @local.definition)
|
||||
(#eq? @_mod "enum"))
|
||||
|
||||
(field_definition
|
||||
(field_identifier) @local.definition
|
||||
(field_type) @local.definition)
|
||||
|
||||
(annotation_key) @local.definition
|
||||
|
||||
(method_definition
|
||||
(method_signature (method_identifier) @local.definition))
|
||||
|
||||
(param_identifier) @local.definition
|
||||
|
||||
(annotation_directive
|
||||
(class_identifier) @local.definition)
|
||||
|
||||
(class_directive
|
||||
(class_identifier) @local.definition)
|
Loading…
Add table
Reference in a new issue