Skip to main content

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.

Jump to: navigation, search

Difference between revisions of "Xtext Project Plan/Features/CrossReferencing"

(Redirecting to Xtext/Documentation)
 
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.
+

Latest revision as of 11:47, 3 November 2008

Back to the top