Skip navigation.
Home

Spoofax 0.3.0 Eclipse Plug-in released

I decided to forgo my friday night clubbing and rather spend the time at the office in solitude with a bottle of water, some microwave food and Eclipse windows floating feverishly about on my dualhead setup (I don't have an extra monitor at home).

The end result was another release of the Spoofax editor, codenamed Obelix. The name is apt; Obelix is 322% larger than Asterix (0.2.0) and weighs in at around 87KB. In addition to more crud, more features were also added:

  • An outline view for Stratego files

    At the present time, the outliner will only update itself whenever you save. I have not added an autotimeout for reparsing, but this shouldn't be all that difficult.

    By clicking on the items in the outline view, the focus of the connected editor will be changed automatically, and the area in the source file associated with the declaration will be marked in the left hand side margin of the editor. Unfortunately, due to parsing inaccuracies, only the area corresponding to the declaration of the identifier will be marked, not all of its body too. I hope we can fix this soon.

    The information from provided by the outline is kept in the StrategoModel class, which I hope will evolve into a proper AST as time goes by and we improve our parser.

  • Content assistance for strategies, rules and constructors

    Whenever you press Ctrl-Space, the content assistant will be run. It will consider the location you are in the document, parse leftwards and see if it can find something resembling strategy, rule or constructor identifier.

    When the scanner finds an identifier, it will assume it's a rule or strategy, and will show you all potential expansions for the prefix it found. By selecting one, it will insert the selection and move the cursor to after the completion. If you complete a higher-order strategy or rule, it will add a set of parentheses and place the cursor inside these.

    If, while scanning leftwards, it finds a !, it will assume you want a list of constructors.

    By typing ! or <, then waiting 500msec, the editor will automatically pop up a list of constructors or rule/strategy-definitions, respectively, all by itself.

  • Preference pages for syntax highlighting

    Now the editor does not have to be restarted after changing the settings anymore. They are applied instantly.

  • A nifty realtime parenthesis matcher
  • The parenthesis matcher keeps track of the kinds of parenthesis used, and if they don't match, it will signal a mismatch by a red (customizable) match cursor.

The interesting part of this -- content assist and outliner -- was made possible thanks to the new "outline" parser which is somewhat context sensitive. It skimps along the document trying to pick out anything it can reasonably detect, and places it into the StrategoModel. There's a long way left before we have 100% correct parsing. In particular, the unrestricted syntax embedding allowed in Stratego source code is of course not generally solvable. But as we approach there, we will have increasingly better completion and navigation.

A few words of acknowledgement are definitely in order. Inspiration by Martin helped a lot. On the technical side, looking at the SchemeWay project by Dominique Boucher was extremely helpful. My parenthesis matcher is heavily inspired by his. Also, I can heartily recommend the JavaEditor example in the Examples SDK to nail the basics of Eclipse editor development.