facebookarchive / ide-flowtype

Flow support for Atom IDE
Other
178 stars 17 forks source link

Type popup is not scoping in a way that is grammar-friendly #29

Open bradennapier opened 7 years ago

bradennapier commented 7 years ago

It would appear that the popup for the flowtype hints does not scope the syntax in a way that can be detected as a flowtype.

When looking at the flowtypes in the function itself, it does report correctly -- but the syntax highlighting is a bit weird? Not sure if this is specific to the grammar -- although it is correct in the body itself:

Non-required items highlight as they should (see message which I made optional to test):

image

My guess would be that the grammar is able to "guess" its a flowtype when it sees the question mark there.

However, required items cant be predicted so it ends up highlighting incorrectly.

image

My best guest would be that it is not giving the grammar the flowtype scope so the grammar only knows to properly highlight it as flow.

It looks like the main syntax expects:

Object is wrapped in:

syntax--meta syntax--object syntax--flowtype

Then the values are highlighted with the scope:

image

Since there is now "type TypeName = {}" preceeding it, the grammar doesn't know how to do it.

I will also report with the grammar - but I would think there is no real way for the grammar to be aware without scope added in a way that it can pick it up.

I can see how this may end up being a tricky problem. It is possible that the best solution will be to actually provide the full type definition to the user (and perhaps, if possible, hide the definition so that only the grammar actually sees it?) -- just thinking of creative ways of letting the grammar know!