use of com.intellij.refactoring.changeSignature.JavaParameterInfo in project intellij-community by JetBrains.
the class GrChangeSignatureConflictSearcher method addMethodConflicts.
private void addMethodConflicts(MultiMap<PsiElement, String> conflicts) {
try {
GrMethod prototype;
final PsiMethod method = myChangeInfo.getMethod();
if (!(method instanceof GrMethod))
return;
PsiManager manager = method.getManager();
GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(manager.getProject());
final CanonicalTypes.Type returnType = myChangeInfo.getNewReturnType();
String newMethodName = myChangeInfo.getNewName();
if (method.isConstructor()) {
prototype = factory.createConstructorFromText("foo", ArrayUtil.EMPTY_STRING_ARRAY, ArrayUtil.EMPTY_STRING_ARRAY, "{}", method);
} else {
prototype = factory.createMethodFromText("", "foo", returnType != null ? returnType.getTypeText() : null, ArrayUtil.EMPTY_STRING_ARRAY, method);
}
prototype.setName(newMethodName);
JavaParameterInfo[] parameters = myChangeInfo.getNewParameters();
for (JavaParameterInfo info : parameters) {
GrParameter param;
if (info instanceof GrParameterInfo) {
param = factory.createParameter(info.getName(), info.getTypeText(), ((GrParameterInfo) info).getDefaultInitializer(), (GroovyPsiElement) method);
} else {
param = factory.createParameter(info.getName(), info.getTypeText(), (GroovyPsiElement) method);
}
prototype.getParameterList().add(param);
}
ConflictsUtil.checkMethodConflicts(method.getContainingClass(), method, prototype, conflicts);
GrMethodConflictUtil.checkMethodConflicts(method.getContainingClass(), prototype, ((GrMethod) method), conflicts, true);
} catch (IncorrectOperationException e) {
LOG.error(e);
}
}
Aggregations