# Usability features of the editor

## Architecture

The main motivation behind the GUI improvements was adding support for EMF Generics to the Feb 2005 release of Emfatic (authored by Christopher J Daly).
The conversion between `.ecore` and `.emf` now understands them, as a consequence Emfatic now requires EMF 2.3 or higher. Examples of new productions in the grammar appear at the end of this document, the new grammar is backwards compatible.

After each keystroke the document is parsed, a CST is built and (if possible) an AST too. A bidirectional multimap keeps the correspondence between textual representation (CST nodes) and AST node. The performance impact is acceptable. Functionality such as "Mark Occurrences" do not resort to exploring the textual document. Instead, the (offset, length) pair is used to get a CST node, from which an AST node can be found, making for robust navigation.

The availability of CST, AST and their bridging will likely simplify the introduction of new functionality.

## New GUI features

| The Outline view now displays the same elements as the Sample Ecore Editor, toolbar actions are available for hiding/showing annotations, attributes, references, operations.
| Mark occurrences highlights usages of the same EClassifier, range indication on the vertical bar spans the EClassifier declaration.
| Folding is supported, with an annotation hover for collapsed regions.
Problem and warning markers (with squigglies) are updated after each keystroke.
Attempting to generate an .emf for an .ecore triggers an EcoreValidation. Errors and warnings are shown in the Problems view, generation is still allowed if there are only warnings.
| The selected outline node follows the cursor position in the text

Navigable hyperlinks (from usages of classifiers and type variables to their declarations)

Hyperlinks are very handy for example to follow an eOpposite to its declaration (alternatively, letting the mouse cursor rest over an eOpposite displays its definition in a text hover, see below)

Open declaration is also supported, i.e. pressing F3 (or whatever key binding is in effect for it) moves the cursor to the declaration.

A File > New > Other … wizard is available, which initializes the just created .emf file to a syntactically correct state: @namespace( uri= "http://a.b.c/x/y/Z" , prefix="p") package top;
Hovers for usages of classifiers, type parameter variables, and eOpposite references: the definition is shown.

| AutoEdits SmartBrace: typing an opening brace automatically adds its closing brace and leaves the cursor indented on its own line (end result shown left) Besides that strategy the usual ones: - DefaultIndentLine - Closing quote for opening quote
Preference pages, to control AutoEdits and templates (see example below)
A template for each kind of annotation saves typing. In the example, the template definition for adding OCL invariants is shown (the error marker is transient, once the template is inserted it disappears) after choosing the template above

## Show in EMF Type Hierarchy

“Show in EMF Type Hierarchy” can be activated from the editor and from the outline view

The supertype and subtype relationships can be followed, with a list of (inherited) class members displayed on the lower pane. Double-clicking on any of these elements navigates in the editor to its declaration.