[XText] Cross Reference - Custom [message #59345] |
Thu, 16 July 2009 01:18  |
Eclipse User |
|
|
|
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 04:14  |
Eclipse User |
|
|
|
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
>
|
|
|
Powered by
FUDForum. Page generated in 0.02753 seconds