GrMethod (String constructorName, CharSequence constructorText, @Nullable PsiElement context) { GroovyFile file = createGroovyFileChecked("class " + constructorName + "{" + constructorText + "}", false, context); GrTypeDefinition definition = file.getTypeDefinitions()[0]; if (definition == null) { throw new IncorrectOperationException("constructorName: " + constructorName + ", text: " + constructorText); } GrMethod[] methods = definition.getCodeMethods(); if (methods.length != 1) { throw new IncorrectOperationException("constructorName: " + constructorName + ", text: " + constructorText); } return methods[0]; }