alex-pinkus / tree-sitter-swift

A tree-sitter grammar for the Swift programming language.
MIT License
137 stars 35 forks source link

Parse `package` visibility modifier. #383

Closed patrickt closed 4 months ago

patrickt commented 6 months ago

No highlighting changes needed for this to look nice:

image
alex-pinkus commented 6 months ago

Looks like this causes a parse failure on line 39 of: https://github.com/daltoniam/Starscream/blob/master/Package.swift#L39

we might need to special-case this as an allowed identifier, like we do with async, so that tree-sitter doesn’t choose the keyword over the identifier too early.

alex-pinkus commented 6 months ago

You should be able to run top-repos locally btw — in this case ./scripts/top-repos.sh 36 will test exactly the failing repository

A corpus test for this case would be greatly appreciated too!

alex-pinkus commented 6 months ago

Ah, well now ./scripts/top-repos.sh 25

alex-pinkus commented 6 months ago

Maybe try adding it to the simple_identifier declaration itself here? Then it would cover the enum case we see from Moya. Sorry for pointing you in the wrong direction, I thought that was where I special cased async too...

alex-pinkus commented 6 months ago

I added a _contextual_simple_identifier rule in #385 that should be the right place to put these going forward.

alex-pinkus commented 4 months ago

This was super close to being done so I finished it up in #407.