What's the best way to implement basic rules regarding the crossReference in parent=[Class]. Rules like no self-reference and no cycles.
I know of two possibilities:
1. I could define these rules in a custom validator, but then a custom ProposalProvider is necessary, too. One Rule has to be implemented in two places.
2. Or I could use a custom ScopingProvider, but then I cannot provide meaningful error messages. It would always say "reference not found" which isn't helping a lot.
On 2012-10-12 19:04, Robert Wild wrote:
> Given this simple example:
>
> Class:
> "class" name=ID ("extends" parent=[Class])?
> ;
>
>
> What's the best way to implement basic rules regarding the
> crossReference in parent=[Class]. Rules like no self-reference and no
> cycles.
>
> I know of two possibilities:
> 1. I could define these rules in a custom validator, but then a custom
> ProposalProvider is necessary, too. One Rule has to be implemented in
> two places.
>
> 2. Or I could use a custom ScopingProvider, but then I cannot provide
> meaningful error messages. It would always say "reference not found"
> which isn't helping a lot.
>
> Is there some other way?
Custom linker; that runs after the default linking. Extend the
LazyLinker and implement afterModelLinked. You can look at my
implementation (PPLinker) in cloudsmith / geppetto @ github.
In your custom linker just validate links and issue errors.
- henrik
does that prevent items from being displayed by the ProposalProvider?
I haven't tried it yet, but as far as I've understood it, it doesn't seem like it does things differently than validation does, except it's organized a bit different.
Am 11.12.12 14:26, schrieb Robert Wild:
> does that prevent items from being displayed by the ProposalProvider?
> I haven't tried it yet, but as far as I've understood it, it doesn't
> seem like it does things differently than validation does, except it's
> organized a bit different.
>
Custom ContentAssist and custom validation is the way to go, e.g.
sometimes you want to show invalid proposals if there are no others
available but still issue an error + quickfix for that particular reference.
Regards,
Sebastian
--
Looking for professional support for Xtext, Xtend or Eclipse Modeling?
Go visit: http://xtext.itemis.com