Xtext Documentation.Pdf

Total Page:16

File Type:pdf, Size:1020Kb

Xtext Documentation.Pdf Xtext Documentation September 26, 2014 Contents I. Getting Started 9 1. 5 Minutes Tutorial 10 1.1. Creating A New Xtext Project . 10 1.2. Generating The Language Infrastructure . 10 1.3. Try The Editor . 11 1.4. Conclusion . 12 2. 15 Minutes Tutorial 14 2.1. Create A New Xtext Project . 14 2.2. Write Your Own Grammar . 16 2.3. Generate Language Artifacts . 19 2.4. Run the Generated IDE Plug-in . 20 2.5. Second Iteration: Adding Packages and Imports . 20 3. 15 Minutes Tutorial - Extended 27 3.1. Writing a Code Generator With Xtend . 29 3.2. Unit Testing the Language . 34 3.3. Creating Custom Validation Rules . 35 4. Five simple steps to your JVM language 37 4.1. Step One: Create A New Xtext Project . 38 4.2. Step Two: Write the Grammar . 38 4.3. Step Three: Generate Language Artifacts . 43 4.4. Step Four: Define the Mapping to JVM Concepts . 43 4.5. Step Five : Try the Editor! . 48 II. Seven JVM Languages Built With Xbase 50 5. Introduction 51 5.1. Write the Grammar . 51 5.2. Map to Java . 51 5.3. CAUTION: This is Provisional API . 52 5.4. Common Requirements . 52 5.5. Getting the Code . 53 2 5.6. A Short Xtend Primer . 53 6. Scripting Language 57 6.1. Overview . 57 6.2. Running the Example . 58 6.3. Grammar . 58 6.4. Translation to Java . 59 7. Build Language 61 7.1. Overview . 61 7.2. Running the Example . 62 7.3. Grammar . 62 7.4. Translation to Java . 63 7.5. Validation . 65 7.6. Imports . 66 7.7. Operator Overloading . 67 7.8. Run as... Integration . 67 8. DSL for MongoDB 68 8.1. Overview . 69 8.2. Running the Example . 70 8.3. Grammar . 70 8.4. Translation to Java . 72 8.5. Qualified Name Provider . 77 8.6. Validation . 78 8.7. IDE Enhancements . 79 9. DSL for Guice 81 9.1. Overview . 81 9.2. Running the Example . 82 9.3. Grammar . 83 9.4. Translation to Java . 84 9.5. Validation . 88 10.Http Routing Language 89 10.1. Overview . 89 10.2. Running the Example . 90 10.3. Grammar . 90 10.4. Translation to Java . 91 11.Template Language 95 11.1. Overview . 95 11.2. Running the Example . 96 11.3. Grammar . 96 11.4. Translation to Java . 97 3 11.5. Extending the Compiler . 100 11.6. Type Computation . 102 11.7. Value Converter . 103 11.8. Content Assist . 103 11.9. Syntax Highlighting . 104 12.Little Tortoise 105 12.1. Overview . 105 12.2. Running the Example . 107 12.3. Grammar . 107 12.4. Translation to Java . 108 12.5. Interpreter . 109 12.6. Literal Classes . 111 III. Reference Documentation 112 13.Overview 113 13.1. What is Xtext? . 113 13.2. How Does It Work? . 113 13.3. Xtext is Highly Configurable . 113 13.4. Who Uses Xtext? . 114 13.5. Who is Behind Xtext? . 114 13.6. What is a Domain-Specific Language . 114 14.The Grammar Language 116 14.1. A First Example . 116 14.2. The Syntax . 118 14.2.1. Language Declaration . 118 14.2.2. EPackage Declarations . 118 14.2.3. Rules . 123 14.2.4. Parser Rules . 127 14.2.5. Hidden Terminal Symbols . 134 14.2.6. Data Type Rules . 135 14.2.7. Enum Rules . 136 14.2.8. Syntactic Predicates . 137 14.3. Ecore Model Inference . 138 14.3.1. Type and Package Generation . 138 14.3.2. Feature and Type Hierarchy Generation . 139 14.3.3. Enum Literal Generation . 140 14.3.4. Feature Normalization . 140 14.3.5. Error Conditions . 141 14.4. Grammar Mixins . 141 14.5. Common Terminals . 142 4 15.Configuration 144 15.1. The Language Generator . 144 15.1.1. A Short Introduction to MWE2 . 144 15.1.2. General Architecture . 146 15.1.3. Standard Generator Fragments . 149 15.2. Dependency Injection in Xtext with Google Guice . 149 15.2.1. The Module API . 150 15.2.2. Obtaining an Injector . 152 15.3. Continuous Integration (with Maven) . 153 15.3.1. An overview of the example projects . 153 15.3.2. Building an Xtext language with Maven and Tycho . 153 15.3.3. Integration in Standard Maven Builds . 157 16.Runtime Concepts 159 16.1. Runtime Setup (ISetup) . 159 16.2. Setup within Eclipse-Equinox (OSGi) . 159 16.3. Logging . 160 16.4. Code Generation / Compilation . 160 16.4.1. IGenerator . ..
Recommended publications
  • How to Develop Your Own Dsls in Eclipse Using Xtend and Xtext ?
    How to develop your own DSLs in Eclipse using Xtend and Xtext ? Daniel Strmečki | Software Developer 19.05.2016. BUSINESS WEB APPLICATIONS HOW TO DEVELOP YOUR OWN DSLS IN ECLIPSE USING XTEXT AND XTEND? Content 1. DSLs › What are DSLs? › Kinds of DSLs? › Their usage and benefits… 2. Xtend › What kind of language is Xtend? › What are its benefits compared to classic Java? 3. Xtext › What is a language development framework? › How to develop you own DSL? 4. Short demo 5. Conclusion 2 | 19.05.2016. BUSINESS WEB APPLICATIONS | [email protected] | www.evolva.hr HOW TO DEVELOP YOUR OWN DSLS IN ECLIPSE USING XTEXT AND XTEND? DSL acronym Not in a Telecommunications context: Digital Subscriber Line But in a Software Engineering context: Domain Specific Languages 3 | 19.05.2016. BUSINESS WEB APPLICATIONS | [email protected] | www.evolva.hr HOW TO DEVELOP YOUR OWN DSLS IN ECLIPSE USING XTEXT AND XTEND? Domain Specific Languages General-Purpose Languages (GPLs) › Languages broadly applicable across application domains › Lack specialized features for a particular domain › XML, UML, Java , C++, Python, PHP… Domain specific languages (DSLs) › Languages tailored to for an application in a specific domain › Provide substantial gains in expressiveness and ease of use in their domain of application › SQL, HTML, CSS, Logo, Mathematica, Marcos, Regular expressions, Unix shell scripts, MediaWiki, LaTeX… 4 | 19.05.2016. BUSINESS WEB APPLICATIONS | [email protected] | www.evolva.hr HOW TO DEVELOP YOUR OWN DSLS IN ECLIPSE USING XTEXT AND XTEND? Domain Specific Languages A novelty in software development › DSL for programming numerically controlled machine tools, was developed in 1957–1958 › BNF dates back to 1959 (M.
    [Show full text]
  • Expressive and Efficient Model Transformation with an Internal DSL
    Expressive and Efficient Model Transformation with an Internal DSL of Xtend Artur Boronat Department of Informatics, University of Leicester, UK [email protected] ABSTRACT 1 INTRODUCTION Model transformation (MT) of very large models (VLMs), with mil- Over the past decade the application of MDE technology in indus- lions of elements, is a challenging cornerstone for applying Model- try has led to the emergence of very large models (VLMs), with Driven Engineering (MDE) technology in industry. Recent research millions of elements, that may need to be updated using model efforts that tackle this problem have been directed at distributing transformation (MT). This situation is characterized by important MT on the Cloud, either directly, by managing clusters explicitly, or challenges [26], starting from model persistence using XMI serial- indirectly, via external NoSQL data stores. In this paper, we draw at- ization with the Eclipse Modeling Framework (EMF) [31] to scalable tention back to improving efficiency of model transformations that approaches to apply model updates. use EMF natively and that run on non-distributed environments, An important research effort to tackle these challenges was showing that substantial performance gains can still be reaped on performed in the European project MONDO [19] by scaling out that ground. efficient model query and MT engines, such as VIATRA[3] and We present Yet Another Model Transformation Language (YAMTL), ATL/EMFTVM [46], building on Cloud technology either directly, a new internal domain-specific language (DSL) of Xtend for defin- by using distributed clusters of servers explicitly, or indirectly, by ing declarative MT, and its execution engine.
    [Show full text]
  • Xtext / Sirius - Integration the Main Use-Cases
    Xtext / Sirius - Integration The Main Use-Cases White Paper December 2017 SUMMARY Chapter 1 Introduction 1 Chapter 2 Let’s start 2 Chapter 2.1 What modeling is about? 2 Chapter 2.2 Benefits of graphical modeling 3 Chapter 2.3 Benefits of textual modeling 5 Chapter 3 What is Xtext? 6 Chapter 4 What is Sirius? 8 Chapter 5 Xtext & Sirius in action 10 Chapter 5.1 Case 1: Editing the same models both graphically and textually 10 Chapter 5.2 Case 2: Embedding an Xtext Editor into Sirius 15 Chapter 6 How may we help you? 18 Introduction Introduction You are going to create a domain-specific modeling tool and you wonder how users will edit and visualize the models: textually with a dedicated syntax and a rich textual editor ? or graphically with diagrams drawn with a palette and smart tools? Both approaches are interesting and can be used complementary: While text is able to carry more detailed information, a diagram highlights the relationship between elements much better. In the end, a good tool should combine both, and use each notation where it suits best. In this white paper, we will explain the benefits of each approach. Then we will present Eclipse Xtext and Eclipse Sirius, two open-source frameworks for the development of textual and graphical model editors. And finally, we will detailed two use-cases where these two technologies can be integrated in the same modeling workbench. 1 Let’s start Let’s start What modeling is about? Before presenting the graphical and textual modeling approaches, it is important to briefly clarify what we mean by modeling.
    [Show full text]
  • On Modularity and Performances of External Domain-Specific Language Implementations Manuel Leduc
    On modularity and performances of external domain-specific language implementations Manuel Leduc To cite this version: Manuel Leduc. On modularity and performances of external domain-specific language implementa- tions. Software Engineering [cs.SE]. Université Rennes 1, 2019. English. NNT : 2019REN1S112. tel-02972666 HAL Id: tel-02972666 https://tel.archives-ouvertes.fr/tel-02972666 Submitted on 20 Oct 2020 HAL is a multi-disciplinary open access L’archive ouverte pluridisciplinaire HAL, est archive for the deposit and dissemination of sci- destinée au dépôt et à la diffusion de documents entific research documents, whether they are pub- scientifiques de niveau recherche, publiés ou non, lished or not. The documents may come from émanant des établissements d’enseignement et de teaching and research institutions in France or recherche français ou étrangers, des laboratoires abroad, or from public or private research centers. publics ou privés. THÈSE DE DOCTORAT DE L’UNIVERSITE DE RENNES 1 COMUE UNIVERSITE BRETAGNE LOIRE Ecole Doctorale N°601 Mathèmatique et Sciences et Technologies de l’Information et de la Communication Spécialité : Informatique Par Manuel LEDUC On modularity and performance of External Domain-Specific Language im- plementations Thèse présentée et soutenue à RENNES , le 18 Décembre 2019 Unité de recherche : Equipe DiverSE, IRISA Rapporteurs avant soutenance : Paul Klint, Professeur, CWI, Amsterdam, Pays-Bas Juan De Lara, Professeur, Université autonome de Madrid, Madrid, Espagne Composition du jury : Président : Olivier Ridoux, Professeur, Université de Rennes 1, Rennes, France Examinateurs : Nelly Bencomo, Lecturer in Computer Science, Aston University, Birmingham, Royaume-Uni Jean-Remy Falleri, Maître de conférences HDR, Université de Bordeaux, Bordeaux, France Gurvan Le Guernic, Ingénieur de recherche, DGA, Rennes, France Dir.
    [Show full text]
  • Galileo Release Train 2009
    Galileo Release Train 2009 1 6 Years in a Row 33 Projects 24 million LOC 23 Projects 18 million LOC 21 Projects 17 million LOC 10 Projects WTP BIRT TPTP TPTP EMF CDT VE CDT Ganymede Galileo Eclipse 3.0 Eclipse 3.1 Callisto Europa June 28 2004 June 28 2005 June 30 2006 June 29, 2007 June 25, 2008 June 24, 2008 2 Galileo Stats - 33 project teams - 24+ million LOC - 44 companies providing committers 3 Why a release train? Help spur commercial adoption of Eclipse technology Consumers use many projects not just the Platform Inter-dependency between projects Eclipse project teams are independent BUT the project code is inter-dependent. Alignment of version compatibility Remove latency between project releases 4 How did we make it happen? Architecture Modular & Extensible Architecture vs Monolithic Release Governance Projects remain independent Process Open source development process Frequent milestone releases 5 Key Themes Advancement in Eclipse Runtime Technology Growth of Eclipse Modeling Domain Specific Languages Expanding Enterprise Adoption 6 Eclipse Runtime Technology New Support for OSGi in Equinox Implementation of the new OSGi 4.2 specification Distributed OSGi services PDE Improvements OSGI Declarative Services tooling Publish to a p2 repository API Analysis Tools Target platform support in PDE Make it easier to develop software that runs on EclipseRT runtimes EclipseRT runtime SDKs available in Galileo repository PDE tooling P2 Provisioning Improvements More flexible UI for RCP applications New Publisher tool that make it easier to publish content to repositories 7 Modeling Domain Specific Languages Developers need to deal with a growing set of APIs APIs for different infrastructure services, standards, business standards, etc.
    [Show full text]
  • Eclipse Roadmap V5
    Eclipse RoadMap v5 Introduction As required by the Eclipse Development Process, this document describes the 2010 Eclipse Roadmap. There are three main sections to this document: 1. This Preamble provides some background on Eclipse and the Foundation, and identifies the strategic goals of Eclipse. It also provides a brief overview of the scope of future projects 2. The Themes and Priorities which has been developed by the Eclipse Councils. 3. The Platform Release Plan which has been developed by the Eclipse Planning Council. The Roadmap is intended to be a living document which will see future iterations. This document is the fifth version of the Eclipse Roadmap, and is labeled as version 5.0. In order to preserve this document while the underlying information evolves, the pages have been frozen by copying them from their original project hosted locations. The goal of the Roadmap is to provide the Eclipse ecosystem with guidance and visibility on the future directions of the Eclipse open source community. An important element in this visibility is that the Roadmap help the EMO and the Board of Directors in determining which projects will be accepted by Eclipse during the life of this revision of the Roadmap. In other words, new projects must be consistent with the Roadmap. This does not mean that every new project must be explicitly envisaged by the Roadmap. It does mean that new projects cannot be inconsistent with the stated directions of Eclipse. In particular, Eclipse expects that incubator projects created in the Technology PMC will cover areas not explicitly described in the Roadmap.
    [Show full text]
  • Flexible Graphical Editors for Extensible Modular Meta Models
    X perf =1.00 X loss =0.01 SDSoftware Design and Quality Flexible Graphical Editors for Extensible Modular Meta Models Master’s Thesis of B.Sc. Michael Junker at the Department of Informatics Institute for Program Structures and Data Organization (IPD) Reviewer: Prof. Dr. Ralf Reussner Second reviewer: Jun.-Prof. Dr.-Ing. Anne Koziolek Advisor: Dipl.-Inform. Misha Strittmatter Second advisor: M.Sc. Heiko Klare 12. April 2016 – 11. October 2016 Karlsruher Institut für Technologie Fakultät für Informatik Postfach 6980 76128 Karlsruhe I declare that I have developed and written the enclosed thesis completely by myself, and have not used sources or means without declaration in the text. Karlsruhe, 10.October 2016 .................................... (B.Sc. Michael Junker) Abstract In model-driven software development, graphical editors can be used to create model instances more eciently and intuitively than with pure XML code. These graphical editors rely on models created on the basis of a meta-model. If such a meta-model is extended invasively not only its code has to be re-generated but also the graphical editor needs to be adapted. When developing multiple extensions, the meta-model as well as the corresponding graphical editor tend to get complex and error-prone. One way of coping with this complexity is to use modular meta-models and extending them noninvasively. However, having multiple meta-model fragments providing extended features is only half the job as equivalent graphical editors are needed as well. This master’s thesis therefore analyzes dierent types of extensions for meta-models as well as on graphical editor level.
    [Show full text]
  • Open Source and Third Party Documentation
    Open Source and Third Party Documentation Verint.com Twitter.com/verint Facebook.com/verint Blog.verint.com Content Introduction.....................2 Licenses..........................3 Page 1 Open Source Attribution Certain components of this Software or software contained in this Product (collectively, "Software") may be covered by so-called "free or open source" software licenses ("Open Source Components"), which includes any software licenses approved as open source licenses by the Open Source Initiative or any similar licenses, including without limitation any license that, as a condition of distribution of the Open Source Components licensed, requires that the distributor make the Open Source Components available in source code format. A license in each Open Source Component is provided to you in accordance with the specific license terms specified in their respective license terms. EXCEPT WITH REGARD TO ANY WARRANTIES OR OTHER RIGHTS AND OBLIGATIONS EXPRESSLY PROVIDED DIRECTLY TO YOU FROM VERINT, ALL OPEN SOURCE COMPONENTS ARE PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. Any third party technology that may be appropriate or necessary for use with the Verint Product is licensed to you only for use with the Verint Product under the terms of the third party license agreement specified in the Documentation, the Software or as provided online at http://verint.com/thirdpartylicense. You may not take any action that would separate the third party technology from the Verint Product. Unless otherwise permitted under the terms of the third party license agreement, you agree to only use the third party technology in conjunction with the Verint Product.
    [Show full text]
  • Handcrafting a Triple Graph Transformation System to Realize Round-Trip Engineering Between UML Class Models and Java Source Code
    Handcrafting a Triple Graph Transformation System to Realize Round-trip Engineering Between UML Class Models and Java Source Code Thomas Buchmann and Sandra Greiner Chair of Applied Computer Science I, University of Bayreuth, Universitätsstrasse 30, 95440, Bayreuth, Germany Keywords: Round-trip Engineering, Model-driven Development, Xtend, Triple Graph Transformation Systems. Abstract: Model transformations are a mandatory requirement for model-driven development, a software engineering discipline, which has become more and more popular during the last decade. Over the years, the concept of unidirectional model transformations and corresponding tool support reached maturity since these kind of transformations are widely used in model-driven engineering, mainly for forward engineering and code generation. In incremental and iterative software engineering processes, forward engineering may be too restrictive since it resembles waterfall-like processes. Thus, bidirectional transformations are required, which aim to provide support for (incrementally) transforming one or more source model to one or more target model and vice versa from only one transformation description. However, they seem to be rarely used in model- driven software development as adequate tool support is missing. On the other hand, programming languages nowadays provide support for higher-level features like closures or lambda expressions which allow to describe transformation patterns in a declarative way. In this paper, we present an approach for round-trip engineering between UML class models and Java source code, which is realized with a triple graph transformation system written in the Xtend programming language. 1 INTRODUCTION and accompanying tools have emerged (Czarnecki and Helsen, 2006). We observe tools, which sup- During the last few years, model-driven software en- port unidirectional batch transformations, e.g.
    [Show full text]
  • PRISM Model Checker As an Eclipse-Plugin
    MASARYK UNIVERSITY FACULTY}w¡¢£¤¥¦§¨ OF I !"#$%&'()+,-./012345<yA|NFORMATICS PRISM model checker as an Eclipse-plugin DIPLOMA THESIS Bc. Milan Malota Brno, Autumn 2015 Declaration Hereby I declare, that this paper is my original authorial work, which I have worked out by my own. All sources, references and literature used or excerpted during elaboration of this work are properly cited and listed in complete reference to the due source. In Brno, January 11, 2016 Bc. Milan Malota Advisor: RNDr. Vojtechˇ Rehˇ ak,´ Ph.D. ii Acknowledgement I would like to thank my advisor Vojtechˇ Rehˇ ak´ for valuable advice, com- ments, support and patience during the writing of this thesis. I also want to express my gratitude to my family and my girlfriend for their support during studies. iii Abstract PRISM is a probabilistic model checker and is used in many different ap- plication domains and is well known among scientists dealing with formal modeling and analysis of systems that exhibit random or probabilistic be- havior. PRISM’s GUI was developed in the beginning of the PRISM life cycle and technologies made great progress so it can seem obsolete. That is why the request for a new GUI was pronounced. One of the platforms suitable for integrating an application and preferred by the original development team is the Eclipse platform. In the scope of this thesis we analyze available Eclipse platforms and notable graphical user interface frameworks. On the basis of the analysis new graphical user interface allowing all funcionality of the current PRISM GUI is implemented. iv Keywords PRISM, Eclipse RCP, Eclipse e4, AWT, Swing, SWT, JFace, Albireo v Contents 1 Introduction ...............................3 1.1 Motivation .............................3 2 Preliminaries ..............................5 2.1 PRISM model checker ......................5 2.1.1 The PRISM language .
    [Show full text]
  • Xtend Programming Language Agenda
    Agile Software Development Produced Eamonn de Leastar ([email protected]) by Department of Computing, Maths & Physics Waterford Institute of Technology http://www.wit.ie http://elearning.wit.ie Xtend Programming Language Agenda • Subtitle 3 4 Features (1) • Extension methods - enhance closed types with new functionality • Lambda Expressions - concise syntax for anonymous function literals • ActiveAnnotations - annotation processing on steroids • Operator overloading - make your libraries even more expressive • Powerful switch expressions - type based switching with implicit casts • Multiple dispatch - a.k.a. polymorphic method invocation 5 Features (2) • Template expressions - with intelligent white space handling • No statements - everything is an expression • Properties - shorthands for accessing and defining getters and setter • Type inference - you rarely need to write down type signatures anymore • Full support for Java generics - including all conformance and conversion rules • Translates to Java not bytecode - understand what is going on and use your code for platforms such as Android or GWT 6 Hello World xtend java class HelloWorld public class HelloWorld { { def static void main(String[] args) public static void main(String[] args) { { println("Hello World") System.out.println("Hello World"); } } } } 7 Selected Key Features • Java Interoperability • Expressions • Annotations • Type Inference • Literals • @Data • Conversion Rules • Casts • Classes • Field access & method invocation • Constructors • Constructor call • Fields • Lambda Expressions • Methods • If expression • Override • switch Expression • Inferred return types • return expression 8 Java Interoperability 9 Type inference • Xtend, like Java, is a statically typed language. • It completely supports Java's type system, including the primitive types like int or boolean, arrays and all the Java classes, interfaces, enums and annotations that reside on the class path.
    [Show full text]
  • Code Smell Prediction Employing Machine Learning Meets Emerging Java Language Constructs"
    Appendix to the paper "Code smell prediction employing machine learning meets emerging Java language constructs" Hanna Grodzicka, Michał Kawa, Zofia Łakomiak, Arkadiusz Ziobrowski, Lech Madeyski (B) The Appendix includes two tables containing the dataset used in the paper "Code smell prediction employing machine learning meets emerging Java lan- guage constructs". The first table contains information about 792 projects selected for R package reproducer [Madeyski and Kitchenham(2019)]. Projects were the base dataset for cre- ating the dataset used in the study (Table I). The second table contains information about 281 projects filtered by Java version from build tool Maven (Table II) which were directly used in the paper. TABLE I: Base projects used to create the new dataset # Orgasation Project name GitHub link Commit hash Build tool Java version 1 adobe aem-core-wcm- www.github.com/adobe/ 1d1f1d70844c9e07cd694f028e87f85d926aba94 other or lack of unknown components aem-core-wcm-components 2 adobe S3Mock www.github.com/adobe/ 5aa299c2b6d0f0fd00f8d03fda560502270afb82 MAVEN 8 S3Mock 3 alexa alexa-skills- www.github.com/alexa/ bf1e9ccc50d1f3f8408f887f70197ee288fd4bd9 MAVEN 8 kit-sdk-for- alexa-skills-kit-sdk- java for-java 4 alibaba ARouter www.github.com/alibaba/ 93b328569bbdbf75e4aa87f0ecf48c69600591b2 GRADLE unknown ARouter 5 alibaba atlas www.github.com/alibaba/ e8c7b3f1ff14b2a1df64321c6992b796cae7d732 GRADLE unknown atlas 6 alibaba canal www.github.com/alibaba/ 08167c95c767fd3c9879584c0230820a8476a7a7 MAVEN 7 canal 7 alibaba cobar www.github.com/alibaba/
    [Show full text]