tree-sitter / tree-sitter-c-sharp

C# Grammar for tree-sitter
MIT License
177 stars 47 forks source link

`file_scoped_namespace_declaration` range output different to `namespace_declaration` range #338

Open Issafalcon opened 3 weeks ago

Issafalcon commented 3 weeks ago

Hi,

Since the large overhaul to the parser, I have noticed that when using Treesitter queries in Neovim, that the range output in block scoped namespaces, include the entire contents of the enclosed block (i.e. The entire namespace).

This used to be the case for file scoped namespaces too, but after the overhaul, the range of file_scoped_namespace_declaration only includes the line that the namespace declaration is on.

This has altered the behaviour of a plugin that I maintain (https://github.com/Issafalcon/neotest-dotnet). It hasn't broken it in any major way, but the tests all started to fail because the tree of nodes that are formulated based on whether a class is nested in the range of the namespace have changed. The file scoped namespaces are ignored, and not included in the tree, because the range doesn't include the range position of the nested class itself.

I'm not sure if this is a deliberate breaking change, or if it's a regression defect, but thought I'd raise it anyway.