Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Xtext Project Plan/Features/CrossReferencing
< Xtext Project Plan
Revision as of 07:58, 24 July 2008 by Sven.efftinge.typefox.io (Talk | contribs)
The cross referencing features allows for specification of cross references within an xtext grammar.
To do the linking several things are required:
- the derived/referenced ecore model contains a respective cross reference (containment=false).
- the syntax of a crossreference is expressed by a lexer rule. usually an identifier or a fully qualified name
- there is a linking phase right after parsing
- there is linking semantics provided for a specific link.
In the grammar a cross reference is specified using square brackets.
CrossReference : '[' ReferencedEClass ('|' lexerRuleName)? ']'
Example:
Reference : type=[Entity|ID] name=ID;
That results in a Type 'Reference' with an EReference 'type' of type 'Entity' and an EAttribute 'name' of type 'EString' (because ID is of type EString).
For each grammar a linking service can be implemented/configured, which implements the following interface:
interface ILinkingService { /** * is called to compute the URI of the EObject referenced by * the given text in the given model. * * returns the computed URI or null if it couldn't be computed */ URI getLink(LeafNode text, CrossReference ref, EObject model); /** * is called to compute the URI of the EObject referenced by * the given text in the given model. */ URI[] getLinks(LeafNode text, CrossReference ref, EObject model); }
A linking service is configured using the service framework shipped with xtext.