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

项目:Eclipse-Postfix-Code-Completion    文件:ExtractClassRefactoring.java   
public ExtractClassRefactoring(ExtractClassDescriptor descriptor) {
    fDescriptor= descriptor;
    IType type= fDescriptor.getType();
    if (fDescriptor.getPackage() == null) {
        fDescriptor.setPackage(type.getPackageFragment().getElementName());
    }
    if (fDescriptor.getClassName() == null) {
        fDescriptor.setClassName(type.getElementName() + "Data"); //$NON-NLS-1$
    }
    if (fDescriptor.getFieldName() == null) {
        fDescriptor.setFieldName(StubUtility.getVariableNameSuggestions(NamingConventions.VK_INSTANCE_FIELD, type.getJavaProject(), "data", 0, null, true)[0]); //$NON-NLS-1$
    }
    if (fDescriptor.getFields() == null) {
        try {
            fDescriptor.setFields(ExtractClassDescriptor.getFields(type));
        } catch (JavaModelException e) {
            JavaPlugin.log(e);
        }
    }
    fVerification= new ExtractClassDescriptorVerification(descriptor);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ExtractClassRefactoring.java   
public ExtractClassRefactoring(ExtractClassDescriptor descriptor) {
    fDescriptor= descriptor;
    IType type= fDescriptor.getType();
    if (fDescriptor.getPackage() == null) {
        fDescriptor.setPackage(type.getPackageFragment().getElementName());
    }
    if (fDescriptor.getClassName() == null) {
        fDescriptor.setClassName(type.getElementName() + "Data"); //$NON-NLS-1$
    }
    if (fDescriptor.getFieldName() == null) {
        fDescriptor.setFieldName(StubUtility.getVariableNameSuggestions(NamingConventions.VK_INSTANCE_FIELD, type.getJavaProject(), "data", 0, null, true)[0]); //$NON-NLS-1$
    }
    if (fDescriptor.getFields() == null) {
        try {
            fDescriptor.setFields(ExtractClassDescriptor.getFields(type));
        } catch (JavaModelException e) {
            JavaPlugin.log(e);
        }
    }
    fVerification= new ExtractClassDescriptorVerification(descriptor);
}
项目:Eclipse-Postfix-Code-Completion    文件:ExtractClassRefactoring.java   
@Override
public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException, OperationCanceledException {
    RefactoringStatus result= new RefactoringStatus();
    pm.beginTask(RefactoringCoreMessages.ExtractClassRefactoring_progress_msg_check_initial_condition, 5);
    try {
        result.merge(fDescriptor.validateDescriptor());
        if (!result.isOK())
            return result;
        IType type= fDescriptor.getType();
        result.merge(Checks.checkAvailability(type));
        if (!result.isOK())
            return result;
        pm.worked(1);
        Field[] fields= ExtractClassDescriptor.getFields(fDescriptor.getType());
        pm.worked(1);
        if (pm.isCanceled())
            throw new OperationCanceledException();
        fVariables= new LinkedHashMap<String, FieldInfo>();
        if (fields.length == 0) {
            result.addFatalError(RefactoringCoreMessages.ExtractClassRefactoring_error_no_usable_fields, JavaStatusContext.create(type));
            return result;
        }
        for (int i= 0; i < fields.length; i++) {
            Field field= fields[i];
            String fieldName= field.getFieldName();
            IField declField= type.getField(fieldName);
            ParameterInfo info= new ParameterInfo(Signature.toString(declField.getTypeSignature()), fieldName, i);
            fVariables.put(fieldName, new FieldInfo(info, declField));
            if (pm.isCanceled())
                throw new OperationCanceledException();
        }
        pm.worked(3);
    } finally {
        pm.done();
    }
    return result;
}
项目:Eclipse-Postfix-Code-Completion    文件:ExtractClassContribution.java   
@Override
public Refactoring createRefactoring(JavaRefactoringDescriptor descriptor, RefactoringStatus status) throws CoreException {
    if (!(descriptor instanceof ExtractClassDescriptor)) {
        status.addFatalError(RefactoringCoreMessages.ExtractClassContribution_error_unknown_descriptor);
        return null;
    }
    return new ExtractClassRefactoring((ExtractClassDescriptor) descriptor);
}
项目:Eclipse-Postfix-Code-Completion    文件:RefactoringExecutionStarter.java   
public static void startExtractClassRefactoring(IType type, Shell shell) {
    ExtractClassDescriptor descriptor= RefactoringSignatureDescriptorFactory.createExtractClassDescriptor();
    descriptor.setType(type);
    ExtractClassRefactoring refactoring= new ExtractClassRefactoring(descriptor);
    ExtractClassWizard wizard= new ExtractClassWizard(descriptor, refactoring);
    new RefactoringStarter().activate(wizard, shell, RefactoringMessages.OpenRefactoringWizardAction_refactoring, RefactoringSaveHelper.SAVE_REFACTORING);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ExtractClassRefactoring.java   
@Override
public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException, OperationCanceledException {
    RefactoringStatus result= new RefactoringStatus();
    pm.beginTask(RefactoringCoreMessages.ExtractClassRefactoring_progress_msg_check_initial_condition, 5);
    try {
        result.merge(fDescriptor.validateDescriptor());
        if (!result.isOK())
            return result;
        IType type= fDescriptor.getType();
        result.merge(Checks.checkAvailability(type));
        if (!result.isOK())
            return result;
        pm.worked(1);
        Field[] fields= ExtractClassDescriptor.getFields(fDescriptor.getType());
        pm.worked(1);
        if (pm.isCanceled())
            throw new OperationCanceledException();
        fVariables= new LinkedHashMap<String, FieldInfo>();
        if (fields.length == 0) {
            result.addFatalError(RefactoringCoreMessages.ExtractClassRefactoring_error_no_usable_fields, JavaStatusContext.create(type));
            return result;
        }
        for (int i= 0; i < fields.length; i++) {
            Field field= fields[i];
            String fieldName= field.getFieldName();
            IField declField= type.getField(fieldName);
            ParameterInfo info= new ParameterInfo(Signature.toString(declField.getTypeSignature()), fieldName, i);
            fVariables.put(fieldName, new FieldInfo(info, declField));
            if (pm.isCanceled())
                throw new OperationCanceledException();
        }
        pm.worked(3);
    } finally {
        pm.done();
    }
    return result;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ExtractClassContribution.java   
@Override
public Refactoring createRefactoring(JavaRefactoringDescriptor descriptor, RefactoringStatus status) throws CoreException {
    if (!(descriptor instanceof ExtractClassDescriptor)) {
        status.addFatalError(RefactoringCoreMessages.ExtractClassContribution_error_unknown_descriptor);
        return null;
    }
    return new ExtractClassRefactoring((ExtractClassDescriptor) descriptor);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:RefactoringExecutionStarter.java   
public static void startExtractClassRefactoring(IType type, Shell shell) {
    ExtractClassDescriptor descriptor= RefactoringSignatureDescriptorFactory.createExtractClassDescriptor();
    descriptor.setType(type);
    ExtractClassRefactoring refactoring= new ExtractClassRefactoring(descriptor);
    ExtractClassWizard wizard= new ExtractClassWizard(descriptor, refactoring);
    new RefactoringStarter().activate(wizard, shell, RefactoringMessages.OpenRefactoringWizardAction_refactoring, RefactoringSaveHelper.SAVE_REFACTORING);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ExtractClassWizard.java   
public Object[] getElements(Object inputElement) {
    if (inputElement instanceof ExtractClassDescriptor) {
        ExtractClassDescriptor descriptor= (ExtractClassDescriptor) inputElement;
        return descriptor.getFields();
    }
    return null;
}
项目:che    文件:RefactoringSignatureDescriptorFactory.java   
public static ExtractClassDescriptor createExtractClassDescriptor(
    String project, String description, String comment, Map arguments, int flags)
    throws IllegalArgumentException {
  return new ExtractClassDescriptor(project, description, comment, arguments, flags);
}
项目:che    文件:RefactoringSignatureDescriptorFactory.java   
public static ExtractClassDescriptor createExtractClassDescriptor() {
  return new ExtractClassDescriptor();
}
项目:Eclipse-Postfix-Code-Completion    文件:ExtractClassRefactoring.java   
public ExtractClassDescriptorVerification(ExtractClassDescriptor descriptor) {
    fDescriptor= descriptor;
}
项目:Eclipse-Postfix-Code-Completion    文件:ExtractClassWizard.java   
public ExtractClassWizard(ExtractClassDescriptor descriptor, Refactoring refactoring) {
    super(refactoring, DIALOG_BASED_USER_INTERFACE);
    fDescriptor= descriptor;
    setDefaultPageTitle(RefactoringMessages.ExtractClassWizard_page_title);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ExtractClassRefactoring.java   
public ExtractClassDescriptorVerification(ExtractClassDescriptor descriptor) {
    fDescriptor= descriptor;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ExtractClassWizard.java   
public ExtractClassWizard(ExtractClassDescriptor descriptor, Refactoring refactoring) {
    super(refactoring, DIALOG_BASED_USER_INTERFACE);
    fDescriptor= descriptor;
    setDefaultPageTitle(RefactoringMessages.ExtractClassWizard_page_title);
}