|
|
Line 1: |
Line 1: |
− | The cross referencing features allows for specification of cross references within an xtext grammar.
| + | #REDIRECT [[Xtext/Documentation]] |
− | | + | |
− | 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.
| + | |
− | */
| + | |
− | URI[] getLinks(LeafNode text, CrossReference ref, EObject model);
| + | |
− | }
| + | |
− | | + | |
− | A linking service is configured using the service framework shipped with xtext.
| + | |