Closed jwoudenberg closed 2 years ago
Hey,
it seems sensible and from a quick glance an okay approach. However, I'm a bit afraid of the breakage it might cause in upstream projects. Maybe doing it via a field would be an alternative https://tree-sitter.github.io/tree-sitter/creating-parsers#using-fields
Yeah, that concern makes a ton of sense. Fields look like a great alternative approach, but I think they can only be used to point to a particular unique child, right? So in case of a type like Some.Module.MyType
, I don't think Some
and Module
could have the same field name. Putting them together in a single qualifier node or something might work, but then the grammar would change again.
Yeah, I kinda hoped, that it might return a list, but the docs seem to suggest, that's not the case.
Since this is a not a bug I'm happy to close this!
Hey there! Thank you so much for your work on this grammar. It's been a pleasure to work with so far.
I'm using tree-sitter and tree-sitter-elm to build some development tooling that performs diffs of syntax trees to find what changed, basically trying to figure out which nodes got added and removed. One case that's giving me trouble is when in an Elm type like
Dict a b
theDict
is qualified, intoDict.Dict a b
. My diff tool understands there's extra code here, but not whether the slice that was added isDict.
or.Dict
. This only happens in cases where a type and module name match. If bothDict
slices had different node kinds that would resolve the ambiguity. Currently they're bothupper_case_identifier
s.I realize this is a super-specific need, and totally understand it's not one this grammar wants to support. I'd thought I'd bring it up though, in case a change like this would be useful in other places, for instance to highlight module qualifiers and types differently.
I've given implementing this change a shot, but I'm super new to writing tree-sitter parsers so good odds I'm not taking an optimal approach. If there's an interest I'd be happy to make a PR (this is the diff to grammar.js).