Search in sources :

Example 1 with DeletePackageFragmentRootChange

use of org.eclipse.jdt.internal.corext.refactoring.changes.DeletePackageFragmentRootChange in project che by eclipse.

the class DeleteChangeCreator method createPackageFragmentRootDeleteChange.

private static Change createPackageFragmentRootDeleteChange(IPackageFragmentRoot root) throws JavaModelException {
    IResource resource = root.getResource();
    if (resource != null && resource.isLinked()) {
        //XXX using this code is a workaround for jcore bug 31998
        //jcore cannot handle linked stuff
        //normally, we should always create DeletePackageFragmentRootChange
        CompositeChange composite = new DynamicValidationStateChange(RefactoringCoreMessages.DeleteRefactoring_delete_package_fragment_root);
        ClasspathChange change = ClasspathChange.removeEntryChange(root.getJavaProject(), root.getRawClasspathEntry());
        if (change != null) {
            composite.add(change);
        }
        //checked in preconditions
        Assert.isTrue(!Checks.isClasspathDelete(root));
        composite.add(createDeleteChange(resource));
        return composite;
    } else {
        Assert.isTrue(!root.isExternal());
        // TODO remove the query argument
        return new DeletePackageFragmentRootChange(root, true, null);
    }
}
Also used : ClasspathChange(org.eclipse.jdt.internal.corext.refactoring.changes.ClasspathChange) DeletePackageFragmentRootChange(org.eclipse.jdt.internal.corext.refactoring.changes.DeletePackageFragmentRootChange) CompositeChange(org.eclipse.ltk.core.refactoring.CompositeChange) IResource(org.eclipse.core.resources.IResource) DynamicValidationStateChange(org.eclipse.jdt.internal.corext.refactoring.changes.DynamicValidationStateChange)

Aggregations

IResource (org.eclipse.core.resources.IResource)1 ClasspathChange (org.eclipse.jdt.internal.corext.refactoring.changes.ClasspathChange)1 DeletePackageFragmentRootChange (org.eclipse.jdt.internal.corext.refactoring.changes.DeletePackageFragmentRootChange)1 DynamicValidationStateChange (org.eclipse.jdt.internal.corext.refactoring.changes.DynamicValidationStateChange)1 CompositeChange (org.eclipse.ltk.core.refactoring.CompositeChange)1