Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'runtime/queries/c-sharp/highlights.scm')
| -rw-r--r-- | runtime/queries/c-sharp/highlights.scm | 240 |
1 files changed, 184 insertions, 56 deletions
diff --git a/runtime/queries/c-sharp/highlights.scm b/runtime/queries/c-sharp/highlights.scm index 07c3bfc3..6b94dd8c 100644 --- a/runtime/queries/c-sharp/highlights.scm +++ b/runtime/queries/c-sharp/highlights.scm @@ -1,64 +1,112 @@ -(identifier) @variable - ;; Methods +(method_declaration + name: (identifier) @function) -(method_declaration name: (identifier) @function) -(local_function_statement name: (identifier) @function) +(method_declaration + type: [(identifier) (qualified_name)] @type) -;; Types +(invocation_expression + (member_access_expression + name: (identifier) @function)) + +(invocation_expression + (member_access_expression + expression: (identifier) @variable)) + +(invocation_expression + function: (conditional_access_expression + (member_binding_expression + name: (identifier) @function))) + +(invocation_expression + [(identifier) (qualified_name)] @function) + +; Generic Method invocation with generic type +(invocation_expression + function: (generic_name + . (identifier) @function)) +;; Namespaces + +(namespace_declaration + name: [(identifier) (qualified_name)] @namespace) + +;; 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) @namespace) +(namespace_declaration name: (identifier) @type) +(using_directive (_) @namespace) +(constructor_declaration name: (identifier) @type) +(object_creation_expression [(identifier) (qualified_name)] @type) +(type_parameter_list (type_parameter) @type) -(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) +[ + (implicit_type) + (nullable_type) + (pointer_type) + (function_pointer_type) + (predefined_type) +] @type.builtin -(constructor_declaration name: (identifier) @constructor) -(destructor_declaration name: (identifier) @constructor) +;; Generic Types +(type_of_expression + (generic_name + (identifier) @type)) -(_ type: (identifier) @type) +(base_list + (generic_name + (identifier) @type)) -(base_list (identifier) @type) +(type_constraint + (generic_name + (identifier) @type)) + +(object_creation_expression + (generic_name + (identifier) @type)) -(predefined_type) @type.builtin +(property_declaration + (generic_name + (identifier) @type)) + +(_ + type: (generic_name + (identifier) @type)) ;; Enum -(enum_member_declaration (identifier) @type.enum.variant) +(enum_member_declaration (identifier) @variable.other.member) ;; 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_expression) - (interpolation_start) - (interpolation_quote) + (interpolated_string_text) + (interpolated_verbatim_string_text) + "\"" + "$\"" + "@$\"" + "$@\"" ] @string -(escape_sequence) @constant.character.escape - (boolean_literal) @constant.builtin.boolean -(null_literal) @constant.builtin +[ + (null_literal) + (void_keyword) +] @constant.builtin ;; Comments - (comment) @comment ;; Tokens - [ ";" "." @@ -70,7 +118,6 @@ "-" "-=" "&" - "&=" "&&" "+" "++" @@ -88,14 +135,11 @@ ">=" ">>" ">>=" - ">>>" - ">>>=" "|" - "|=" "||" + "|=" "?" "??" - "??=" "^" "^=" "~" @@ -106,6 +150,10 @@ "%" "%=" ":" + ".." + "&=" + "->" + "??=" ] @operator [ @@ -115,20 +163,14 @@ "]" "{" "}" - (interpolation_brace) ] @punctuation.bracket ;; Keywords +(modifier) @keyword +(this_expression) @keyword +(escape_sequence) @constant.character.escape [ - (modifier) - "this" - (implicit_type) -] @keyword - -[ - "add" - "alias" "as" "base" "break" @@ -144,11 +186,9 @@ "enum" "event" "explicit" - "extern" "finally" "for" "foreach" - "global" "goto" "if" "implicit" @@ -156,11 +196,9 @@ "is" "lock" "namespace" - "notnull" "operator" "params" "return" - "remove" "sizeof" "stackalloc" "static" @@ -190,19 +228,109 @@ "let" ] @keyword -;; Attribute - -(attribute name: (identifier) @attribute) +(preprocessor_call) @keyword.directive +(preprocessor_call (_) @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) +(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) + +;; 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 -;; Parameters +;; Attribute +(attribute) @type +;; Parameter (parameter + type: (identifier) @type name: (identifier) @variable.parameter) +(parameter (identifier) @variable.parameter) +(parameter_modifier) @keyword -;; Type constraints +(parameter_list + (parameter + name: (identifier) @parameter)) -(type_parameter_constraints_clause (identifier) @type.parameter) +(parameter_list + (parameter + type: [(identifier) (qualified_name)] @type)) -;; Method calls +;; Typeof +(type_of_expression [(identifier) (qualified_name)] @type) -(invocation_expression (member_access_expression name: (identifier) @function)) +;; 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)] @variable.parameter) +(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) + +;; Switch +(switch_statement (identifier) @variable) +(switch_expression (identifier) @variable) + +;; Lock statement +(lock_statement (identifier) @variable) + +;; Rest +(member_access_expression) @variable +(element_access_expression (identifier) @variable) +(argument (identifier) @variable) +(for_statement (identifier) @variable) +(for_each_statement (identifier) @variable) +(expression_statement (identifier) @variable) +(member_access_expression expression: (identifier) @variable) +(member_access_expression name: (identifier) @variable) +(conditional_access_expression [(identifier) (qualified_name)] @variable) +((identifier) @comment.unused + (#eq? @comment.unused "_")) |