AzureMarker / intellij-lalrpop

Jetbrains plugin for the LALRPOP parser-generator
MIT License
16 stars 2 forks source link

Show type hints for inferred nonterminal types #34

Closed AzureMarker closed 3 years ago

AzureMarker commented 3 years ago

When a nonterminal does not explicitly state its type, show the inferred type as a type hint.

Similar to how type hints are shown in Rust code: image

Do something similar for nonterminals:

// This has the type Vec<T>
Comma<T> = Deliminate<T, ",">;
dnbln commented 3 years ago

I actually wanted to do this. The rust plugin has some code available as public API, which would also add the references you could navigate, at the expense of showing ? / &? / &mut ? when it cannot find something.

AzureMarker commented 3 years ago

You can surely work on this; I made the issue to track the idea (I didn't intend to claim the assignment outright).

dnbln commented 3 years ago

Wow... Was looking at the wrong thing the whole time. No wonder it wasn't working :sweat_smile:

dnbln commented 3 years ago

Got it to work:

image

dnbln commented 3 years ago

Might be a little bit overkill but I added the inlay for selected symbols in alternatives too, here's how the same code as above looks now:

image

@Mcat12 thoughts?

Maybe also would be a good idea to put this behind an option in the settings because it looks like too much.

AzureMarker commented 3 years ago

I think it might be better to have the symbol types only be shown when you hover over them (like documentation).

dnbln commented 3 years ago

Uhh I added the options already :disappointed: image

AzureMarker commented 3 years ago

I'm not opposed to it also being an option :)

dnbln commented 3 years ago

I think the way the rust plugin does something similar is through the elementDescriptionProvider EP, offering that data on hover