DSL Forge is a framework for the development of domain-specific language (DSL) editors for web applications and cloud IDEs. The framework makes it possible to create and edit models, launch automated tool chains on the server, including model-to-model transformations, code generation, live validation, and execution of the generated artefacts.
The framework is composed of two features:
- Tooling for language development, and
- Runtime, or Target Components.
The Tooling allows generating editors which are executed on top of the Runtime.
Basically, two paths are illustrated each of which covers a specific use case:
How It Works
The core of the generator is a model to text transformation between Xtext and ANTLR. Indeed, compared to the ANTLR specification language, the Xtext language uses extra sugar (e.g. EMF typed references, Xbase, etc.).
Both scenarios are covered by the tool, as this first open-source version comes with two generators, each of which fulfills one of the above scenarios.
The Runtime target components are required if you develop against the Eclipse Remote Application Platform (RAP). It is a set of plugins providing services such as typed content assist, workspace management, persistency, etc. The plugins are built on top of the Basic Equinox RAP Target you can already download from the Eclipse RAP update sites.
DSL Forge’s editors can be customized according to the use case. It’s up to the developer to decide what should be done on the client, versus what should be done on the server. The following table illustrates the possible options in typical client/server architectures.
Depending on the use case, you may want customize some features from the server, such as parsing (syntax validation), scoping, or semantic validation. You may decide to proceed upon user request (e.g. on button click, on save, etc.) or systematically at each user interaction with the UI (e.g. on text modify). If you are using a Java backend, you probably want a centralized location where you manage the resource sets, persist the files, store workspace metadata, etc.
In other scenarios, features like syntax highlighting, text hovering, or content assist, are required on the client side, so that the amount of HTTP calls between the client and the server is minimized; large scale applications fall in this scenario.
Default syntax highlighting displays text in different colors and fonts according to the category of terms, e.g. keyword, strings, line comments, and block comments. Together with syntax highlighting, brace matching makes it simple to see if a brace has been left out, or to locate the match of the brace the cursor is on, by highlighting the pair in a different color.
Syntax validation is roughly equivalent to checking whether text input is grammatically correct (without worrying about the meaning, as opposed to semantic validation). The purpose of syntax validation is to check that the user is entering a valid sequence of tokens. The language parser takes the tokens produced during the lexical analysis stage, and attempts to build an abstract syntax tree (AST) structure to represent that input. The editor reacts to invalid sequences of tokens by displaying annotations and messages: errors, warning, and information.
Content Assist, also called autocomplete or auto completion, helps the user predict the rest of a word a user is typing. Press “CRTL+SPACE” to show the content assist popup, and select a suggestion from the popup by double-clicking on the proposal or hitting “ENTER”. Content Assist proposes keywords, local references, global references (i.e. references located in other resources), as well as templates, also known as code snippets.
The content assist popup also proposes templates, or snippets, to help speed up coding. Template proposals are special entries which let the user generate in one click the skeleton of a class, an entity, or whatever the language abstraction is. The templates are located in a separate file and are loaded by ACE the classic way. The user can then navigate through the place holders using the “TAB” key and fill in the values of the template.
If your application has a Java back-end, server-side validation can be used to validate additional constraints on the language instances. In this case, it is possible to integrate model validators that can be triggered in live mode, or on user request. EMF-based validators, including the Xtext validation framework, work out-of-the box as the validators are bound in the runtime plugin, which is packaged as-is in the web application.
Hovering is typically used to display documentation, for example hovering over a reference displays the documentation attached to its declaring type. In the example below, hovering over an entity displays its name, type, and a link to package documentation.
Folding allows selectively hiding and displaying sections of the model being edited. This allows the user to manage a large amount of code, while viewing only those subsections which are specifically relevant at a given time. Identification of folds is automatic for curly brackets, and can be adapted based on the syntax of the language.
Keyboard shortcuts are used to expedite common operations by reducing input sequences to a few keystrokes. The generated editors provide the most commonly used key bindings, here is the default key bindings:
- CRTL+SPACE: Content assist,
- CRTL+S: Save,
- CRTL+C: Copy,
- CRTL+V: Paste,
- CRTL+Z: Undo,
- CRTL+Y: Redo,
- CRTL+F: Find text.
Supported Web Development Platforms
Two web development platforms are now supported:
- Eclipse Remote Application Platform (RAP)
- Eclipse Web Tools Platform (WTP)
Remote Application Platform
The Remote Application Platform (RAP) is a framework for modular business applications that can be accessed from different types of clients including web browsers, rich clients, and mobile devices. It provides a powerful, multi-platform widget toolkit with SWT API that enables developers to write applications entirely in Java and re-use the same code on different platforms. More information about Eclipse RAP can be found at https://www.eclipse.org/rap/
Web Tools Platform
The Web Tools Project (WTP) aims to provide common infrastructure available to any Eclipse-based development environment targeting web applications. WTP provides tools to develop web applications following the Sun Microsystems Java™ Servlet 2.3 Specification and the Sun Microsystems JSP 1.2 Specification. Web applications can be simple (consisting of static web pages) or they can be more advanced and include Java Server Pages (JSP) files and Java servlets. More info about WTP can be found on https://www.eclipse.org/webtools/
Dependencies with other tools
DSL Forge is open source and uses components from other open source projects under EPL and BSD liscences. Below a brief description of the involved technologies:
ANTLR (ANother Tool for Language Recognition) is a powerful parser generator for reading, processing, executing, or translating structured text or binary files. It’s widely used to build languages, tools, and frameworks. From a grammar, ANTLR generates a parser that can build abstract syntax trees. More info about ANTLR at https://www.antlr.org/
Xtext is an open-source framework for developing programming languages and domain-specific languages (DSLs) based on ANTLR grammars. It uses a subset of ANTLR and is specifically tailored to EMF-based models. It also provides customizable advanced features well-integrated with Eclipse IDEs. More info about Xtext at https://eclipse.org/Xtext/
DSL Forge program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which is available at https://www.eclipse.org/legal/epl-v10.html