Rebuild Project Programmatically

Hi,
I have added Model Listener to track the changes in my model. I want to rebuild the project whenever a new node is added to my model. I have SModel which is from open api. Is there any way to call Rebuild Project from the code.

Thanks
Kunal
5 comments
You can do it the same way it's done in MakeSelectedModels or RebuildProject actions.
The only problem that can appear here is that you can't know project from a model. You should somehow remember it in the listener.
Screen Shot 2015-04-14 at 20.49.12.png

Screen Shot 2015-04-14 at 20.49.17.png
0

 Hi,

I want to rebuild my project within a plugin and to do that I need to pass project as a parameter to "MakeActionParameters()" in following:

new MakeActionImpl(new MakeActionParameters(project).modules(project.getProjectModules())).executeAction();


but I couldn't access my project within my plugin. I couldn't find project in "action context parameters" of my plugin. All I can get is my model.

0

The declaration of the "project" parameter is in the jetbrains.mps.ide.actions@java_stub model, so you should import it and you'll see project among action parameters. That's quite undiscoverable, we plan to change this soon.

0

Yep that worked. Thanks!

I have one more problem. In my plugin, I want to use rebuild command in a loop. Every time I make few changes in the model and then I rebuild the model again. When I use my plugin, it rebuilds but the result is not as intended. It looks like it is rebuilding just one time. And updating the same result every time.


0

Can't help you without looking into the code or a small project demonstrating the problem. If the code is correct, I suppose such a scenario should work fine.

0

Please sign in to leave a comment.