tree-sitter-julia icon indicating copy to clipboard operation
tree-sitter-julia copied to clipboard

Macrocall parsing rule allows newlines between arguments if they are stirngs

Open steffenhaug opened this issue 1 year ago • 1 comments

In reference to https://github.com/JuliaEditorSupport/zed-julia/issues/15#issuecomment-2329739530.

It appears that top-level macro calls allow newlines between arguments if the argument after the newline is a string.

It is my understanding that only the @doc macro is handled as a special case in the parser to allow newlines between macro arguments, and that newlines are only allowed between the first and second argument. The advanced usage section of the documentation manual is pretty clear about this.

This makes it quite tricky to correctly find docstrings if there are macros used at the top level.

It seems quite strange to me that something like this can go unnoticed, given the prevalence of @kwdef in particular, yet I could find no issues mentioning this, closed or open. I appreciate that this kind of context-sensitivity might be really tricky to implement in tree-sitter.

For the record, it is possible to have any number of newline-separated arguments, not just newlines between the first and second argument.

But funnily enough, if the newline separates an argument that isn't a string literal, it is not parsed as part of the macro call, even though it is in the special case of @doc:

Is this behavior a conscious choice?

steffenhaug avatar Sep 05 '24 18:09 steffenhaug

Hi @steffenhaug, thanks for the report.

We don't handle @doc at all. This is probably a bug in the scanner with the way we parse the start of the string.

Please use the issue template next time.

savq avatar Sep 05 '24 20:09 savq