Sven and I are going to classify Xtext compared to other concepts and frameworks and demonstrate its capabilities with a refined version of an example I presented in London the week before. After that we discuss the versatile possibilities for extending and customizing the framework and finish with an exciting outlook.
7. How does Xtext
relate to ...
IDE Meta-tooling Platform (IMP)
Dynamic Language Toolkit (DLTK)
8. How does Xtext
relate to ...
IDE Meta-tooling Platform (IMP) !
at
an th
ore th
is m
X xt
te Language Toolkit (DLTK)
Dynamic
9. Is it a language workbench?
JetBrains Meta Programming System
Intentional Domain Workbench Microsoft Oslo
10. Is it a language workbench?
le te ly
m p rc e!
it’s co s ou
ut en
JetBrains Meta Programming System
,b op
Y es a nd
as ed
t ext-b
Intentional Domain Workbench Microsoft Oslo
11. Xtext is a complete environment
for development of textual
- programming languages and
- domain-specific languages.
It is implemented in Java and is
based on Eclipse, EMF, and Antlr.
12. Domain-Specific Language (DSL)
A DSL is a formal, processable language
targeting at a specific viewpoint or
aspect of a software system.
Its semantics, flexibility and notation is
designed in order to support working
with that viewpoint as good as possible.
14. “ Queen to c7.
Check.”
“ Rd2-c2 ,
rook at d2 moves to c2.”
15. Moves in Chess:
!ook at a1 moves to a5.
P
iece S q uare A
ction
De stin ation
"ishop at c8 captures knight at h3.n
P
iece S q uare io
Action
D
es tinat
# b1 x c3
Piece S qua re ction stination
AD e
$2 - g4
ation
S A D
quar
e ction e stin
24. ar
Model
m
m
ra
G
Generator Fragments
Generator
Runtime
Superclass
Subclass Class
LL(*) Parser ecore meta model editor
25. Composable
Code Generator
! generator is composed of “fragments”
! fragments can contribute to:
! Manifest.MF
! plugin.xml
! Guice modules
! Add your own fragments
26. ar
Model
m
m
ra
G
Generator
Runtime
Google Guice
Superclass
Subclass Class
LL(*) Parser ecore meta model editor
29. Dependency Injection with
Googlee
!No dependency to concrete implementation
!No explicit construction
!Easy testing
!Easy composition
30. Configuration of Components
in Xtext
/**
* used to register components to be used within the IDE.
*/
public class DomainmodelUiModule
! ! extends GeneratedDomainmodelUiModule {
!
! @Override
! public Class<? extends ILabelProvider> bindILabelProvider() {
! ! return MySpecialLabelProvider.class;
! }
}
33. Integration with EMF
eclipse
Any EMF-based modeling
Code Generator GMF Editor P R O J E C T
Component
<<abstract>> XMI
XMIResource
Resource
XtextResource Text
Parser Linker Serializer
ValueConverter ScopeProvider Formatter
34. Working with Xtext
// initialization and setup (only needed in standalone mode)
new EntityStandaloneSetup().createInjectorAndDoEMFRegistration();
// standard EMF API usage
ResourceSet resourceSet = new ResourceSet();
Resource resource = resourceSet.getResource(uriToModelFile, true);
Model model = (Model) resource.getContents().get(0);
// print the name of all types to the console
for (Type type : model.getElements()) {
System.out.println(type.getName());
}