@Override
 protected PsiCodeFragment createReturnTypeCodeFragment() {
   final String returnTypeText = StringUtil.notNullize(myMethod.getReturnTypeText());
   final JavaCodeFragmentFactory factory = JavaCodeFragmentFactory.getInstance(myProject);
   return factory.createTypeCodeFragment(
       returnTypeText, myMethod.getMethod(), true, JavaCodeFragmentFactory.ALLOW_VOID);
 }
  private void createNameAndReturnTypeEditors() {
    myNameCodeFragment = new GroovyCodeFragment(myProject, "");
    myNameField =
        new EditorTextField(
            PsiDocumentManager.getInstance(myProject).getDocument(myNameCodeFragment),
            myProject,
            myNameCodeFragment.getFileType());

    final JavaCodeFragmentFactory factory = JavaCodeFragmentFactory.getInstance(myProject);
    myReturnTypeCodeFragment =
        factory.createTypeCodeFragment("", myMethod, true, JavaCodeFragmentFactory.ALLOW_VOID);
    final Document document =
        PsiDocumentManager.getInstance(myProject).getDocument(myReturnTypeCodeFragment);
    myReturnTypeField =
        new EditorTextField(document, myProject, myReturnTypeCodeFragment.getFileType());

    myNameField.setText(myMethod.getName());
    final GrTypeElement element = myMethod.getReturnTypeElementGroovy();
    if (element != null) {
      myReturnTypeField.setText(element.getText());
    }

    myReturnTypeLabel = new JLabel();
    myReturnTypeLabel.setLabelFor(myReturnTypeField);

    myNameLabel = new JLabel();
    myNameLabel.setLabelFor(myNameField);
  }
 @Override
 protected PsiFile createExpressionCodeFragment(
     @NotNull Project project,
     @NotNull String text,
     @Nullable PsiElement context,
     boolean isPhysical) {
   return JavaCodeFragmentFactory.getInstance(project)
       .createExpressionCodeFragment(text, context, null, isPhysical);
 }
 private static Document createDocument(
     final String text,
     Project project,
     boolean isClassesAccepted,
     final JavaCodeFragment.VisibilityChecker visibilityChecker) {
   PsiPackage defaultPackage = JavaPsiFacade.getInstance(project).findPackage("");
   final JavaCodeFragment fragment =
       JavaCodeFragmentFactory.getInstance(project)
           .createReferenceCodeFragment(text, defaultPackage, true, isClassesAccepted);
   fragment.setVisibilityChecker(visibilityChecker);
   return PsiDocumentManager.getInstance(project).getDocument(fragment);
 }