Skip to main content


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 18:04 Go to next message
Robert Wild is currently offline Robert WildFriend
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 18:34 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
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 13:26 Go to previous messageGo to next message
Robert Wild is currently offline Robert WildFriend
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 13:51 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
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 14:18 Go to previous message
Robert Wild is currently offline Robert WildFriend
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: Fri Apr 19 12:24:53 GMT 2024

Powered by FUDForum. Page generated in 0.02476 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top