Help with a project's plugin


I'm working on my IDEA IntelliJ Plugin with gradle and I am trying to create a button that adds a function to the current class, or a given class. I saw an example in Eclipse but couldn't find the equivalent libraries.

I've tried to seek for an equivalent library to ICompilationUnit in Eclipse but couldn't find anything

ICompilationUnit unit = compilationUnit(activeEditor());

final String messageName = inputBox("Create New Message",
"Message Name");

if (messageName == null)
return null;
String camel = camelCase(messageName);
final String methodName = "handle" + camel;

IType type = null;
try {
unit.createImport(, null, null);
type = unit.getType(drop(unit.getElementName(), 4));

if (!type.getSuperclassName().equals("SimpleAgent")) {
msgbox("cannot create message - unrecognized agent type");
return null;

IMethod mtd = method(type, methodName);

if (mtd == null) {
mtd = type
+ messageName
+ "\")\npublic void "
+ methodName
+ "(){\n\t//TODO: Add Message Handling Code Here.\n\t"
+ "//you can add any parameters to the method in order to receive them within the message.\n}\n",
null, false, null);

CompilationUnitEditor editor = activeCompilationUnitEditor();
My main goal is to add a button that once it's clicked it opens a text box, than it adds a function with the given text to the current class. Error if nothing has been typed.

Thank you very much in advanced.

Comment actions Permalink

There is zero overlap between Eclipse and IntelliJ Platform API. Please follow "Getting started" trail in SDK Docs to create your plugin.

Comment actions Permalink

Hey, I read the documentation, but still there isnt much about what im asking.. I understand that tgeres zero overlap, bit I guess someone can help with my problem..


Please sign in to leave a comment.