tree-sitter/tree-sitter-c-sharp

Generic methods not highlighted correctly

musjj opened this issue · 9 comments

musjj commented

Casting using a generic method is highlighted incorrectly, when it's assigned to a variable.

image

Tree-Sitter Grammars do not, themselves, do any syntax highlighting.

What IDE/editor/viewer are you using?

musjj commented

Sorry for not being specific, I guess. I'm using neovim, and it seems that problem isn't the highlighting, but the fact that they're not parsed correctly:

With variable assignment

image
image

Without variable assignment

image
image

Your block of code parses as:

  (compilation_unit
      (global_statement
        (local_declaration_statement
          (variable_declaration
            (identifier)
            (variable_declarator
              (identifier)
              (equals_value_clause
                (invocation_expression
                  (generic_name
                    (identifier)
                    (type_argument_list
                      (identifier)))
                  (argument_list
                    (argument
                      (string_literal)))))))))
      (global_statement
        (expression_statement
          (invocation_expression
            (generic_name
              (identifier)
              (type_argument_list
                (identifier)))
            (argument_list
              (argument
                (string_literal)))))))

So both of them are mapping to the exact same block during the parsing phase. I checkout our tagging system which is used by highlighters as well:

image

While I'm not familiar with NeoVIM I would suggest trying to disable OmniSharp to see if the syntax on first then matches the syntax on the second.

musjj commented

I've turned off the LSP, but no luck.
image
Weirdly, it seems that it got parsed as a binary expression for me. I wonder if my parser is outdated or something...

I've found this - it seems to be a very recent regression, let me investigate.

Regression introduced in #294 which also shows a lack of these use cases in the corpus tests.

Should now be working correctly here - neovim-tree-sitter will need to update their reference to the latest commit on master.

musjj commented

Thanks a lot for the swift response! I'll give it a go once they bumped up the commit in the repo.

musjj commented

This is fixed now, thanks a lot!