Update c-sharp queries (#12948)

This commit is contained in:
SofusA 2025-02-27 00:40:16 +01:00 committed by GitHub
parent bb3af143f1
commit 534d0907d3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 129 additions and 277 deletions

View file

@ -649,7 +649,7 @@ args = { processId = "{0}" }
[[grammar]]
name = "c-sharp"
source = { git = "https://github.com/tree-sitter/tree-sitter-c-sharp", rev = "5b60f99545fea00a33bbfae5be956f684c4c69e2" }
source = { git = "https://github.com/tree-sitter/tree-sitter-c-sharp", rev = "b5eb5742f6a7e9438bee22ce8026d6b927be2cd7" }
[[language]]
name = "cel"

View file

@ -1,116 +1,63 @@
(identifier) @variable
;; Methods
(method_declaration
name: (identifier) @function)
(method_declaration
type: [(identifier) (qualified_name)] @type)
(invocation_expression
(member_access_expression
name: (identifier) @function))
(invocation_expression
function: (conditional_access_expression
(member_binding_expression
name: (identifier) @function)))
(invocation_expression
[(identifier) (qualified_name)] @function)
(local_function_statement
name: (identifier) @function)
; Generic Method invocation with generic type
(invocation_expression
function: (generic_name
. (identifier) @function))
;; Namespaces
(namespace_declaration
name: [(identifier) (qualified_name)] @namespace)
(method_declaration name: (identifier) @function)
(local_function_statement name: (identifier) @function)
;; Types
(interface_declaration name: (identifier) @type)
(class_declaration name: (identifier) @type)
(enum_declaration name: (identifier) @type)
(struct_declaration (identifier) @type)
(record_declaration (identifier) @type)
(namespace_declaration name: (identifier) @type)
(using_directive (_) @namespace)
(constructor_declaration name: (identifier) @type)
(destructor_declaration name: (identifier) @type)
(object_creation_expression [(identifier) (qualified_name)] @type)
(type_parameter_list (type_parameter) @type)
(array_type (identifier) @type)
(for_each_statement type: (identifier) @type)
(namespace_declaration name: (identifier) @namespace)
[
(implicit_type)
(nullable_type)
(pointer_type)
(function_pointer_type)
(predefined_type)
] @type.builtin
(generic_name (identifier) @type)
(type_parameter (identifier) @type.parameter)
(parameter type: (identifier) @type)
(type_argument_list (identifier) @type)
(as_expression right: (identifier) @type)
(is_expression right: (identifier) @type)
;; Generic Types
(type_of_expression
(generic_name
(identifier) @type))
(constructor_declaration name: (identifier) @constructor)
(destructor_declaration name: (identifier) @constructor)
(base_list
(generic_name
(identifier) @type))
(_ type: (identifier) @type)
(type_constraint
(generic_name
(identifier) @type))
(base_list (identifier) @type)
(object_creation_expression
(generic_name
(identifier) @type))
(property_declaration
(generic_name
(identifier) @type))
(_
type: (generic_name
(identifier) @type))
(predefined_type) @type.builtin
;; Enum
(enum_member_declaration (identifier) @variable.other.member)
(enum_member_declaration (identifier) @type.enum.variant)
;; Literals
[
(real_literal)
(integer_literal)
] @constant.numeric.integer
(real_literal) @constant.numeric.float
(integer_literal) @constant.numeric.integer
(character_literal) @constant.character
[
(string_literal)
(raw_string_literal)
(verbatim_string_literal)
(interpolated_string_text)
(interpolated_verbatim_string_text)
(interpolation_format_clause)
"\""
"$\""
"@$\""
"$@\""
(interpolated_string_expression)
(interpolation_start)
(interpolation_quote)
] @string
(escape_sequence) @constant.character.escape
(boolean_literal) @constant.builtin.boolean
[
(null_literal)
(void_keyword)
] @constant.builtin
(null_literal) @constant.builtin
;; Comments
(comment) @comment
;; Tokens
(type_argument_list ["<" ">"] @punctuation.bracket)
(type_parameter_list ["<" ">"] @punctuation.bracket)
[
";"
@ -123,6 +70,7 @@
"-"
"-="
"&"
"&="
"&&"
"+"
"++"
@ -140,11 +88,14 @@
">="
">>"
">>="
">>>"
">>>="
"|"
"||"
"|="
"||"
"?"
"??"
"??="
"^"
"^="
"~"
@ -155,224 +106,103 @@
"%"
"%="
":"
"::"
".."
"&="
"->"
"??="
] @operator
["(" ")" "[" "]" "{" "}"] @punctuation.bracket
[
"("
")"
"["
"]"
"{"
"}"
(interpolation_brace)
] @punctuation.bracket
;; Keywords
(modifier) @keyword.storage.modifier
(this_expression) @keyword
(escape_sequence) @constant.character.escape
[
"as"
"await"
"base"
"checked"
"from"
"get"
"in"
"init"
"is"
"let"
"lock"
"new"
"operator"
"out"
"params"
"ref"
"select"
"set"
"sizeof"
"stackalloc"
"typeof"
"unchecked"
"using"
"when"
"where"
"with"
"yield"
(modifier)
"this"
(implicit_type)
] @keyword
[
"add"
"alias"
"as"
"base"
"break"
"case"
"catch"
"checked"
"class"
"continue"
"default"
"delegate"
"do"
"else"
"enum"
"event"
"interface"
"namespace"
"struct"
"record"
] @keyword.storage.type
[
"explicit"
"implicit"
"static"
] @keyword.storage.modifier
[
"break"
"continue"
"goto"
] @keyword.control
[
"catch"
"extern"
"finally"
"throw"
"try"
] @keyword.control.exception
[
"do"
"for"
"foreach"
"while"
] @keyword.control.repeat
[
"case"
"default"
"else"
"global"
"goto"
"if"
"implicit"
"interface"
"is"
"lock"
"namespace"
"notnull"
"operator"
"params"
"return"
"remove"
"sizeof"
"stackalloc"
"static"
"struct"
"switch"
] @keyword.control.conditional
"return" @keyword.control.return
[
(nullable_directive)
(define_directive)
(undef_directive)
(if_directive)
(else_directive)
(elif_directive)
(endif_directive)
(region_directive)
(endregion_directive)
(error_directive)
(warning_directive)
(line_directive)
(pragma_directive)
] @keyword.directive
;; Linq
(from_clause (identifier) @variable)
(group_clause)
(order_by_clause)
(select_clause (identifier) @variable)
(query_continuation (identifier) @variable) @keyword
;; Record
(with_expression
(with_initializer_expression
(simple_assignment_expression
(identifier) @variable)))
;; Exprs
(binary_expression [(identifier) (qualified_name)] @variable [(identifier) (qualified_name)] @variable)
(binary_expression [(identifier) (qualified_name)]* @variable)
(conditional_expression [(identifier) (qualified_name)] @variable)
(conditional_access_expression [(identifier) (qualified_name)] @variable)
(prefix_unary_expression [(identifier) (qualified_name)] @variable)
(postfix_unary_expression [(identifier) (qualified_name)]* @variable)
(assignment_expression [(identifier) (qualified_name)] @variable)
(cast_expression [(identifier) (qualified_name)] @type [(identifier) (qualified_name)] @variable)
(element_access_expression (identifier) @variable)
(member_access_expression
expression: ([(identifier) (qualified_name)] @type
(#match? @type "^[A-Z]")))
(member_access_expression [(identifier) (qualified_name)] @variable)
;; Class
(base_list (identifier) @type)
(property_declaration (generic_name))
(property_declaration
type: (nullable_type) @type
name: (identifier) @variable)
(property_declaration
type: (predefined_type) @type
name: (identifier) @variable)
(property_declaration
type: (identifier) @type
name: (identifier) @variable)
;; Delegate
(delegate_declaration (identifier) @type)
;; Lambda
(lambda_expression) @variable
"throw"
"try"
"typeof"
"unchecked"
"using"
"while"
"new"
"await"
"in"
"yield"
"get"
"set"
"when"
"out"
"ref"
"from"
"where"
"select"
"record"
"init"
"with"
"let"
] @keyword
;; Attribute
(attribute) @type
;; Parameter
(attribute name: (identifier) @attribute)
;; Parameters
(parameter
type: (identifier) @type
name: (identifier) @variable.parameter)
(parameter (identifier) @variable.parameter)
(parameter_modifier) @keyword
(parameter_list
(parameter
name: (identifier) @parameter))
(parameter_list
(parameter
type: [(identifier) (qualified_name)] @type))
;; Typeof
(type_of_expression [(identifier) (qualified_name)] @type)
;; Variable
(variable_declaration [(identifier) (qualified_name)] @type)
(variable_declarator [(identifier) (qualified_name)] @variable)
;; Return
(return_statement (identifier) @variable)
(yield_statement (identifier) @variable)
;; Type
(generic_name (identifier) @type)
(type_parameter [(identifier) (qualified_name)] @type)
(type_argument_list [(identifier) (qualified_name)] @type)
;; Type constraints
(type_parameter_constraints_clause (identifier) @variable.parameter)
(type_constraint (identifier) @type)
;; Exception
(catch_declaration (identifier) @type (identifier) @variable)
(catch_declaration (identifier) @type)
(type_parameter_constraints_clause (identifier) @type.parameter)
;; Switch
(switch_statement (identifier) @variable)
(switch_expression (identifier) @variable)
;; Method calls
;; Lock statement
(lock_statement (identifier) @variable)
;; Declaration expression
(declaration_expression
type: (identifier) @type
name: (identifier) @variable)
;; Rest
(argument (identifier) @variable)
(name_colon (identifier) @variable)
(if_statement (identifier) @variable)
(for_statement (identifier) @variable)
(for_each_statement (identifier) @variable)
(expression_statement (identifier) @variable)
(array_rank_specifier (identifier) @variable)
(equals_value_clause (identifier) @variable)
(interpolation (identifier) @variable)
(cast_expression (identifier) @variable)
((identifier) @comment.unused
(#eq? @comment.unused "_"))
(invocation_expression (member_access_expression name: (identifier) @function))

View file

@ -0,0 +1,23 @@
(class_declaration name: (identifier) @name) @definition.class
(class_declaration (base_list (_) @name)) @reference.class
(interface_declaration name: (identifier) @name) @definition.interface
(interface_declaration (base_list (_) @name)) @reference.interface
(method_declaration name: (identifier) @name) @definition.method
(object_creation_expression type: (identifier) @name) @reference.class
(type_parameter_constraints_clause (identifier) @name) @reference.class
(type_parameter_constraint (type type: (identifier) @name)) @reference.class
(variable_declaration type: (identifier) @name) @reference.class
(invocation_expression function: (member_access_expression name: (identifier) @name)) @reference.send
(namespace_declaration name: (identifier) @name) @definition.module
(namespace_declaration name: (identifier) @name) @module

View file

@ -5,7 +5,6 @@
(enum_declaration body: (_) @class.inside)
(delegate_declaration)
(record_declaration body: (_) @class.inside)
(record_struct_declaration body: (_) @class.inside)
] @class.around
(constructor_declaration body: (_) @function.inside) @function.around