Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » [XText] Cross Reference - Custom
[XText] Cross Reference - Custom [message #59345] Thu, 16 July 2009 05:18 Go to next message
Ioan Salau is currently offline Ioan SalauFriend
Messages: 69
Registered: July 2009
Location: Toronto
Member

By default, cross reference implementation uses feature 'name'. I would
like to use a different feature, eventual a combination of one or more
features. One possible usage is to implement generics:



datatype int;
datatype string;

entity Integer {
attr value : int;
}

entity Quantity extends Integer{
attr unitOfMeasurement : string;
}


template <Integer T, Quantity Q>
entity Interval<T,Q> {
attr min : T;
attr max : T;
attr quantity : Q;
}


Although the feature "name" of entity is 'Interval', I would like to use
cross reference as 'Interval<T,Q>' which is a combination of feature
'name' value and template's parameterNames.
How is possible to modify the default behavior of cross reference?

Thanks. Ioan
Re: [XText] Cross Reference - Custom [message #59369 is a reply to message #59345] Thu, 16 July 2009 08:14 Go to previous message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Ioan,

the ScopeProvider instantiates Scopes which will contain ScopedElements.
ScopedElements are literally a simple pair of EObject->Name. Custom
ScopeProviders may create kind of arbitrary Scopes which in turn may
contain any kind of ScopedElement. It is even possible to create more
than one ScopedElement for an EObject.

Please have a look at org.eclipse.xtext.scoping.impl.ScopedElements (I
hope it is available in Xtext 0.7.0 but will be definitly present in
Xtext 0.7.1 which will be released this Friday). It is a useful helper
that will create a Scope and you may pass the algorithm to compute the
name as an argument.

Cross references will be matched against the name of a ScopedElement by
default.

Hope that helps,
Sebastian

Am 16.07.2009 7:18 Uhr, schrieb Ioan:
> By default, cross reference implementation uses feature 'name'. I would
> like to use a different feature, eventual a combination of one or more
> features. One possible usage is to implement generics:
>
>
>
> datatype int;
> datatype string;
>
> entity Integer {
> attr value : int;
> }
>
> entity Quantity extends Integer{
> attr unitOfMeasurement : string;
> }
>
>
> template <Integer T, Quantity Q>
> entity Interval<T,Q> {
> attr min : T;
> attr max : T;
> attr quantity : Q;
> }
>
> Although the feature "name" of entity is 'Interval', I would like to use
> cross reference as 'Interval<T,Q>' which is a combination of feature
> 'name' value and template's parameterNames. How is possible to modify
> the default behavior of cross reference?
>
> Thanks. Ioan
>
Previous Topic:Serialize a single element to a String
Next Topic:Conversion from oaw to tmf xtext - Access values of Datatype refs
Goto Forum:
  


Current Time: Thu Jul 04 09:28:57 GMT 2024

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

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

Back to the top