@Override public void applyTransformation(@NotNull TransformationContext context) { if (!(context.getCodeClass() instanceof GroovyScriptClass)) return; GroovyScriptClass scriptClass = (GroovyScriptClass) context.getCodeClass(); LightMethodBuilder mainMethod = new LightMethodBuilder(scriptClass.getManager(), GroovyLanguage.INSTANCE, "main") .setMethodReturnType(PsiType.VOID) .addParameter( "args", new PsiArrayType( PsiType.getJavaLangString( scriptClass.getManager(), scriptClass.getResolveScope()))) .addModifiers(PsiModifier.PUBLIC, PsiModifier.STATIC); LightMethodBuilder runMethod = new LightMethodBuilder(scriptClass.getManager(), GroovyLanguage.INSTANCE, "run") .setMethodReturnType(TypesUtil.getJavaLangObject(scriptClass)) .addModifier(PsiModifier.PUBLIC); context.addMethod(runMethod, true); context.addMethod(mainMethod, true); context.setSuperType(getBaseClassType(scriptClass)); }