Search in sources :

Example 1 with Parameter

use of org.eclipse.jdt.core.refactoring.participants.ChangeMethodSignatureArguments.Parameter 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);
}
Also used : JavaModelException(org.eclipse.jdt.core.JavaModelException) ArrayList(java.util.ArrayList) ChangeMethodSignatureArguments(org.eclipse.jdt.core.refactoring.participants.ChangeMethodSignatureArguments) ParameterInfo(org.eclipse.jdt.internal.corext.refactoring.ParameterInfo) Parameter(org.eclipse.jdt.core.refactoring.participants.ChangeMethodSignatureArguments.Parameter) MethodRefParameter(org.eclipse.jdt.core.dom.MethodRefParameter) ExceptionInfo(org.eclipse.jdt.internal.corext.refactoring.ExceptionInfo) ThrownException(org.eclipse.jdt.core.refactoring.participants.ChangeMethodSignatureArguments.ThrownException)

Aggregations

ArrayList (java.util.ArrayList)1 JavaModelException (org.eclipse.jdt.core.JavaModelException)1 MethodRefParameter (org.eclipse.jdt.core.dom.MethodRefParameter)1 ChangeMethodSignatureArguments (org.eclipse.jdt.core.refactoring.participants.ChangeMethodSignatureArguments)1 Parameter (org.eclipse.jdt.core.refactoring.participants.ChangeMethodSignatureArguments.Parameter)1 ThrownException (org.eclipse.jdt.core.refactoring.participants.ChangeMethodSignatureArguments.ThrownException)1 ExceptionInfo (org.eclipse.jdt.internal.corext.refactoring.ExceptionInfo)1 ParameterInfo (org.eclipse.jdt.internal.corext.refactoring.ParameterInfo)1