Java Code Examples for org.eclipse.ltk.core.refactoring.CompositeChange#merge()

The following examples show how to use org.eclipse.ltk.core.refactoring.CompositeChange#merge() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ReorgPolicyFactory.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
private Change createReferenceUpdatingMoveChange(IProgressMonitor pm) throws JavaModelException {
	pm.beginTask("", 2 + (fUpdateQualifiedNames ? 1 : 0)); //$NON-NLS-1$
	try {
		CompositeChange composite= new DynamicValidationStateChange(RefactoringCoreMessages.ReorgPolicy_move);
		composite.markAsSynthetic();
		// XX workaround for bug 13558
		// <workaround>
		if (fChangeManager == null) {
			fChangeManager= createChangeManager(new SubProgressMonitor(pm, 1), new RefactoringStatus());
			// TODO: non-CU matches silently dropped
			RefactoringStatus status;
			try {
				status = Checks.validateModifiesFiles(getAllModifiedFiles(), null, pm);
				if (status.hasFatalError()) {
					fChangeManager = new TextChangeManager();
				}
			} catch (CoreException e) {
				fChangeManager= new TextChangeManager();
			}
		}
		// </workaround>

		composite.merge(new CompositeChange(RefactoringCoreMessages.MoveRefactoring_reorganize_elements, fChangeManager.getAllChanges()));

		Change fileMove= createSimpleMoveChange(new SubProgressMonitor(pm, 1));
		if (fileMove instanceof CompositeChange) {
			composite.merge(((CompositeChange) fileMove));
		} else {
			composite.add(fileMove);
		}
		return composite;
	} finally {
		pm.done();
	}
}
 
Example 2
Source File: ReorgPolicyFactory.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private Change createReferenceUpdatingMoveChange(IProgressMonitor pm) throws JavaModelException {
	pm.beginTask("", 2 + (fUpdateQualifiedNames ? 1 : 0)); //$NON-NLS-1$
	try {
		CompositeChange composite= new DynamicValidationStateChange(RefactoringCoreMessages.ReorgPolicy_move);
		composite.markAsSynthetic();
		// XX workaround for bug 13558
		// <workaround>
		if (fChangeManager == null) {
			fChangeManager= createChangeManager(new SubProgressMonitor(pm, 1), new RefactoringStatus());
			// TODO: non-CU matches silently dropped
			RefactoringStatus status= Checks.validateModifiesFiles(getAllModifiedFiles(), null);
			if (status.hasFatalError())
				fChangeManager= new TextChangeManager();
		}
		// </workaround>

		composite.merge(new CompositeChange(RefactoringCoreMessages.MoveRefactoring_reorganize_elements, fChangeManager.getAllChanges()));

		Change fileMove= createSimpleMoveChange(new SubProgressMonitor(pm, 1));
		if (fileMove instanceof CompositeChange) {
			composite.merge(((CompositeChange) fileMove));
		} else {
			composite.add(fileMove);
		}
		return composite;
	} finally {
		pm.done();
	}
}