« New MPS build | Main | The first real life LOP application! »

November 03, 2007

Keeping models in-sync

Language-oriented enthusiasts who tried to design DSLs with previous version of MPS may have found that some of their languages don’t work well with MPS build 470 because models of those languages use concepts or features which became deprecated.

To be more specific, there are significant changes in actions language and constraints language.

Frustrating, of course, but this problem is unavoidable. Over a language evolution, models written in this language become outdated.
Actually, this happens constantly in our every day development. Our team develops various DSLs and solutions concurrently and it is just not possible to have all models updated after changes in their languages.

Fortunately, MPS supports scripts which can automate migration of models to new version of language.
Language migration scripts are part of language definition and they are available in any context where the language has been used.

A couple of such scripts can be found in build 470.

To begin with, let’s open BaseConcept in jetbarins.mps.core language (open any project in MPS, press Ctrl-N and type ‘BasC’).

BaseConcept.PNG

There is a set of concept properties with name starting with “deprecated”. To find what was deprecated in build 470, select ‘deprecated_next_after_415’ property and press Alt-F7 (search usages).

deprecated_usages.PNG

Double-click on selected node to open it in the editor.

ConceptRightTransformMenuPart_decl.PNG

Obviously, all usages of the deprecated ConceptRightTransformMenuPart concept should be rewritten using new ConceptRightTransformPart concept.

To find usages, first press Ctrl-W twice to make proper selection and then press Alt-F7.
In my example project 'find usages' found one instance and few other usages.

deprecated_usages_2.PNG

First let’s open ‘instance’ in editor view:

ConceptRightTransformMenuPart_before.PNG

When a concept is changed or replaced, we remove corresponding support in generator, typesystem etc. but keep its structure and editor to let old models to be opened without crashing. Editor is usually modified to warn of the obsolete feature usage.

One of the other usages is in script named ‘MigrateFrom415’. Let’s open it too.

script_edtor.PNG

The model transformation is done in ‘do’ block. It is written in BaseLanguage (Java-like language) but Java here is almost not recognizable because of heavy usage of smodel language.
The smodel language is BaseLanguage’s extension for manipulation with MPS models.

Now let’s run this script. This can be done from main menu or from model’s popup menu. Actually, I could do it just after MPS is started. All steps above are not necessary.

script_menu.PNG

Script will perform search usages and open refactoring view:

refactoring_view.PNG

That gives us last opportunity to take a look at the models before they are transformed:

ConceptRightTransformMenuPart_before.PNG

‘Do Refactor’ will update the model:

ConceptRightTransformMenuPart_after.PNG

Posted by Igor Alshannikov at November 3, 2007 04:44 AM

Comments

Post a comment




Remember Me?