diff options
| author | Amaan Qureshi <amaanq12@gmail.com> | 2024-05-03 20:10:58 -0400 |
|---|---|---|
| committer | Amaan Qureshi <amaanq12@gmail.com> | 2024-05-11 15:26:30 -0400 |
| commit | 6587d8e6942b8d2146d61bab4c4acff9dec5ae59 (patch) | |
| tree | 692b60f95e29eb8dae81194cd0f21e92d0fcd142 /queries/c_sharp | |
| parent | bot(lockfile): update dtd, go, idl, javascript, tact, xml (diff) | |
| download | nvim-treesitter-6587d8e6942b8d2146d61bab4c4acff9dec5ae59.tar nvim-treesitter-6587d8e6942b8d2146d61bab4c4acff9dec5ae59.tar.gz nvim-treesitter-6587d8e6942b8d2146d61bab4c4acff9dec5ae59.tar.bz2 nvim-treesitter-6587d8e6942b8d2146d61bab4c4acff9dec5ae59.tar.lz nvim-treesitter-6587d8e6942b8d2146d61bab4c4acff9dec5ae59.tar.xz nvim-treesitter-6587d8e6942b8d2146d61bab4c4acff9dec5ae59.tar.zst nvim-treesitter-6587d8e6942b8d2146d61bab4c4acff9dec5ae59.zip | |
feat(c_sharp): update parser & queries
Diffstat (limited to 'queries/c_sharp')
| -rw-r--r-- | queries/c_sharp/folds.scm | 3 | ||||
| -rw-r--r-- | queries/c_sharp/highlights.scm | 238 | ||||
| -rw-r--r-- | queries/c_sharp/locals.scm | 4 |
3 files changed, 177 insertions, 68 deletions
diff --git a/queries/c_sharp/folds.scm b/queries/c_sharp/folds.scm index 80ae4e44b..16967b69d 100644 --- a/queries/c_sharp/folds.scm +++ b/queries/c_sharp/folds.scm @@ -10,5 +10,8 @@ initializer: (initializer_expression) @fold [ (block) + (preproc_if) + (preproc_elif) + (preproc_else) (using_directive)+ ] @fold diff --git a/queries/c_sharp/highlights.scm b/queries/c_sharp/highlights.scm index 7d2621bcc..20cc80747 100644 --- a/queries/c_sharp/highlights.scm +++ b/queries/c_sharp/highlights.scm @@ -1,12 +1,15 @@ -(identifier) @variable +[ + (identifier) + (preproc_arg) +] @variable + +((preproc_arg) @constant.macro + (#lua-match? @constant.macro "^[_A-Z][_A-Z0-9]*$")) ((identifier) @keyword (#eq? @keyword "value") (#has-ancestor? @keyword accessor_declaration)) -((identifier) @variable.builtin - (#eq? @variable.builtin "_")) - (method_declaration name: (identifier) @function.method) @@ -14,8 +17,23 @@ name: (identifier) @function.method) (method_declaration + returns: [ + (identifier) @type + (generic_name + (identifier) @type) + ]) + +(event_declaration type: (identifier) @type) +(event_declaration + name: (identifier) @variable.member) + +(event_field_declaration + (variable_declaration + (variable_declarator + name: (identifier) @variable.member))) + (declaration_pattern type: (identifier) @type) @@ -46,11 +64,16 @@ (identifier) @type) (namespace_declaration - name: [ - (qualified_name - (identifier) @module) - (identifier) @module - ]) + name: (identifier) @module) + +(file_scoped_namespace_declaration + name: (identifier) @module) + +(qualified_name + (identifier) @module + (#not-has-ancestor? @module method_declaration) + (#not-has-ancestor? @module record_declaration) + (#has-ancestor? @module namespace_declaration file_scoped_namespace_declaration)) (invocation_expression (identifier) @function.method.call) @@ -64,13 +87,16 @@ (assignment_expression left: (identifier) @variable.member)) +(parameter + name: (identifier) @variable.parameter) + (parameter_list - (parameter - name: (identifier) @variable.parameter)) + name: (identifier) @variable.parameter) -(implicit_parameter_list - (parameter - name: (identifier) @variable.parameter)) +(bracketed_parameter_list + name: (identifier) @variable.parameter) + +(implicit_parameter) @variable.parameter (parameter_list (parameter @@ -82,6 +108,15 @@ (null_literal) @constant.builtin +(calling_convention + [ + (identifier) + "Cdecl" + "Stdcall" + "Thiscall" + "Fastcall" + ] @attribute.builtin) + (character_literal) @character [ @@ -93,7 +128,10 @@ (escape_sequence) @string.escape -(boolean_literal) @boolean +[ + "true" + "false" +] @boolean (predefined_type) @type.builtin @@ -114,8 +152,7 @@ (identifier) @type) (using_directive - (name_equals - (identifier) @type.definition)) + (type) @type.definition) (property_declaration name: (identifier) @property) @@ -124,7 +161,16 @@ type: (identifier) @type) (nullable_type - (identifier) @type) + type: (identifier) @type) + +(array_type + type: (identifier) @type) + +(ref_type + type: (identifier) @type) + +(pointer_type + type: (identifier) @type) (catch_declaration type: (identifier) @type) @@ -138,15 +184,48 @@ (record_declaration name: (identifier) @type) +(struct_declaration + name: (identifier) @type) + (enum_declaration name: (identifier) @type) (enum_member_declaration name: (identifier) @variable.member) +(operator_declaration + type: (identifier) @type) + +(conversion_operator_declaration + type: (identifier) @type) + +(explicit_interface_specifier + [ + (identifier) @type + (generic_name + (identifier) @type) + ]) + +(explicit_interface_specifier + (identifier) @type) + +(primary_constructor_base_type + type: (identifier) @type) + +[ + "assembly" + "module" + "this" + "base" + (discard) +] @variable.builtin + (constructor_declaration name: (identifier) @constructor) +(destructor_declaration + name: (identifier) @constructor) + (constructor_initializer "base" @constructor) @@ -157,7 +236,7 @@ (identifier) @type) ; Generic Types. -(type_of_expression +(typeof_expression (generic_name (identifier) @type)) @@ -169,9 +248,13 @@ (generic_name (identifier) @type)) -(type_constraint - (generic_name - (identifier) @type)) +(type_parameter_constraint + [ + (identifier) @type + (type + (generic_name + (identifier) @type)) + ]) (object_creation_expression (generic_name @@ -205,15 +288,26 @@ (type_parameter_list (type_parameter) @type) +(type_parameter + name: (identifier) @type) + (type_parameter_constraints_clause - target: (identifier) @type) + "where" + . + (identifier) @type) (attribute name: (identifier) @attribute) -(for_each_statement +(foreach_statement type: (identifier) @type) +(goto_statement + (identifier) @label) + +(labeled_statement + (identifier) @label) + (tuple_element type: (identifier) @type) @@ -222,43 +316,48 @@ (declaration_expression type: (identifier) @type))) +(cast_expression + type: (identifier) @type) + +(lambda_expression + type: (identifier) @type) + (as_expression right: (identifier) @type) -(type_of_expression +(typeof_expression (identifier) @type) -(name_colon - (identifier) @variable.parameter) +(preproc_error) @keyword.exception -(warning_directive) @comment.warning - -(error_directive) @keyword.exception - -(define_directive - (identifier) @constant) @constant.macro - -(undef_directive - (identifier) @constant) @constant.macro - -(line_directive) @constant.macro - -(line_directive - (preproc_integer_literal) @constant - (preproc_string_literal)? @string) - -(pragma_directive - (identifier) @constant) @constant.macro +[ + "#define" + "#undef" +] @keyword.directive.define -(pragma_directive - (preproc_string_literal) @string) @constant.macro +[ + "#if" + "#elif" + "#else" + "#endif" + "#region" + "#endregion" + "#line" + "#pragma" + "#nullable" + "#error" + (shebang_directive) +] @keyword.directive [ - (nullable_directive) - (region_directive) - (endregion_directive) + (preproc_line) + (preproc_pragma) + (preproc_nullable) ] @constant.macro +(preproc_pragma + (identifier) @constant) + [ "if" "else" @@ -266,16 +365,15 @@ "break" "case" "when" - (if_directive) - (elif_directive) - (else_directive) - (endif_directive) ] @keyword.conditional -(if_directive +(preproc_pragma (identifier) @constant) -(elif_directive +(preproc_if + (identifier) @constant) + +(preproc_if (identifier) @constant) [ @@ -335,6 +433,7 @@ "=>" "??" "??=" + ".." ] @operator [ @@ -359,6 +458,8 @@ ")" ] @punctuation.bracket +(interpolation_brace) @punctuation.special + (type_argument_list [ "<" @@ -366,12 +467,6 @@ ] @punctuation.bracket) [ - (this_expression) - (base_expression) - "this" -] @variable.builtin - -[ "using" "as" ] @keyword.import @@ -390,6 +485,9 @@ "or" "not" "stackalloc" + "__makeref" + "__reftype" + "__refvalue" "in" "out" "ref" @@ -413,8 +511,14 @@ "unchecked" "fixed" "alias" + "file" + "unsafe" ] @keyword +(attribute_target_specifier + . + _ @keyword) + [ "enum" "record" @@ -438,9 +542,9 @@ "static" "volatile" "required" -] @keyword.modifier - -[ + "managed" + "unmanaged" + "notnull" "abstract" "private" "protected" @@ -449,9 +553,11 @@ "partial" "sealed" "virtual" + "global" ] @keyword.modifier -(parameter_modifier) @operator +(scoped_type + "scoped" @keyword.modifier) (query_expression (_ diff --git a/queries/c_sharp/locals.scm b/queries/c_sharp/locals.scm index 33df9bb37..bef094007 100644 --- a/queries/c_sharp/locals.scm +++ b/queries/c_sharp/locals.scm @@ -10,10 +10,10 @@ (declaration_expression name: (identifier) @local.definition.var) -(for_each_statement +(foreach_statement left: (identifier) @local.definition.var) -(for_each_statement +(foreach_statement left: (tuple_pattern (identifier) @local.definition.var)) |
