Closed dnbln closed 3 years ago
Yeah, this is the next big area of improvement for the plugin. A few things need to happen to support this notation:
<>
is replaced with some special variable (e.g. __intellij_lalrpop_selection
) so the Rust plugin can parse the code. The hard part is performing this transformation without affecting the source PSI elements (what's shown in the lalrpop file). This will require some more research.Item*
is a Vec
of Item
's type, <Visibility> "fn" <Name>
is a tuple of the visibility and name types, <var:Id> "=" <expr:Expression>
has two named variables, etc. Currently, the last example is supported as long as Id
and Expression
explicitly declare their types, i.e. Id: String = ...
.Edit: some more examples of alternatives at the bottom of this page: http://lalrpop.github.io/lalrpop/tutorial/003_type_inference.html
I tried my hand at solving the second part and realized that in cases like <Visibility> "fn" <Name>
, <>
is not really a tuple, but (<>)
is. Small but important distinction here.
I might have just found a solution to 1. (but I'm not really sure it would work): the LiteralTextEscaper
// from PsiLanguageInjectionHost
/**
* @return {@link LiteralTextEscaper} instance which will be used to convert the content of this host element to the content of injected file
*/
@NotNull
LiteralTextEscaper<? extends PsiLanguageInjectionHost> createLiteralTextEscaper();
Ok turns out I was right: it is able to do that. Implemented it in https://github.com/dblanovschi/intellij-lalrpop/commit/745608f234e9bfa99d114738b879aa3401d4d3ef :tada: . Now on to evaluating what's "selected" from the list of symbols in the alternative.
I finally got it to find what's selected or not (after getting sidetracked on type resolution in lalrpop; so now the types in rust injections are way more accurate, but at quite the cost).
Fixed by #17 :tada:
As of now, (I think the Rust plugin?) says "error: Chained comparison operator require parentheses" when using
<>