Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » scope with internal rule
scope with internal rule [message #641739] Sat, 27 November 2010 13:56 Go to next message
chuck  is currently offline chuck Friend
Messages: 160
Registered: July 2010
Senior Member
i have a situation like that:

ClassOp:
(
"bla bla "
"{"

( ROps+=ROp)
...
"}";

ROp :
( var=R )
....
"tot("ref= [type::R]
....
;

R returns mm::type:{R} "..." name=ID


the scope:

public IScope scope_ROp_ref(ROp el, EReference r) {
...
}

in scope provider i have problems because the attribute name with ID is internal to R and i'm getting scope into ROp on var ....and i receive 0 suggetions...

thx for the help...

[Updated on: Sat, 27 November 2010 14:35]

Report message to a moderator

Re: scope with internal rule [message #641743 is a reply to message #641739] Sat, 27 November 2010 14:25 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

i don 't understand your problem. if you don't have any cross references so scoping does not come in place.
once more: a running sample grammar with the scope provider as you use it would help.

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: scope with internal rule [message #641744 is a reply to message #641743] Sat, 27 November 2010 14:38 Go to previous messageGo to next message
chuck  is currently offline chuck Friend
Messages: 160
Registered: July 2010
Senior Member
sorry ...i totally forgot to indicate where is the crossreference...
i edited my post ...
Re: scope with internal rule [message #641745 is a reply to message #641744] Sat, 27 November 2010 15:32 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals

generate myDsl "http://www.xtext.org/example/mydsl/MyDsl"

ClassOp:  

"bla" "bla"
"{"

( ROps+=ROp)

"}";

ROp:
var=R
"tot("ref=[R]")";

R :{R} "..." name=ID;


works for me
And what do you you do in your scope provider?

once more a concrete example with a concrete example model and a description of the problem would help.

btw

R returns mm::type:{R} "..." name=ID


looks strage for me

shouldn't that be

R returns type::R :{R} "..." name=ID;



~Christian



Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Sat, 27 November 2010 15:39]

Report message to a moderator

Re: scope with internal rule [message #641749 is a reply to message #641739] Sat, 27 November 2010 16:00 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Chuck,

I don't see any cross reference in your bla-bla grammar snippet so
scoping is unlikely to be used at any point in your sample. Please be
more specific with your questions.

Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 27.11.10 14:56, schrieb chuck:
> i have a situation like that:
>
> ClassOp:
> (
> "bla bla "
> "{"
> ( ROps+=ROp)
> ..
> "}";
>
> ROp :
> ( var=R )
> ... bla bla
> ;
>
> R:{R} "..." name=ID
>
> in scope provider i have problems because the attribute name with ID is
> internal to R and i'm getting scope into ROp on var ....and i receive 0
> suggetions...
>
> thx for the help...
Re: scope with internal rule [message #641750 is a reply to message #641749] Sat, 27 November 2010 16:01 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Sorry, I should have refreshed the newsreader.

Am 27.11.10 17:00, schrieb Sebastian Zarnekow:
> Hi Chuck,
>
> I don't see any cross reference in your bla-bla grammar snippet so
> scoping is unlikely to be used at any point in your sample. Please be
> more specific with your questions.
>
> Regards,
> Sebastian
Re: scope with internal rule [message #641764 is a reply to message #641739] Sat, 27 November 2010 18:28 Go to previous messageGo to next message
chuck  is currently offline chuck Friend
Messages: 160
Registered: July 2010
Senior Member
this is myscope provider...

i should merge 2 list but it should work with this code?
public IScope scope_ROp_ref(ROp ref, EReference r) {
List union=new ArrayList();

EList<ROp> list_new=((ClassOp)ref.eContainer()).getROps();
union.addAll(list_new);
return Scopes.scopeFor(union);

}

what is wrong?? if i delete this scope provider i receive every right elements but i would receive only ones in COp... sorry for the blabla but there are many strings only for debugging...
Re: scope with internal rule [message #641765 is a reply to message #641764] Sat, 27 November 2010 18:39 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

you add ROps to the Scope but the ref is of Type R - so you won't get any elements in the scope that match the type of the reference.

Maybe you want to do something like

	public IScope scope_ROp_ref(ROp ref, EReference r) {
		List<R> union=new ArrayList<R>();
		for (ROp rop : ((ClassOp)ref.eContainer()).getROps()) {
			union.add(rop.getVar());
		}
		return Scopes.scopeFor(union);
	}


~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: scope with internal rule [message #641813 is a reply to message #641765] Sun, 28 November 2010 11:37 Go to previous message
chuck  is currently offline chuck Friend
Messages: 160
Registered: July 2010
Senior Member
so simple...thx and sorry again Wink
Previous Topic:Recipe for using XText providers elsewhere
Next Topic:How to call function containing uri?
Goto Forum:
  


Current Time: Thu Apr 25 07:19:54 GMT 2024

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

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

Back to the top