Skip to content
moosetechnologyPublic

About

This is the repository of the new Model Transformation library. It includes the Matching part, and in the future it will cover the Transformation part also.

Resources

Stars

4 stars

Watchers

1 watching

Forks

Latest commit

 

History

269 Commits

Folders and files

Repository files navigation

Latest Moose

Description

MoTion is a new object pattern matcher in Pharo. A pattern matcher works on a finite set of objects that we will call a model. Examples of models are: the Pharo AST of a method, the DOM of an XML document, the objects loaded from a JSON file, ... MoTion can deal with Pharo objects independently of the model containing the data. MoTion combines both features for graph pattern matching and object matching, and by that it enables expressing patterns declaratively and applying matches over complex object structures. With its refactoring rules, MoTion can also transform the code it matches.

Update on October 2026

MoTion is now capable of applying some refactorings based on bindings. This represents the outcome of several months of work by the trainee and will be discussed in a subsequent section. Please note that these refactorings can only be applied over FAST metamodels and we are still at the beginning, yet cool stuff can be done with the existing.

Installation

To install MoTion, go to the Playground (Ctrl+OW) in your Pharo image and execute the following Metacello script (select it and press Do-it button or Ctrl+D):

Metacello new
    baseline: 'MoTion';
    repository: 'github://moosetechnology/MoTion:main/src';
    load.

To also load the refactorings on FAST models, use load: 'MoTionFAST' instead of load (see Refactorings with MoTion).

A first look

pattern := FamixJavaModel % {
    #'allTypes>entities' <=> FamixJavaInterface % {
        #'superInheritances>superclass>name' <=> 'Remote'.
        #'isStub' <~=> true.
    } as: 'foundInterface'.
}.

pattern match: aFamixJavaModel.

This pattern finds, in a Java model, the interfaces that inherit from Remote and are not stubs, and binds each one to foundInterface.

Documentation

Want to use MoTion? Here's are the references that you need to help you using it properly. Enjoy :)

Page What you'll find
Syntax All the operators: object patterns % {} / %% {}, <=>, negation <~=>, @x variables, wildcards, paths >, recursion *, lists, sets, orMatches:, number comparisons
How to use the matcher asMatcher, match:, results, bindings with as: and collectBindings:for:
Some cool examples Patterns on Famix Java, FAST Java, Pharo packages and XML
Refactorings with MoTion Renaming, replacing and removing code with MoTionRule
Inspect MoTion Patterns Inspect suspicious MoTion patterns using MatcherInspector

Finally

Don't hesitate to ask. More examples can be found in the tests packages.

Also, if you are not familiar with MoTion or are using it for the first time, no worries: you can find skills for MoTion that you can use with any AI agent here: https://github.com/alesshosry/MoTionSkills.

Pssst: don't hesitate to have a look at Iguala, which is the same matcher implemented in Python: https://github.com/aranega/iguala

Finally, well, just enjoy it ;)

About

This is the repository of the new Model Transformation library. It includes the Matching part, and in the future it will cover the Transformation part also.

Resources

Stars

4 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages