Java 类org.eclipse.jdt.core.refactoring.descriptors.IntroduceParameterObjectDescriptor 实例源码

项目:Eclipse-Postfix-Code-Completion    文件:IntroduceParameterObjectProcessor.java   
public IntroduceParameterObjectProcessor(IntroduceParameterObjectDescriptor descriptor) throws JavaModelException {
    super(descriptor.getMethod());
    IMethod method= descriptor.getMethod();
    Assert.isNotNull(method);
    initializeFields(method);
    setBodyUpdater(new RewriteParameterBody());
    setDefaultValueAdvisor(new ParameterObjectCreator());
    configureRefactoring(descriptor, this);
}
项目:Eclipse-Postfix-Code-Completion    文件:IntroduceParameterObjectProcessor.java   
@Override
public JavaRefactoringDescriptor createDescriptor() {
    IntroduceParameterObjectDescriptor ipod= RefactoringSignatureDescriptorFactory.createIntroduceParameterObjectDescriptor();
    ipod.setMethod(getMethod());
    ipod.setClassName(getClassName());
    ipod.setDelegate(getDelegateUpdating());
    ipod.setDeprecateDelegate(getDeprecateDelegates());
    ipod.setGetters(isCreateGetter());
    ipod.setSetters(isCreateSetter());
    ipod.setPackageName(getPackage());
    ipod.setParameterName(getParameterName());
    ipod.setTopLevel(isCreateAsTopLevel());

    ArrayList<Parameter> parameters= new ArrayList<Parameter>();
    List<ParameterInfo> pis= getParameterInfos();
    for (Iterator<ParameterInfo> iter= pis.iterator(); iter.hasNext();) {
        ParameterInfo pi= iter.next();
        if (pi.isAdded()) {
            parameters.add(IntroduceParameterObjectDescriptor.PARAMETER_OBJECT);
        } else {
            IntroduceParameterObjectDescriptor.Parameter parameter= new IntroduceParameterObjectDescriptor.Parameter(pi.getOldIndex());
            if (pi.isCreateField()) {
                parameter.setCreateField(true);
                parameter.setFieldName(pi.getNewName());
            }
            parameters.add(parameter);
        }
    }
    ipod.setParameters(parameters.toArray(new Parameter[parameters.size()]));
    String project= getCompilationUnit().getJavaProject().getElementName();
    try {
        ipod.setComment(createComment(project).asString());
    } catch (JavaModelException e) {
        JavaPlugin.log(e);
    }
    ipod.setProject(project);
    ipod.setDescription(getProcessorName());
    ipod.setFlags(getDescriptorFlags());
    return ipod;
}
项目:Eclipse-Postfix-Code-Completion    文件:IntroduceParameterObjectContribution.java   
@Override
public Refactoring createRefactoring(JavaRefactoringDescriptor descriptor, RefactoringStatus status) throws CoreException {
    if (descriptor instanceof IntroduceParameterObjectDescriptor) {
        IntroduceParameterObjectProcessor processor= new IntroduceParameterObjectProcessor((IntroduceParameterObjectDescriptor) descriptor);
        return new ProcessorBasedRefactoring(processor);
    }
    return null;
}
项目:Eclipse-Postfix-Code-Completion    文件:RefactoringExecutionStarter.java   
public static void startIntroduceParameterObject(IMethod method, Shell shell) throws CoreException {
    RefactoringStatus availability= Checks.checkAvailability(method);
    if (availability.hasError()){
        MessageDialog.openError(shell, RefactoringMessages.RefactoringExecutionStarter_IntroduceParameterObject_problem_title, RefactoringMessages.RefactoringExecutionStarter_IntroduceParameterObject_problem_description);
        return;
    }
    IntroduceParameterObjectDescriptor ipod= RefactoringSignatureDescriptorFactory.createIntroduceParameterObjectDescriptor();
    ipod.setMethod(method);

    IntroduceParameterObjectProcessor processor= new IntroduceParameterObjectProcessor(ipod);

    final RefactoringStatus status= processor.checkInitialConditions(new NullProgressMonitor());
    if (status.hasFatalError()) {
        final RefactoringStatusEntry entry= status.getEntryMatchingSeverity(RefactoringStatus.FATAL);
        if (entry.getCode() == RefactoringStatusCodes.OVERRIDES_ANOTHER_METHOD || entry.getCode() == RefactoringStatusCodes.METHOD_DECLARED_IN_INTERFACE) {
            final Object element= entry.getData();
            IMethod superMethod= (IMethod) element;
            availability= Checks.checkAvailability(superMethod);
            if (availability.hasError()){
                MessageDialog.openError(shell, RefactoringMessages.RefactoringExecutionStarter_IntroduceParameterObject_problem_title, RefactoringMessages.RefactoringExecutionStarter_IntroduceParameterObject_problem_description);
                return;
            }
            String message= Messages.format(RefactoringMessages.RefactoringErrorDialogUtil_okToPerformQuestion, entry.getMessage());
            if (element != null && MessageDialog.openQuestion(shell, RefactoringMessages.OpenRefactoringWizardAction_refactoring, message)) {
                ipod= RefactoringSignatureDescriptorFactory.createIntroduceParameterObjectDescriptor();
                ipod.setMethod(superMethod);
                processor= new IntroduceParameterObjectProcessor(ipod);
            }
            else processor=null;
        }
    }
    if (processor != null) {
        Refactoring refactoring= new ProcessorBasedRefactoring(processor);
        IntroduceParameterObjectWizard wizard= new IntroduceParameterObjectWizard(processor, refactoring);
        new RefactoringStarter().activate(wizard, shell, RefactoringMessages.OpenRefactoringWizardAction_refactoring, RefactoringSaveHelper.SAVE_REFACTORING);
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:IntroduceParameterObjectProcessor.java   
public IntroduceParameterObjectProcessor(IntroduceParameterObjectDescriptor descriptor) throws JavaModelException {
    super(descriptor.getMethod());
    IMethod method= descriptor.getMethod();
    Assert.isNotNull(method);
    initializeFields(method);
    setBodyUpdater(new RewriteParameterBody());
    setDefaultValueAdvisor(new ParameterObjectCreator());
    configureRefactoring(descriptor, this);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:IntroduceParameterObjectProcessor.java   
@Override
public JavaRefactoringDescriptor createDescriptor() {
    IntroduceParameterObjectDescriptor ipod= RefactoringSignatureDescriptorFactory.createIntroduceParameterObjectDescriptor();
    ipod.setMethod(getMethod());
    ipod.setClassName(getClassName());
    ipod.setDelegate(getDelegateUpdating());
    ipod.setDeprecateDelegate(getDeprecateDelegates());
    ipod.setGetters(isCreateGetter());
    ipod.setSetters(isCreateSetter());
    ipod.setPackageName(getPackage());
    ipod.setParameterName(getParameterName());
    ipod.setTopLevel(isCreateAsTopLevel());

    ArrayList<Parameter> parameters= new ArrayList<Parameter>();
    List<ParameterInfo> pis= getParameterInfos();
    for (Iterator<ParameterInfo> iter= pis.iterator(); iter.hasNext();) {
        ParameterInfo pi= iter.next();
        if (pi.isAdded()) {
            parameters.add(IntroduceParameterObjectDescriptor.PARAMETER_OBJECT);
        } else {
            IntroduceParameterObjectDescriptor.Parameter parameter= new IntroduceParameterObjectDescriptor.Parameter(pi.getOldIndex());
            if (pi.isCreateField()) {
                parameter.setCreateField(true);
                parameter.setFieldName(pi.getNewName());
            }
            parameters.add(parameter);
        }
    }
    ipod.setParameters(parameters.toArray(new Parameter[parameters.size()]));
    String project= getCompilationUnit().getJavaProject().getElementName();
    try {
        ipod.setComment(createComment(project).asString());
    } catch (JavaModelException e) {
        JavaPlugin.log(e);
    }
    ipod.setProject(project);
    ipod.setDescription(getProcessorName());
    ipod.setFlags(getDescriptorFlags());
    return ipod;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:IntroduceParameterObjectContribution.java   
@Override
public Refactoring createRefactoring(JavaRefactoringDescriptor descriptor, RefactoringStatus status) throws CoreException {
    if (descriptor instanceof IntroduceParameterObjectDescriptor) {
        IntroduceParameterObjectProcessor processor= new IntroduceParameterObjectProcessor((IntroduceParameterObjectDescriptor) descriptor);
        return new ProcessorBasedRefactoring(processor);
    }
    return null;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:RefactoringExecutionStarter.java   
public static void startIntroduceParameterObject(IMethod method, Shell shell) throws CoreException {
    RefactoringStatus availability= Checks.checkAvailability(method);
    if (availability.hasError()){
        MessageDialog.openError(shell, RefactoringMessages.RefactoringExecutionStarter_IntroduceParameterObject_problem_title, RefactoringMessages.RefactoringExecutionStarter_IntroduceParameterObject_problem_description);
        return;
    }
    IntroduceParameterObjectDescriptor ipod= RefactoringSignatureDescriptorFactory.createIntroduceParameterObjectDescriptor();
    ipod.setMethod(method);

    IntroduceParameterObjectProcessor processor= new IntroduceParameterObjectProcessor(ipod);

    final RefactoringStatus status= processor.checkInitialConditions(new NullProgressMonitor());
    if (status.hasFatalError()) {
        final RefactoringStatusEntry entry= status.getEntryMatchingSeverity(RefactoringStatus.FATAL);
        if (entry.getCode() == RefactoringStatusCodes.OVERRIDES_ANOTHER_METHOD || entry.getCode() == RefactoringStatusCodes.METHOD_DECLARED_IN_INTERFACE) {
            final Object element= entry.getData();
            IMethod superMethod= (IMethod) element;
            availability= Checks.checkAvailability(superMethod);
            if (availability.hasError()){
                MessageDialog.openError(shell, RefactoringMessages.RefactoringExecutionStarter_IntroduceParameterObject_problem_title, RefactoringMessages.RefactoringExecutionStarter_IntroduceParameterObject_problem_description);
                return;
            }
            String message= Messages.format(RefactoringMessages.RefactoringErrorDialogUtil_okToPerformQuestion, entry.getMessage());
            if (element != null && MessageDialog.openQuestion(shell, RefactoringMessages.OpenRefactoringWizardAction_refactoring, message)) {
                ipod= RefactoringSignatureDescriptorFactory.createIntroduceParameterObjectDescriptor();
                ipod.setMethod(superMethod);
                processor= new IntroduceParameterObjectProcessor(ipod);
            }
            else processor=null;
        }
    }
    if (processor != null) {
        Refactoring refactoring= new ProcessorBasedRefactoring(processor);
        IntroduceParameterObjectWizard wizard= new IntroduceParameterObjectWizard(processor, refactoring);
        new RefactoringStarter().activate(wizard, shell, RefactoringMessages.OpenRefactoringWizardAction_refactoring, RefactoringSaveHelper.SAVE_REFACTORING);
    }
}
项目:che    文件:RefactoringSignatureDescriptorFactory.java   
public static IntroduceParameterObjectDescriptor createIntroduceParameterObjectDescriptor() {
  return new IntroduceParameterObjectDescriptor();
}
项目:che    文件:RefactoringSignatureDescriptorFactory.java   
public static IntroduceParameterObjectDescriptor createIntroduceParameterObjectDescriptor(
    String project, String description, String comment, Map arguments, int flags)
    throws IllegalArgumentException {
  return new IntroduceParameterObjectDescriptor(project, description, comment, arguments, flags);
}