MPS Plugins and introspection
Hi, I am considering to write a plugin for MPS to perform some manipulation on the models present in a project. Is some documentation available? Do you have any suggestion?
Thank you,
Federico
Thank you,
Federico
Please sign in to leave a comment.
Some documentation on MPS is available here
http://confluence.jetbrains.net/display/MPSD2/MPS+User%27s+Guide
If you have questions not mentioned there, please feel free to ask - we can write documentation for the most interesting parts in MPS core.
Regards,
Mihail
thank you but it seems to me the documentation for users. There is any documentation about the internals and about writing plugins for MPS?
For example a plugin to look for nodes of a given type and with certain characteristics in the whole workspace?
Federico
http://confluence.jetbrains.net/display/MPSD2/Plugin#Plugin-Actionsandactiongroups
So, you add an action and place it into some menu. Then you need to get all the modules of the current project from the action. Just add a context parameter to an action - and here's current MPSProject.
The next part is not described in the documentation, but it's quite simple - the project has its modules, and each module has its "own" models (project.getModules(), IModule.getOwnModelDescriptors(), SModelDescriptor.getSModel()). So, you get all the models in your project. Then you cast the SModel instances you got to MPS type "model" and you can further start using the smodel language.
The next part is working on the "below-model" level (smodel language), and it's partially described here
http://confluence.jetbrains.net/display/MPSD2/SModel+language
but IMO it's quite intuitive if you read the first chapter of the documentation
http://confluence.jetbrains.net/display/MPSD2/Basic+notions
http://confluence.jetbrains.net/display/MPSD2/MPS+project+structure
so you can continue looking at it just by using completion menu.
If you ave further questions, need an example etc., feel free to ask.
Regards,
Mihail
1) now we don't have a public API on this level as we change it very often
2) we plan to reorganize the inner part of how MPS stores models, so the API will be changed, and I suppose that's the point where we could stabilize it.
3) the language authors don't typically need to go above the model level
thank you very much.
I am at the very beginning:
I select from the Menu Go To -> Go to Model, and I search for “jetbrains.mps.ide.actions”.
Then I select inside actions the folder Menu, ProjectPane, Model, Action and I create a new jetbrains.mps.lang.plugin.Action.
When I open the new created Action I have this message:
“Warning: the node is in a packaged model. Your changes won’t be saved”
The new created Action is not editable (I am not able to set a name).
How can I create an Action and save it?
(As soon as I understand what are the steps I am trying to read a "for-very-dummies" tutorial)
Regards,
Federico
Error during dispatching of java.awt.event.MouseEvent[MOUSE_RELEASED,(988,621),absolute(980,613),button=1,modifiers=Button1,clickCount=1] on frame0: You can read model only inside read actions
How can I create a read action? Should I start another thread?
To create a read action, just type "read action". Read action is a statement. To change models, use "write action". It can be started from any thread, too.
I plan to write a second part implementing the export functionality in the action code to produce some XML form of the models.
Added a link to plugin documentation page, here:
http://confluence.jetbrains.net/display/MPSD2/Plugin
If you don't mind.
If you write some other posts and howtos on mps, I'll be glad to reference them from our pages where appropriate.
Regards,
Mihail
Federico
EDIT: they are just moved in a sub-menu. By the way when I create a tool it does not automatically appear in the list of tools... I don't know how to start it.
http://confluence.jetbrains.com/display/MPS/Migration+to+MPS+2.5, "Use separate Plugin Solutions to hold all platform-specific.." part
In general. you should create separate solution holding all platform-specific aspects like Actions/Tools/..