Eclipse Xtext Infrastructure

This is one of a sequence of pages that I have wriiten about Xtext which start here.

On these pages we look at things that we may need to do that can't be done by defining the grammar and generator files alone.

Eclipse is defined to be very extendable (use of plugins, use of Google Juice, and so on) and Xtext continues that use of this type of approach. here we discuss the way these things are provided in xtext using:

For a discussion of how to use these things outside of Eclipse see this blog.

Runtime Topics

We have looked at the Ecore model and how it is generated. It is a static tree stucture for the DSL (use of EReference makes it a graph structure rather than a tree).

We also need to understand some tree-like structures, that are generated when the DSL is running, such as naming and scoping. These are used to allow elements in our language to refer to other elements, that is, provide non-containment links.

These topics are discussed on the following sub-pages:


Generator is composed of 'fragments' which can contribute to various components:


Some built-in fragments are setup in MWE2 file. To use your own fragment:

declaring fragments

A generator fragment must implement the interface IGeneratorFragment (src).

or if we are implementing IValueConverterService we use:

public class MyDslRuntimeModule extends org.xtext.example.mydsl.AbstractMyDslRuntimeModule {
        public Class<? extends IValueConverterService> bindIValueConverterService() {
                return MyTerminalConverters.class;

See this video for details.

Other Possible Fragments:

Class Generated Artifacts Further Information
grammarAccess.GrammarAccessFragment   Java API to access grammar elements (required by several other fragments)
ecore.EcoreGeneratorFragment (src) EMF code for generated models generates Java API for the generated EPackages
parseTreeConstructor.ParseTreeConstructorFragment   the serialization component (1.0)
resourceFactory.ResourceFactoryFragment   a custom ResourceFactory for use with EMF
parser.antlr.XtextAntlrGeneratorFragment (src) ANTLR grammar, parser, lexer and related services The antlr parser generator fragment
scoping.ImportURIScopingFragment   scoping and exporting API
exporting.SimpleNamesFragment   scoping and exporting API
scoping.ImportNamespacesScopingFragment   scoping and exporting API
exporting.QualifiedNamesFragment   scoping and exporting API
builder.BuilderIntegrationFragment   scoping and exporting API
generator.GeneratorFragment   generator API
formatting.FormatterFragment   formatter API
GrammarAccessFragment (src) Access to the grammar
ResourceFactoryFragment (src) EMF resource factory  
ParseTreeConstructorFragment (src) Model-to-text serialization  
ImportNamespacesScopingFragment (src) Index-based scoping  
validation.JavaValidatorFragment (src) Model validation java-based API for validation
FormatterFragment (src) Code formatter  
labeling.LabelProviderFragment (src) Label provider labeling API
outline.OutlineTreeProviderFragment (src) Outline view configuration outline API
outline.QuickOutlineFragment   outline API
quickfix.QuickfixProviderFragment   quickfix API
contentAssist.JavaBasedContentAssistFragment   content assist API
junit.Junit4Fragment   generates junit test support classes into Generator#pathTestProject
projectWizard.SimpleProjectWizardFragment   project wizard (optional)
refactoring.RefactorElementNameFragment   rename refactoring
types.TypesGeneratorFragment   provides the necessary bindings for java types integration
JavaBasedContentAssistFragment (src) Java-based content assist  
parser.antlr.XtextAntlrUiGeneratorFragment (src) Content assist helper based on ANTLR generates a more lightweight Antlr parser and lexer tailored for content assist
xbase.XbaseGeneratorFragment   generates the required bindings only if the grammar inherits from Xbase
templates.CodetemplatesGeneratorFragment   provides a preference page for template proposals
compare.CompareFragment   provides a compare view

Guice Components

Google guice is setup using modules.

Can write own guice components, changed in module: module


metadata block
see also: itemis blog
Correspondence about this page

This site may have errors. Don't use for critical systems.

Copyright (c) 1998-2022 Martin John Baker - All rights reserved - privacy policy.