xtext webinar
TRANSCRIPT
![Page 1: Xtext Webinar](https://reader034.vdocuments.mx/reader034/viewer/2022052303/554fa19ab4c90586258b49e8/html5/thumbnails/1.jpg)
Eclipse Live Webinar on
Sven Efftinge, Heiko Behrens itemis
http://live.eclipse.org/node/705
![Page 2: Xtext Webinar](https://reader034.vdocuments.mx/reader034/viewer/2022052303/554fa19ab4c90586258b49e8/html5/thumbnails/2.jpg)
What is Xtext?
DSLs - An Example
Underlying Technology
Advanced Topics
Questions & Answers
Agenda
![Page 3: Xtext Webinar](https://reader034.vdocuments.mx/reader034/viewer/2022052303/554fa19ab4c90586258b49e8/html5/thumbnails/3.jpg)
What is
?
![Page 4: Xtext Webinar](https://reader034.vdocuments.mx/reader034/viewer/2022052303/554fa19ab4c90586258b49e8/html5/thumbnails/4.jpg)
A Language Framework
![Page 5: Xtext Webinar](https://reader034.vdocuments.mx/reader034/viewer/2022052303/554fa19ab4c90586258b49e8/html5/thumbnails/5.jpg)
Yet another Parser Generator?
JavaCC
![Page 6: Xtext Webinar](https://reader034.vdocuments.mx/reader034/viewer/2022052303/554fa19ab4c90586258b49e8/html5/thumbnails/6.jpg)
Yet another Parser Generator?
JavaCCNo, it’s more than that!
![Page 7: Xtext Webinar](https://reader034.vdocuments.mx/reader034/viewer/2022052303/554fa19ab4c90586258b49e8/html5/thumbnails/7.jpg)
How does Xtext relate to ...
IDE Meta-tooling Platform (IMP)
Dynamic Language Toolkit (DLTK)
![Page 8: Xtext Webinar](https://reader034.vdocuments.mx/reader034/viewer/2022052303/554fa19ab4c90586258b49e8/html5/thumbnails/8.jpg)
How does Xtext relate to ...
IDE Meta-tooling Platform (IMP)
Dynamic Language Toolkit (DLTK)Xtext is more than that!
![Page 9: Xtext Webinar](https://reader034.vdocuments.mx/reader034/viewer/2022052303/554fa19ab4c90586258b49e8/html5/thumbnails/9.jpg)
Is it a language workbench?
JetBrains Meta Programming System
Intentional Domain Workbench Microsoft Oslo
![Page 10: Xtext Webinar](https://reader034.vdocuments.mx/reader034/viewer/2022052303/554fa19ab4c90586258b49e8/html5/thumbnails/10.jpg)
Is it a language workbench?
JetBrains Meta Programming System
Intentional Domain Workbench Microsoft Oslo
Yes, but it’s completely
text-based and open source!
![Page 11: Xtext Webinar](https://reader034.vdocuments.mx/reader034/viewer/2022052303/554fa19ab4c90586258b49e8/html5/thumbnails/11.jpg)
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.
![Page 12: Xtext Webinar](https://reader034.vdocuments.mx/reader034/viewer/2022052303/554fa19ab4c90586258b49e8/html5/thumbnails/12.jpg)
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.
![Page 13: Xtext Webinar](https://reader034.vdocuments.mx/reader034/viewer/2022052303/554fa19ab4c90586258b49e8/html5/thumbnails/13.jpg)
Rd2-c2
![Page 14: Xtext Webinar](https://reader034.vdocuments.mx/reader034/viewer/2022052303/554fa19ab4c90586258b49e8/html5/thumbnails/14.jpg)
,rook at d2 moves to c2.
Rd2-c2
”
Queen to c7.“”
“
Check.
![Page 15: Xtext Webinar](https://reader034.vdocuments.mx/reader034/viewer/2022052303/554fa19ab4c90586258b49e8/html5/thumbnails/15.jpg)
Moves in Chess:
!ook at a1 moves to a5.
"ishop at c8 captures knight at h3.
# b1 x c3
$2 - g4
Piece
Piece
Piece
Square
Square
Square
Square
Action
Action
Action
Action
Destination
Destination
Destination
Destination
![Page 16: Xtext Webinar](https://reader034.vdocuments.mx/reader034/viewer/2022052303/554fa19ab4c90586258b49e8/html5/thumbnails/16.jpg)
Rook a1 move a5
Bishop c8 capture h3 Knight
Knight b1 capture c3 Queen
Pawn g2 move g4
SourceDestinationPiece
Move
WhitePlayerBlackPlayer
Game«enum»
Piece*
![Page 17: Xtext Webinar](https://reader034.vdocuments.mx/reader034/viewer/2022052303/554fa19ab4c90586258b49e8/html5/thumbnails/17.jpg)
"ishop at c8 captures knight at h3
" c8 x h3
![Page 18: Xtext Webinar](https://reader034.vdocuments.mx/reader034/viewer/2022052303/554fa19ab4c90586258b49e8/html5/thumbnails/18.jpg)
Model (textfile)
White: "Mayfield"
Black: "Trinks"
pawn at e2 moves to e4
pawn at f7 moves to g5
K b1 - c3
f7 - f5
queen at d1 moves to h5
// 1-0
![Page 19: Xtext Webinar](https://reader034.vdocuments.mx/reader034/viewer/2022052303/554fa19ab4c90586258b49e8/html5/thumbnails/19.jpg)
DEMO
![Page 20: Xtext Webinar](https://reader034.vdocuments.mx/reader034/viewer/2022052303/554fa19ab4c90586258b49e8/html5/thumbnails/20.jpg)
Underlying Technology
![Page 21: Xtext Webinar](https://reader034.vdocuments.mx/reader034/viewer/2022052303/554fa19ab4c90586258b49e8/html5/thumbnails/21.jpg)
Superclass
Subclass Class
ecore meta modelLL(*) Parser editor
Model
Grammar
Generator
Runtime
![Page 22: Xtext Webinar](https://reader034.vdocuments.mx/reader034/viewer/2022052303/554fa19ab4c90586258b49e8/html5/thumbnails/22.jpg)
Java Persistence API (JPA)package templates;
import java.io.Serializable;
import java.util.*;
import javax.persistence.*;
@SuppressWarnings("serial")
@Entity
public class Customer implements Serializable {
! private Long id;
! private String name;
! private Address address;
! private Set<Order> orders = new HashSet<Order>();
! // No-arg constructor
! public Customer() {
! }
! @Id
! public Long getId() {
! ! return id;
! }
! public void setId(Long id) {
! ! this.id = id;
! }
! public String getName() {
! ! return name;
! }
! public void setName(String name) {
! ! this.name = name;
! }
! public Address getAddress() {
! ! return address;
! }
! public void setAddress(Address address) {
! ! this.address = address;
! }
! @OneToMany
! public Collection<Order> getOrders() {
! ! return orders;
! }
! public void setOrders(Set<Order> orders) {
! ! this.orders = orders;
! }
}
entity Customer {
! property name : String
! property address : Address
! property orders : Order[]
}
![Page 23: Xtext Webinar](https://reader034.vdocuments.mx/reader034/viewer/2022052303/554fa19ab4c90586258b49e8/html5/thumbnails/23.jpg)
DEMO
![Page 24: Xtext Webinar](https://reader034.vdocuments.mx/reader034/viewer/2022052303/554fa19ab4c90586258b49e8/html5/thumbnails/24.jpg)
Superclass
Subclass Class
ecore meta modelLL(*) Parser editor
Model
Grammar
Generator
Runtime
Generator Fragments
![Page 25: Xtext Webinar](https://reader034.vdocuments.mx/reader034/viewer/2022052303/554fa19ab4c90586258b49e8/html5/thumbnails/25.jpg)
Composable
Code Generator
! generator is composed of “fragments”
! fragments can contribute to:
! Manifest.MF
! plugin.xml
! Guice modules
! Add your own fragments
![Page 26: Xtext Webinar](https://reader034.vdocuments.mx/reader034/viewer/2022052303/554fa19ab4c90586258b49e8/html5/thumbnails/26.jpg)
Superclass
Subclass Class
ecore meta modelLL(*) Parser editor
Model
Grammar
Generator
Runtime
Googl
e G
uic
e
![Page 28: Xtext Webinar](https://reader034.vdocuments.mx/reader034/viewer/2022052303/554fa19ab4c90586258b49e8/html5/thumbnails/28.jpg)
licensed by http://www.wordle.net/
MyCustomLabelProvider
![Page 29: Xtext Webinar](https://reader034.vdocuments.mx/reader034/viewer/2022052303/554fa19ab4c90586258b49e8/html5/thumbnails/29.jpg)
Dependency Injection with Googlee
!No dependency to concrete implementation
!No explicit construction
!Easy testing
!Easy composition
![Page 30: Xtext Webinar](https://reader034.vdocuments.mx/reader034/viewer/2022052303/554fa19ab4c90586258b49e8/html5/thumbnails/30.jpg)
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;
! }
}
![Page 31: Xtext Webinar](https://reader034.vdocuments.mx/reader034/viewer/2022052303/554fa19ab4c90586258b49e8/html5/thumbnails/31.jpg)
DEMO
![Page 32: Xtext Webinar](https://reader034.vdocuments.mx/reader034/viewer/2022052303/554fa19ab4c90586258b49e8/html5/thumbnails/32.jpg)
Advanced Topics
![Page 33: Xtext Webinar](https://reader034.vdocuments.mx/reader034/viewer/2022052303/554fa19ab4c90586258b49e8/html5/thumbnails/33.jpg)
Integration with EMFmodeling
P R O J E C T
e c l i p s e
GMF EditorCode GeneratorAny EMF-based
Component
<<abstract>>
ResourceXMIResource XMI
XtextResource
Parser SerializerLinker
ScopeProviderValueConverter Formatter
XtextResource Text
![Page 34: Xtext Webinar](https://reader034.vdocuments.mx/reader034/viewer/2022052303/554fa19ab4c90586258b49e8/html5/thumbnails/34.jpg)
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());
}
![Page 35: Xtext Webinar](https://reader034.vdocuments.mx/reader034/viewer/2022052303/554fa19ab4c90586258b49e8/html5/thumbnails/35.jpg)
Eclipse Helios
•Model Index
•Grammar Mixins
•Base Language
•UI Features
![Page 36: Xtext Webinar](https://reader034.vdocuments.mx/reader034/viewer/2022052303/554fa19ab4c90586258b49e8/html5/thumbnails/36.jpg)
![Page 37: Xtext Webinar](https://reader034.vdocuments.mx/reader034/viewer/2022052303/554fa19ab4c90586258b49e8/html5/thumbnails/37.jpg)
Questions & Answers