Example usage for org.eclipse.jdt.core ICompilationUnit getWorkingCopy

List of usage examples for org.eclipse.jdt.core ICompilationUnit getWorkingCopy

Introduction

In this page you can find the example usage for org.eclipse.jdt.core ICompilationUnit getWorkingCopy.

Prototype

ICompilationUnit getWorkingCopy(WorkingCopyOwner owner, IProblemRequestor problemRequestor,
        IProgressMonitor monitor) throws JavaModelException;

Source Link

Document

Returns a shared working copy on this compilation unit using the given working copy owner to create the buffer, or this compilation unit if it is already a non-primary working copy.

Usage

From source file:org.eclipse.objectteams.otdt.tests.AbstractJavaModelTests.java

License:Open Source License

/**
 * This method is still necessary when we need to use an owner and a specific problem requestor
 * (typically while using primary owner).
 * @deprecated/*from   w  ww .java 2 s  .  c  o  m*/
 */
public ICompilationUnit getWorkingCopy(String path, String source, WorkingCopyOwner owner,
        IProblemRequestor problemRequestor) throws JavaModelException {
    ICompilationUnit workingCopy = getCompilationUnit(path);
    if (owner != null)
        workingCopy = workingCopy.getWorkingCopy(owner, problemRequestor, null/*no progress monitor*/);
    else
        workingCopy.becomeWorkingCopy(problemRequestor, null/*no progress monitor*/);
    workingCopy.getBuffer().setContents(source);
    if (problemRequestor instanceof ProblemRequestor)
        ((ProblemRequestor) problemRequestor).initialize(source.toCharArray());
    workingCopy.makeConsistent(null/*no progress monitor*/);
    return workingCopy;
}