String () { if (myReturnTypeCodeFragment != null && !checkType((PsiTypeCodeFragment)myReturnTypeCodeFragment, true)) { return GroovyRefactoringBundle.message("return.type.is.wrong"); } List<GrParameterTableModelItem> parameterInfos = myParametersTableModel.getItems(); int newParameterCount = parameterInfos.size(); for (int i = 0; i < newParameterCount; i++) { GrParameterTableModelItem item = parameterInfos.get(i); String name = item.parameter.getName(); if (!StringUtil.isJavaIdentifier(name)) { return GroovyRefactoringBundle.message("name.is.wrong", name); } if (!checkType((PsiTypeCodeFragment)item.typeCodeFragment, i == newParameterCount - 1)) { return GroovyRefactoringBundle.message("type.for.parameter.is.incorrect", name); } try { item.parameter.setType(((PsiTypeCodeFragment)item.typeCodeFragment).getType()); } catch (PsiTypeCodeFragment.TypeSyntaxException e) { LOG.error(e); } catch (PsiTypeCodeFragment.NoTypeException e) { item.parameter.setType(null); } String defaultValue = item.defaultValueCodeFragment.getText(); final String initializer = item.initializerCodeFragment.getText(); if (item.parameter.getOldIndex() < 0 && defaultValue.trim().isEmpty() && initializer.trim().isEmpty()) { return GroovyRefactoringBundle.message("specify.default.value", name); } item.parameter.setInitializer(initializer); item.parameter.setDefaultValue(defaultValue); } ThrownExceptionInfo[] exceptionInfos = myExceptionsModel.getThrownExceptions(); PsiTypeCodeFragment[] typeCodeFragments = myExceptionsModel.getTypeCodeFragments(); for (int i = 0; i < exceptionInfos.length; i++) { ThrownExceptionInfo exceptionInfo = exceptionInfos[i]; PsiTypeCodeFragment typeCodeFragment = typeCodeFragments[i]; try { PsiType type = typeCodeFragment.getType(); if (!(type instanceof PsiClassType)) { return GroovyRefactoringBundle.message("changeSignature.wrong.type.for.exception", typeCodeFragment.getText()); } PsiElementFactory factory = JavaPsiFacade.getInstance(getProject()).getElementFactory(); PsiClassType throwable = factory.createTypeByFQClassName(CommonClassNames.JAVA_LANG_THROWABLE, myMethod.getMethod().getResolveScope()); if (!throwable.isAssignableFrom(type)) { return GroovyRefactoringBundle.message("changeSignature.not.throwable.type", typeCodeFragment.getText()); } exceptionInfo.setType((PsiClassType)type); } catch (PsiTypeCodeFragment.TypeSyntaxException e) { return GroovyRefactoringBundle.message("changeSignature.wrong.type.for.exception", typeCodeFragment.getText()); } catch (PsiTypeCodeFragment.NoTypeException e) { return GroovyRefactoringBundle.message("changeSignature.no.type.for.exception"); } } return null; }