tree-sitter-c-sharp icon indicating copy to clipboard operation
tree-sitter-c-sharp copied to clipboard

Ignore code between `#if false` ... `#endif`?

Open Sjord opened this issue 4 years ago • 1 comments

E.g.

#if false
    this is a fairly common pattern in C# to disable code, but can also be used for comments or anything else.
#endif

Currently, this grammar basically ignores preprocessor directives. The parser is not aware of preprocessor variables, so it can't really do any better. However, in case of #if false we can be certain that the code shouldn't end up in the parse tree.

This introduces an extra special case for preprocessor directives, but it would improve parsing results.

Sjord avatar Sep 15 '21 11:09 Sjord

I'd rather try and get #189 tackled which would cover this.

damieng avatar Sep 15 '21 12:09 damieng