GrMethod (PsiClass aClass, FileTemplate template) { Properties properties = FileTemplateManager.getInstance(aClass.getProject()).getDefaultProperties(); properties.setProperty(FileTemplate.ATTRIBUTE_RETURN_TYPE, "java.lang.Object"); properties.setProperty(FileTemplate.ATTRIBUTE_DEFAULT_RETURN_VALUE, "null"); properties.setProperty(FileTemplate.ATTRIBUTE_CALL_SUPER, ""); String fqn = aClass.getQualifiedName(); if (fqn != null) properties.setProperty(FileTemplate.ATTRIBUTE_CLASS_NAME, fqn); String className = aClass.getName(); if (className != null) properties.setProperty(FileTemplate.ATTRIBUTE_SIMPLE_CLASS_NAME, className); properties.setProperty(FileTemplate.ATTRIBUTE_METHOD_NAME, "methodMissing"); String bodyText; try { bodyText = StringUtil.replace(template.getText(properties), ";", ""); } catch (IOException e) { return null; } return GroovyPsiElementFactory.getInstance(aClass.getProject()) .createMethodFromText("def methodMissing(String name, def args) {\n" + bodyText + "\n}"); }