tree-sitter-objc/queries/highlights.scm

368 lines
6.2 KiB
Scheme
Raw Normal View History

2022-04-22 10:29:02 +00:00
[
(comment)
(pragma)
] @comment
[
(self)
(super)
] @variable.builtin
[
(getter)
(setter)
(nonnull)
(nullable)
(null_resettable)
(unsafe_unretained)
(null_unspecified)
(direct)
(readwrite)
(readonly)
(strong)
(weak)
(copy)
(assign)
(retain)
(atomic)
(nonatomic)
(class)
(NS_NONATOMIC_IOSONLY)
(DISPATCH_QUEUE_REFERENCE_TYPE)
] @keyword
2022-04-16 15:58:26 +00:00
[
"@interface"
"@protocol"
"@property"
"@end"
"@implementation"
2022-04-22 10:29:02 +00:00
"@compatibility_alias"
2022-04-16 15:58:26 +00:00
"@autoreleasepool"
"@synchronized"
"@class"
"@synthesize"
"@dynamic"
"@defs"
"@try"
"@catch"
"@finally"
"@throw"
"@selector"
"@encode"
2022-04-22 10:29:02 +00:00
"@available"
"__builtin_available"
2022-04-16 15:58:26 +00:00
(private)
(public)
(protected)
(package)
(optional)
(required)
"NS_ENUM"
"NS_ERROR_ENUM"
"NS_OPTIONS"
2022-04-22 10:29:02 +00:00
(type_qualifier)
(storage_class_specifier)
(attribute_specifier)
(class_interface_attribute_sepcifier)
(method_variadic_arguments_attribute_specifier)
"NS_NOESCAPE"
2022-04-16 15:58:26 +00:00
"const"
"default"
"enum"
"extern"
"inline"
"static"
"struct"
"typedef"
"typeof"
"__typeof"
"__typeof__"
"_Atomic"
"union"
"volatile"
"goto"
"register"
"__covariant"
"__contravariant"
"__GENERICS"
] @keyword
"sizeof" @keyword.operator
"return" @keyword.return
[
"while"
"for"
"do"
"continue"
"break"
2022-04-22 10:29:02 +00:00
] @keyword.repeat
2022-04-16 15:58:26 +00:00
"#define" @constant.macro
2022-04-22 10:29:02 +00:00
2022-04-16 15:58:26 +00:00
[
"#if"
"#ifdef"
"#ifndef"
"#else"
"#elif"
"#endif"
(preproc_directive)
] @keyword
"#include" @include
"#import" @include
"@import" @include
[
"="
"-"
"*"
"/"
"+"
"%"
"~"
"|"
"&"
"^"
"<<"
">>"
"->"
"<"
"<="
">="
">"
"=="
"!="
"!"
"&&"
"||"
"-="
"+="
"*="
"/="
"%="
"|="
"&="
"^="
">>="
"<<="
"--"
"++"
"@"
] @operator
2022-04-22 10:29:02 +00:00
[
"if"
"else"
"case"
"switch"
] @keyword.conditional
(conditional_expression [ "?" ":" ] @keyword.conditional)
2022-04-16 15:58:26 +00:00
[
(true)
(false)
2022-04-22 10:29:02 +00:00
(YES)
(NO)
] @keyword.boolean
2022-04-16 15:58:26 +00:00
[ "." ";" ":" "," ] @punctuation.delimiter
"..." @punctuation.special
[ "(" ")" "[" "]" "{" "}"] @punctuation.bracket
2022-04-22 10:29:02 +00:00
[
(string_literal)
(string_expression)
(system_lib_string)
(module_string)
] @string
2022-04-16 15:58:26 +00:00
(escape_sequence) @string.escape
(null) @constant.builtin
(nil) @constant.builtin
(number_literal) @number
(number_expression) @number
(char_literal) @character
[
(preproc_arg)
(preproc_defined)
] @function.macro
2022-04-22 10:29:02 +00:00
declarator: (identifier) @property
(cast_expression value: (identifier) @property)
2022-04-16 15:58:26 +00:00
(((field_expression
(field_identifier) @property)) @_parent
2022-04-22 10:29:02 +00:00
(#not-has-parent? @_parent function_declarator call_expression))
2022-04-16 15:58:26 +00:00
(((field_identifier) @property)
(#has-ancestor? @property field_declaration)
(#not-has-ancestor? @property function_declarator))
2022-04-22 10:29:02 +00:00
[
(type_identifier)
(primitive_type)
(sized_type_specifier)
(type_descriptor)
(generics_type_reference)
] @type
2022-04-16 15:58:26 +00:00
[
(id)
(Class)
(Method)
(IMP)
(SEL)
2022-04-22 10:29:02 +00:00
(BOOL)
(instancetype)
2022-04-16 15:58:26 +00:00
(auto)
2022-04-22 10:29:02 +00:00
] @type.builtin
2022-04-16 15:58:26 +00:00
(declaration (type_qualifier) @type)
(cast_expression type: (type_descriptor) @type)
(sizeof_expression value: (parenthesized_expression (identifier) @type))
2022-04-22 10:29:02 +00:00
(class_interface name: (identifier) @type.class)
(category_interface name: (identifier) @type.class)
(category_interface category: (identifier) @type.category)
(superclass_reference name: (identifier) @type.class)
(parameterized_class_type_arguments) @type.class
(class_implementation name: (identifier) @type.class)
(category_implementation name: (identifier) @type.class)
(compatibility_alias_declaration (identifier) @type.class)
(category_implementation category: (identifier) @type.category)
(class_forward_declaration name: (identifier) @type.class)
(protocol_forward_declaration name: (identifier) @type.protocol)
(protocol_declaration name: (identifier) @type.protocol)
(protocol_qualifiers (protocol_identifier) @type.protocol)
(protocol_expression (identifier) @type.protocol)
2022-04-16 15:58:26 +00:00
;; Preproc def / undef
(preproc_def
name: (_) @constant)
(preproc_call
directive: (preproc_directive) @_u
argument: (_) @constant
(#eq? @_u "#undef"))
(call_expression
function: (identifier) @function)
2022-04-22 10:29:02 +00:00
(field_expression
field: (field_identifier) @function)
2022-04-16 15:58:26 +00:00
(function_declarator
declarator: (identifier) @function)
(preproc_function_def
name: (identifier) @function.macro)
2022-04-22 10:29:02 +00:00
(selector_expression
name: (identifier) @function)
(method_declaration
selector: (identifier) @function)
(method_declaration
(keyword_selector
(keyword_declarator
keyword: (identifier) @function)))
(method_declaration
(keyword_selector
(keyword_declarator
name: (identifier) @function)))
(message_expression
receiver: (field_expression
field: (field_identifier) @variable))
(method_definition
selector: (identifier) @function)
(method_definition
(keyword_selector
(keyword_declarator
keyword: (identifier) @function)))
(message_expression
selector: (identifier) @function)
(method_definition
(keyword_selector
(keyword_declarator
name: (identifier) @property)))
(message_expression
selector: (keyword_argument_list
(keyword_argument
keyword: (identifier) @function)))
(message_expression
selector: (keyword_argument_list
(keyword_argument
argument: (identifier) @property)))
(unary_expression argument: (identifier) @function)
(va_arg_expression) @function
(va_arg_expression va_list: (identifier) @property)
(enumerator name: (identifier) @property)
2022-04-16 15:58:26 +00:00
;; Parameters
(parameter_declaration
2022-04-22 10:29:02 +00:00
declarator: (identifier) @variable.parameter)
(parameter_declaration
declarator: (pointer_declarator) @variable.parameter)
2022-04-16 15:58:26 +00:00
(parameter_declaration
2022-04-22 10:29:02 +00:00
declarator: (pointer_declarator
declarator: (identifier) @variable.parameter))
2022-04-16 15:58:26 +00:00
2022-04-22 10:29:02 +00:00
(for_in_statement
loop: (identifier) @variable.parameter)
(dictionary_expression
key:(_expression) @property)
(dictionary_expression
value: (_expression) @property)
(array_expression
(identifier) @property)
(argument_list
(identifier) @property)
(expression_statement
(identifier) @property)
(_expression (identifier) @property)
2022-04-16 15:58:26 +00:00
[
2022-04-22 10:29:02 +00:00
"__attribute"
2022-04-16 15:58:26 +00:00
"__attribute__"
"__cdecl"
"__clrcall"
"__stdcall"
"__fastcall"
"__thiscall"
"__vectorcall"
"_unaligned"
"__unaligned"
"__declspec"
] @attribute
2022-04-22 10:29:02 +00:00
(attribute_specifier) @attribute
((identifier) @constant
(#match? @constant "^[A-Z][A-Z0-9_$]+$"))
2022-04-16 15:58:26 +00:00
(ERROR) @error