GrMethod (@NotNull String modifier, @NotNull String name, @Nullable String type, String @NotNull [] paramTypes, PsiElement context) { PsiType psiType; List<PsiType> res = new ArrayList<>(); final GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(myProject); for (String paramType : paramTypes) { try { psiType = factory.createTypeElement(paramType).getType(); } catch (IncorrectOperationException e) { psiType = TypesUtil.getJavaLangObject(context); } res.add(psiType); } String[] paramNames = GroovyNamesUtil.getMethodArgumentsNames(myProject, res.toArray(PsiType.createArray(res.size()))); final CharSequence text = generateMethodText(modifier, name, type, paramTypes, paramNames, null, false); return createMethodFromText(text.toString(), context); }