use of org.eclipse.jdt.core.refactoring.participants.ChangeMethodSignatureArguments in project che by eclipse.
the class ChangeSignatureProcessor method getParticipantArguments.
private ChangeMethodSignatureArguments getParticipantArguments() {
ArrayList<Parameter> parameterList = new ArrayList<Parameter>();
List<ParameterInfo> pis = getParameterInfos();
String[] originalParameterTypeSigs = fMethod.getParameterTypes();
for (Iterator<ParameterInfo> iter = pis.iterator(); iter.hasNext(); ) {
ParameterInfo pi = iter.next();
if (!pi.isDeleted()) {
int oldIndex = pi.isAdded() ? -1 : pi.getOldIndex();
String newName = pi.getNewName();
String typeSig;
if (pi.isTypeNameChanged()) {
String newType = pi.getNewTypeName();
if (pi.isNewVarargs()) {
//$NON-NLS-1$
newType = ParameterInfo.stripEllipsis(newType) + "[]";
}
typeSig = Signature.createTypeSignature(newType, false);
} else {
typeSig = originalParameterTypeSigs[pi.getOldIndex()];
}
String defaultValue = pi.getDefaultValue();
parameterList.add(new Parameter(oldIndex, newName, typeSig, defaultValue));
}
}
Parameter[] parameters = parameterList.toArray(new Parameter[parameterList.size()]);
ArrayList<ThrownException> exceptionList = new ArrayList<ThrownException>();
List<ExceptionInfo> exceptionInfos = getExceptionInfos();
for (int i = 0; i < exceptionInfos.size(); i++) {
ExceptionInfo ei = exceptionInfos.get(i);
if (!ei.isDeleted()) {
int oldIndex = ei.isAdded() ? -1 : i;
String qualifiedTypeName = ei.getFullyQualifiedName();
String newTypeSig = Signature.createTypeSignature(qualifiedTypeName, true);
exceptionList.add(new ThrownException(oldIndex, newTypeSig));
}
}
ThrownException[] exceptions = exceptionList.toArray(new ThrownException[exceptionList.size()]);
String returnTypeSig;
if (fReturnTypeInfo.isTypeNameChanged()) {
returnTypeSig = Signature.createTypeSignature(fReturnTypeInfo.getNewTypeName(), false);
} else {
try {
returnTypeSig = fMethod.getReturnType();
} catch (JavaModelException e) {
returnTypeSig = Signature.createTypeSignature(fReturnTypeInfo.getNewTypeName(), false);
}
}
return new ChangeMethodSignatureArguments(fMethodName, returnTypeSig, fVisibility, parameters, exceptions, fDelegateUpdating);
}
Aggregations