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); }
@Nullable public static String getTypeText(@Nullable GrTypeElement typeElement) { return typeElement == null ? null : typeElement.getText(); }