Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » cross-reference problem(cross-reference in Xtext)
cross-reference problem [message #628701] Thu, 23 September 2010 17:46 Go to next message
anders Mising name is currently offline anders Mising nameFriend
Messages: 15
Registered: September 2010
Junior Member
Hello,

I want to reference an object within a rule...example:

Frame:
'frame' name=ID ('(' signals+=Signal ')')* ';'
;

Cluster:
'cluster' name=ID '{' (signals+=[Signal])* '}' ';'
;


Signal:
'signal' name=ID
;

The editor complains that "Could not resolve reference to Signal '???'". This types of reference is not supported?

regards,
Anders
Re: cross-reference problem [message #628714 is a reply to message #628701] Thu, 23 September 2010 18:02 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Anders,

the grammar looks good to me. How did you implement your scoping? I'd
assume that your signals will be available under their fully qualified
name which is framename.signalname (which is the default). You have to
customize the scoping or the resource description for signals.

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

Am 23.09.10 19:46, schrieb anders:
> Hello,
>
> I want to reference an object within a rule...example:
>
> Frame:
> 'frame' name=ID ('(' signals+=Signal ')')* ';'
> ;
>
> Cluster:
> 'cluster' name=ID '{' (signals+=[Signal])* '}' ';'
> ;
>
>
> Signal:
> 'signal' name=ID ;
>
> The editor complains that "Could not resolve reference to Signal '???'".
> This types of reference is not supported?
>
> regards,
> Anders
Re: cross-reference problem [message #628717 is a reply to message #628701] Thu, 23 September 2010 18:36 Go to previous messageGo to next message
anders Mising name is currently offline anders Mising nameFriend
Messages: 15
Registered: September 2010
Junior Member
hi sebastian,

thanks for the quick answer.

And sorry i am new to xtext and did not fully understand the "How did you implement your scoping?" question.

The complete grammar looks like:

grammar org.xtext.example.mydsl3.MyDsl with org.eclipse.xtext.common.Terminals

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

Model:
greetings+=Greeting*

(frames+=Frame)*
(cluster+=Cluster)*
;

Greeting:
'Hello' name=ID '!'
;

Frame:
'frame' name=ID ('(' signals+=Signal ')')* ';'
;

Cluster:
'cluster' name=ID '{' (signals+=[Signal])* '}' ';'
;


Signal:
'signal' name=ID
;


regards,
Anders
Re: cross-reference problem [message #628723 is a reply to message #628717] Thu, 23 September 2010 19:01 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Anders,

please refer to the docs for details on scoping.
Meanwhile try to edit the generator workflow for your language and
enable the SimpleNameFragment instead of the QualifiedNameFragment as a
quick and dirty workaround.

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

Am 23.09.10 20:36, schrieb anders:
> hi sebastian,
>
> thanks for the quick answer.
>
> And sorry i am new to xtext and did not fully understand the "How did
> you implement your scoping?" question.
>
> The complete grammar looks like:
>
> grammar org.xtext.example.mydsl3.MyDsl with
> org.eclipse.xtext.common.Terminals
>
> generate myDsl "http://www.xtext.org/example/mydsl3/MyDsl"
>
> Model:
> greetings+=Greeting*
>
> (frames+=Frame)*
> (cluster+=Cluster)*
> ;
>
> Greeting:
> 'Hello' name=ID '!'
> ;
>
> Frame:
> 'frame' name=ID ('(' signals+=Signal ')')* ';'
> ;
>
> Cluster:
> 'cluster' name=ID '{' (signals+=[Signal])* '}' ';'
> ;
>
>
> Signal:
> 'signal' name=ID ;
>
>
> regards,
> Anders
Re: cross-reference problem [message #629039 is a reply to message #628723] Sun, 26 September 2010 17:30 Go to previous messageGo to next message
emy is currently offline emyFriend
Messages: 16
Registered: September 2010
Junior Member
Hello Sebastian,

I am having exactly the same problem as Anders.
I have checked:
Quote:

Meanwhile try to edit the generator workflow for your language and enable the SimpleNameFragment instead of the QualifiedNameFragment as a
quick and dirty workaround.



It is already modified in my model since I have created the XText project from Ecore model.

Also I have checked the scoping part in the documentation
Quote:

An IScopeProvider is responsible for providing an IScope for a given context EObject and EReference.
The returned IScope should contain all target candidates for the given object and cross-reference.


But I couldn't go anywhere from there Confused neither what should I do? or where to write the code? or how ?

Note: I am also new with XText
Re: cross-reference problem [message #629040 is a reply to message #629039] Sun, 26 September 2010 17:33 Go to previous messageGo to next message
emy is currently offline emyFriend
Messages: 16
Registered: September 2010
Junior Member
I am sorry I thought of putting my code as well that may help you understand my problem
// modification of automatically generated by Xtext
grammar org.xtext.example.iccpn.ICCPN with org.eclipse.xtext.common.Terminals 

import "platform:/resource/ICCPN/model/ICCPN.ecore" 

import "http://www.eclipse.org/emf/2002/Ecore" as ecore

ICCPN returns ICCPN:
	{ICCPN}
    (
    	'<eca>'
	    ('<event>'(places+=Place))?
	    (transtions+=Transition)?
	    '</eca>'
    )*;

Place returns Place:
	PrimitiveEvent /*there are other alternatives that I have commented for the timebeing*/;

Transition returns Transition:
	RuleTransition /*there are other alternatives that I have commented for the timebeing*/;

EString returns ecore::EString:
	STRING | ID;

PrimitiveEvent returns PrimitiveEvent:
	{PrimitiveEvent}
	'<cterm type=primitive>' (eventName=EString)  '</cterm>''</event>'
    (('<normalArc>' (normalConnection=[Transition|EString])'</normalArc>')? |
     ('<inhibitorArc>'(inhibitorConnection=[Transition|EString])'</inhibitorArc>')? | 
     ('<startArc>'(startConnection=[Transition|EString])'</startArc>')? |
     ('<endArc>'(endConnection=[Transition|EString])'</endArc>')?
    )?;
RuleTransition returns RuleTransition:
	{RuleTransition}
	'<ruleTransition>' (transitionName=EString)
	('<condition>'('True'|condition=EString )'</condition>')?
	'</ruleTransition>'
	('<action>' 
		((primitiveEvents+=[PrimitiveEvent|EString])*)
	'</action>');
Re: cross-reference problem [message #629865 is a reply to message #628701] Wed, 29 September 2010 19:08 Go to previous messageGo to next message
anders Mising name is currently offline anders Mising nameFriend
Messages: 15
Registered: September 2010
Junior Member
hi Sebastian,

thanks for the reply and the nice way of saying RTFM

The SimpleNameFragment did the trick, but i want of course know more what this means.

Meantime i am studying the xtext manual, but i must admit it is not easy reading.

regards,
Anders
Re: cross-reference problem [message #630151 is a reply to message #629865] Thu, 30 September 2010 19:28 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1193
Registered: July 2009
Senior Member
Hi,

quick and dirty explanation SimpleName/QualifiedName:

...
Container: 'cont' name=ID '{' elements+=Element*'}';
Element:Child|Reference;
Child: 'child' name=ID;
Reference: 'reference' ref=[Child|CorrectTerminalOrDatatypeRule];
...

Sample model:
cont Container1 {child c1 child c2 child c3}
cont Container2 {child c1 child c2 child c3}

The fragments determine which default way of naming and referencing objects will be used.

If you use the SimpleNameFragment each Object is identified by the value of its name feature only, so you will have two objects with name c1, two with name c2 etc. which will potentially cause trouble when trying to reference c1 (which one should it be).

If you use the QualifiedNameFragment each object is assigned a qualified name, that includes its "own" name along with the names of its containers so you will have Container1.c1, Container1.c2, Container2.c1 etc. Of course in this case you may also have to refer to an object via its qualified name (the object's own name may not suffice).

Sample
cont Container1 {
child c1
child c2
child c3
ref c1//refers to c1 in Container1
ref Container2.c1 //refers to c1 in Container2
}
cont Container2 {
child c1
child c2
child c3
}

Alex
Re: cross-reference problem [message #630309 is a reply to message #628701] Fri, 01 October 2010 14:20 Go to previous message
anders Mising name is currently offline anders Mising nameFriend
Messages: 15
Registered: September 2010
Junior Member
thanks Alex for this explanation,

Actually the SimpleNameFragment will solve my problem since all objects are considered global within its own file.

regards,
Anders

Previous Topic:Linking doesn't work after deployment
Next Topic:Error after I run MWE2
Goto Forum:
  


Current Time: Fri Apr 26 21:37:05 GMT 2024

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

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

Back to the top