Java Code Examples for org.eclipse.jdt.core.ICompilationUnit#findWorkingCopy()

The following examples show how to use org.eclipse.jdt.core.ICompilationUnit#findWorkingCopy() . 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: PushDownRefactoringProcessor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public RefactoringStatus checkFinalConditions(IProgressMonitor monitor, CheckConditionsContext context) throws CoreException, OperationCanceledException {
	try {
		monitor.beginTask(RefactoringCoreMessages.PushDownRefactoring_checking, 5);
		clearCaches();
		ICompilationUnit unit= getDeclaringType().getCompilationUnit();
		if (fLayer)
			unit= unit.findWorkingCopy(fOwner);
		resetWorkingCopies(unit);
		final RefactoringStatus result= new RefactoringStatus();
		result.merge(checkMembersInDestinationClasses(new SubProgressMonitor(monitor, 1)));
		result.merge(checkElementsAccessedByModifiedMembers(new SubProgressMonitor(monitor, 1)));
		result.merge(checkReferencesToPushedDownMembers(new SubProgressMonitor(monitor, 1)));
		if (!JdtFlags.isAbstract(getDeclaringType()) && getAbstractDeclarationInfos().length != 0)
			result.merge(checkConstructorCalls(getDeclaringType(), new SubProgressMonitor(monitor, 1)));
		else
			monitor.worked(1);
		if (result.hasFatalError())
			return result;
		List<IMember> members= new ArrayList<IMember>(fMemberInfos.length);
		for (int index= 0; index < fMemberInfos.length; index++) {
			if (fMemberInfos[index].getAction() != MemberActionInfo.NO_ACTION)
				members.add(fMemberInfos[index].getMember());
		}
		fMembersToMove= members.toArray(new IMember[members.size()]);
		fChangeManager= createChangeManager(new SubProgressMonitor(monitor, 1), result);
		if (result.hasFatalError())
			return result;

		Checks.addModifiedFilesToChecker(ResourceUtil.getFiles(fChangeManager.getAllCompilationUnits()), context);

		return result;
	} finally {
		monitor.done();
	}
}
 
Example 2
Source File: SuperTypeRefactoringProcessor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
protected ICompilationUnit getSharedWorkingCopy(final ICompilationUnit unit, final IProgressMonitor monitor) throws JavaModelException {
	try {
		ICompilationUnit copy= unit.findWorkingCopy(fOwner);
		if (copy == null)
			copy= unit.getWorkingCopy(fOwner, monitor);
		return copy;
	} finally {
		monitor.done();
	}
}
 
Example 3
Source File: PullUpRefactoringProcessor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates a working copy layer if necessary.
 *
 * @param monitor
 *            the progress monitor to use
 * @return a status describing the outcome of the operation
 */
protected RefactoringStatus createWorkingCopyLayer(IProgressMonitor monitor) {
	try {
		monitor.beginTask(RefactoringCoreMessages.PullUpRefactoring_checking, 1);
		ICompilationUnit unit= getDeclaringType().getCompilationUnit();
		if (fLayer)
			unit= unit.findWorkingCopy(fOwner);
		resetWorkingCopies(unit);
		return new RefactoringStatus();
	} finally {
		monitor.done();
	}
}
 
Example 4
Source File: PullUpRefactoringProcessor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Resets the environment before the first wizard page becomes visible.
 */
public void resetEnvironment() {
	ICompilationUnit unit= getDeclaringType().getCompilationUnit();
	if (fLayer)
		unit= unit.findWorkingCopy(fOwner);
	resetWorkingCopies(unit);
}