How to Create a basic Plugin in MPS and run it on MPS
Hi All,
I am a newbie in MPS and playing with it to create a DSL on my existing Java API. I want to create a basic plugin to handle my DSL which can run inside MPS. Is there any tutorial or wiki to see how to create a plugin and run inside MPS.
Cheers
Kunal
I am a newbie in MPS and playing with it to create a DSL on my existing Java API. I want to create a basic plugin to handle my DSL which can run inside MPS. Is there any tutorial or wiki to see how to create a plugin and run inside MPS.
Cheers
Kunal
Please sign in to leave a comment.
http://confluence.jetbrains.com/display/MPSD31/Building+MPS+language+plugins should be what you're looking for.
You may also need to check out the build language doc at http://confluence.jetbrains.com/display/MPSD31/Build+Language
Vaclav
Thanks for the quick reply.
The link you gave shows more of building a Plugin Solution but
I am looking for sample examples/code to hook a plugin/bind a plugin on some key events such as Ctr+S . To be more clear how to write a hello plugin on which if a user presses Ctr+s, hello should be displayed on console.
Cheers
Kunal
then I believe http://confluence.jetbrains.com/display/MPSD32/Plugin is closer to what you need.
Vaclav
Thanks for the URL, I went through it and managed to add few actions. Out of that I am facing some difficulty in writing some code inside execute(event) block of Actions section.
I am trying to Sysout some string inside execute(event) block but I cannot see any message , Can you help me as if I am missing something
action TestAction {
mnemonic: <no mnemonic>
execute outside command: false
also available in: << ... >>
caption: Save Model
description: <no description>
icon: <no icon>
construction parameters
<< ... >>
action context parameters ( always visible = false )
<< ... >>
<update block>
execute(event)->void {
System.out.println("Action Invoked");
}
additional methods
<< ... >>
}
Cheers
Use the logging statements from the jetbrains.mps.baselanguage.logging language, instead, such as info "" or warn "".
Vaclav
Cheers
I am adding log and info to print the logs but I cannot see them either in MPS Messages View or mps.log file. Do I need to some additional steps to view the logs ?FYI I already added
BasicConfigurator.configure(); in the code.
Please suggest.
Thanks
Thanks for the quick reply. I did Reload Classes from Toolsmenu after I have added the log statement or Restarted MPS and what find only 1 log to be displayed for the below code Snippet that I added in Action of My Plugin. The Line that gets displayed is INFO-editableSModel and after there is no log even when I add new Node or Remove Node or press Ctrl+S to save Model. Do I need to do anything else?
Below is Code Snippet:
execute(event)->void { BasicConfigurator.configure(); SModel model = this.context.getModel(); if (model instanceof EditableSModel) { info "editable SModel"; EditableSModel model1 = (EditableSModel) model; model1.addChangeListener(new SModelChangeListener() { public void nodeAdded(SModel p0, SNode p1, String p2, SNode p3) { info "Node is Added"; } public void nodeRemoved(SModel p0, SNode p1, String p2, SNode p3) { info "Node" + p1.getName() + "is Removed"; } public void propertyChanged(SNode p0, String p1, String p2, String p3) { <no statements> } public void referenceChanged(SNode p0, String p1, SReference p2, SReference p3) { <no statements> } }); }Thanks
Kunal
I am adding Node to Constant Sandbox,Btwn this should work on all Models as the Context is Editor and what ever Model is represented on Editor, it should trigger the Underlying Actions of Plugin, Right?