Acceleo/Interpreter

From Eclipsepedia

Jump to: navigation, search

Since 3.2, Acceleo offers a full-featured live request interpreter. Since 3.5, It offers the same full-featured live request interpreter for the ocl language. We just need to select the used language (Acceleo, OCL) then type the expression to evaluate and select its context. In addition, Acceleo offers now an evaluation of a complete OCL resource. In this case, we just need to type or import an existing ocl file to the view then select a context to evaluate. We will focus here on detailing all of this view's possibilities.

Contents

Breakdown

First things first, what are all of these menus and fields for?

Acceleo Interpreter Breakdown.png
  1. Language selection
  2. Expression
  3. Evaluation Result
  4. Sub-Expressions
  5. Variables
  6. Actions
  7. Feedback

Language selection

The title of the interpreter features a drop-down menu that allows the user to select the language of his expressions. By default, Acceleo provides the interpreter for itself 'Acceleo'. In Addition, it proposes the pure 'OCL' language as an alternative language and allows to evaluate a complete ocl resource by selecting the 'Complete OCL' option, but any third-party plugin can come and add its own language to the list. More on the extension in the Extensibility section.

Expression

The expression section allows users to enter and edit expressions for the selected language. Note that for the OCL Language users can evaluate single constraints and complete OCL Resources. The expression can be fully customized by language providers and can thus become as powerful as a full-fledged editor for that language. Completion proposals and syntax highlighting are available by default for the selected language in the interpreter.

The expression will be interpreted on the fly as it is typed if the Acceleo Interpreter Realtime action.gif Real-time toggle is activated (located at the upper-right of the view, 6 in the above breakdown). Otherwise, users can call for the evaluation at any given time through either :

  • Right-click in the expression view, then hit Acceleo Interpreter Evaluate action.gif evaluate
  • Hit the Acceleo Interpreter Evaluate action.gif Evaluate icon of the expression section
  • Use the CTRL + SHIFT + D keyboard shortcut

Evaluation Result

This section displays the result of evaluations in the form of a tree. There are multiple possibilities as to the result look-and-feel :

  • Collection result : each of the collection's values will be displayed as one row of the result tree.
Acceleo Interpreter Multiple result.png
  • Single object : if the result consists of a single, plain object, it will be displayed as the only row of the tree.
Acceleo Interpreter Single result.png


Each row of the tree can be displayed in a number of ways, depending on the object's type. The objects are usually displayed as they would in their own editors, but two types of generated objects are displayed in a special manner :

String

If the result is a string, its very first line will be displayed as the Tree's row.

Acceleo Interpreter Long result.png


If the string is longer than a single line, its full length can be seen in two ways :

  • Hover : Hovering the mouse over the row
Acceleo Interpreter Long result hover.png
  • Popup : Double-clicking the row
Acceleo Interpreter Long result popup.png

File

The interpreter allows you to generate "files". No file will actually be generated on disk; instead the interpreter will display them in their own special way, with the icon corresponding to their type (as known to Eclipse) and their content as a child row :

Acceleo Interpreter File result.png

A double-click on the "file" row will open a read-only editor for the file, along with all of the syntax highlighting this editor may have. (partial exemple of a "java" file opened through this action below)

Acceleo Interpreter File result readonly editor.png

Sub-Expressions

This section is OCL specific and will be empty for other languages. It displays the ocl sub-expressions of the entered user expression in the form of tree.

Acceleo Interpreter sub expression tree.png

Each sub expression can be evaluated by clicking on the corresponding tree row in the "Sub-Expressions" section. The result is displayed in the form of tree for each sub-expression.

  • Collections
Acceleo Interpreter sub expression collection.png
  • Single
Acceleo Interpreter sub expression size.png

Variables

The variable section of the interpreter view is hidden by default, and can be shown or hidden at will through the Acceleo Interpreter Variable action.gif Show variables icon of the view.

The variables will be displayed as a Tree, with variable names as the root, and their value(s) as children. They can be used in any expression with only their name :

Acceleo Interpreter Variable Sample.png

Existing variables can be renamed or deleted through the right-click menu, or through the F2 (rename) and del (delete) keyboard shortcuts.

There are two possibilities to create new variables. Either drag and drop Objects in the viewer, or use the new variable wizard.

New variable wizard

A wizard to create new primitive variables can be initiated through a right-click in the Variables view and selecting the New Variable action.

Acceleo Interpreter New Variable Start.png

The wizard itself consists of a single page that allows users to select a name for the new variable, and a primitive value (String, Boolean, Integer or Float).

Acceleo Interpreter New Variable Wizard.png

If the selected name matches that of an existing variable, the new value will be added to that existing variable's list of values.

Drag and Drop

The variable view supports drag and drop from almost any other view, or editor. As long as the "other view" enables dragging, the variable viewer will accept the "drop" and create a new variable with the dropped element as its value. Dropped elements can be either primitives (String, integer, float...), EObjects (elements dropped from an EMF model) or plain Java Objects.

What you can do with the values of these variables, however, depends on the current interpreted language.

Feedback

The interpreter view will use this field in order to display the various issues and information the user might need. Namely, the compilation warnings and errors if any are sprung by the current expression, evaluation warnings and errors if the compilation went fine, but the evaluation did not... and if all went well, the evaluation result's type and length.

Some examples of this include :

Compilation errors

Acceleo Interpreter Compilation Error.png

Evaluation Warning

Acceleo Interpreter Evaluation Warning.png

Result

Acceleo Interpreter Result.png

Actions

The toolbar of this view features a number of actions, the first part being provided by the view itself while the second half is contributed by extending language interpreters. Following is the rundown of the actions that are available by default, when a specific language is selected in the interpreter.

Generic actions

  • Acceleo Interpreter stepbystep action.gif Show Step-by-Step

This toggle allows users to hide or display the "Sub-Expressions" section of the interpreter.

  • Acceleo Interpreter Variable action.gif Show variables

This toggle allows ursers to hide or display the "Variables" section of the interpreter.

  • Acceleo Interpreter Realtime action.gif Real-time

This toggle activates or disables the real-time compilation of expressions, letting the user decide when to launch evaluations or doing it on-the-fly while he types.

  • Acceleo Interpreter Link action.gif Link with editor context

This action is provided by the interpreter view itself, yet it is up to the selected language to accept the link or not. In the case of Acceleo, this action is honored if the current editor is an Acceleo editor opened on an Acceleo module.

Hitting this action when an Acceleo editor is opened links the interpreter with the opened module, enabling the user to use the queries and templates defined, imported or inherited by that module.

Acceleo actions

  • Acceleo Interpreter Save expression.gif Save as

This action is Acceleo specific and will not be displayed for other languages. It will allow the user to save the current expression as a new template or a new query in a module of his choice.

Additional interpreters

Acceleo offers additional interpreters:

  • OCL
  • Complete OCL

Please refer to the Acceleo update site to download the additional Interpreters (OCL and Complete OCL).

OCL interpreter

This interpreter offers the same full-featured live request as the Acceleo interpreter but this time using the OCL language. Users can type their ocl expression in the 'Expression' view and select the context in the model editor to evaluate. Sub-expressions will be shown in the "Sub-Expressions" view. For more information about the "Sub-Expressions" view refer to Sub-Expressions section.

Complete OCL interpreter

This offers the same full-featured live request as the Acceleo and the OCL interpreters for complete OCL resource. It allows user to type a complete OCL resource including its corresponding imports. The completion proposals and syntax highlighting are also available by default for this interpreter. The contextual menu proposes facilities to import an existing complete OCL Resource and to export its evaluation results. The evaluation can be executed for the whole target model as context and for specific context selection.

Import Complete OCL Resource

This action is available in the contextual menu of the "Expression" view if the "Complete OCL" Interpreter is actif.

It allows user to import an already exiting complete OCL Resource Browsing Workspace or File System. The Entire content of the imported file will be copied to the "Expression" view. Only the "*.ocl" files are allowed to be imported to this view.

Export Evaluation Result

This action is available in the contextual menu of the "Expression" view if the "Complete OCL" Interpreter is actif.

It allows user to export the evaluation result of the current "Expression" content evaluated on the whole model of the actif editor. The Entire constraints (OCL invariants) and operations (definitions without parameters) of the "Expression" view content will be evaluated and exported.

Two export options are available by default:

  • The HTML Export: This will execute the default HTML Exporter.
  • The Model Export: This option will save the evaluation result as a model resource.

By activating one of this options, users are invited to select the target file path before executing the selected export mechanism.

Changing the interpreter context

Linking with an editor

[PENDING]

Working with the debugging context

[PENDING]

Extensibility

[PENDING]


Acceleo Portal
Project Project · Installation · New & noteworthy · Release review · API policy · Retention policy · Next · Checklist
Features Acceleo Features · Runtime · Acceleo editor · Views & Perspective · Debugger · Profiler · Traceability · Wishlist · Interpreter · Maven
User documentation Getting Started · Acceleo operations reference · OCL operations reference · Text Production Rules · Migration From Acceleo 2.x · Best Practices · Videos · FAQ
Developer documentation Source code · How to contribute · Compatibility · MOFM2T specification · OCL specification
Community Conferences · Twitter & Blogs · Professional Support · Report a bug