Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Rules regarding CrossReferences
Rules regarding CrossReferences [message #990074] Mon, 10 December 2012 13:04 Go to next message
Robert Wild is currently offline Robert Wild
Messages: 33
Registered: August 2012
Member
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?
Re: Rules regarding CrossReferences [message #990077 is a reply to message #990074] Mon, 10 December 2012 13:34 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik Lindberg
Messages: 2498
Registered: July 2009
Senior Member
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
Re: Rules regarding CrossReferences [message #990220 is a reply to message #990074] Tue, 11 December 2012 08:26 Go to previous messageGo to next message
Robert Wild is currently offline Robert Wild
Messages: 33
Registered: August 2012
Member
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.

Re: Rules regarding CrossReferences [message #990227 is a reply to message #990220] Tue, 11 December 2012 08:51 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian Zarnekow
Messages: 2809
Registered: July 2009
Senior Member
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
Re: Rules regarding CrossReferences [message #990233 is a reply to message #990227] Tue, 11 December 2012 09:18 Go to previous message
Robert Wild is currently offline Robert Wild
Messages: 33
Registered: August 2012
Member
So there's no easy way to prevent the redundancy of rules in ContentAssist and validation?

I guess I can implement a method for checking a rule and call it from contentAssist and validation thus eliminating redundancy.
Previous Topic:Is there an Xtend-Interpreter
Next Topic:signer information mismatch
Goto Forum:
  


Current Time: Thu Jul 31 07:35:51 EDT 2014

Powered by FUDForum. Page generated in 0.02240 seconds