tree-sitter / tree-sitter-scala

Scala grammar for tree-sitter
MIT License
158 stars 55 forks source link

edge-case where single-line comment eats a finishing bracket on Objects #396

Closed walksanatora closed 5 months ago

walksanatora commented 5 months ago

Commit of tree-sitter-scala you tested this on

rust crate 0.21.0

A code sample showing the error

object Test {
    //we have commento
}

Show the error node

cannot find a error node as it is a edge-case (compilation_unit (object_definition name: (identifier) body: (template_body (comment))))

it appears to "fold" the final } into the comment when a comment appears before end of file

What do you expect the tree to look like

probally the same tree. (mabey a new value appears at the end) (compilation_unit (object_definition name: (identifier) body: (template_body (comment))))

Where are you experiencing this error?

the rust crate version

eed3si9n commented 5 months ago

@walksanatora

I was just forgetting to add a newline... (why can I not close it myself...)

Was the comment on https://github.com/tree-sitter/tree-sitter-scala/issues/384#issuecomment-2083788413 intended for this issue? If so should I close this?

walksanatora commented 5 months ago

yeah I put it on the wrong issue

walksanatora commented 5 months ago

(also slightly saddened that match statments aren't turned into a match_expression or smth like that with a value: Identifier field and some "branch" fields or smth like that, but that's just a gripe with the lib and not a bug)

eed3si9n commented 5 months ago

Feel free to open an issue, or send us a PR to improve match expression.