Example usage for org.eclipse.jdt.internal.core BecomeWorkingCopyOperation BecomeWorkingCopyOperation

List of usage examples for org.eclipse.jdt.internal.core BecomeWorkingCopyOperation BecomeWorkingCopyOperation

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.core BecomeWorkingCopyOperation BecomeWorkingCopyOperation.

Prototype

public BecomeWorkingCopyOperation(CompilationUnit workingCopy, IProblemRequestor problemRequestor) 

Source Link

Usage

From source file:org.eclipse.ajdt.core.javaelements.AJCompilationUnit.java

License:Open Source License

/**
 * @see ICompilationUnit#getWorkingCopy(WorkingCopyOwner, IProblemRequestor, IProgressMonitor)
 *///  w w  w  .j  a  v  a  2 s.  co  m
public ICompilationUnit getWorkingCopy(WorkingCopyOwner workingCopyOwner, IProblemRequestor problemRequestor,
        IProgressMonitor monitor) throws JavaModelException {
    if (!isPrimary())
        return this;

    JavaModelManager manager = JavaModelManager.getJavaModelManager();

    CompilationUnit workingCopy = new AJCompilationUnit((PackageFragment) getParent(), getElementName(),
            workingCopyOwner);
    JavaModelManager.PerWorkingCopyInfo perWorkingCopyInfo = manager.getPerWorkingCopyInfo(workingCopy,
            false/*don't create*/, true/*record usage*/, null/*not used since don't create*/);
    if (perWorkingCopyInfo != null) {
        return perWorkingCopyInfo.getWorkingCopy(); // return existing handle instead of the one created above
    }
    BecomeWorkingCopyOperation op = new BecomeWorkingCopyOperation(workingCopy, problemRequestor);
    op.runOperation(monitor);
    return workingCopy;
}

From source file:org.eclipse.jdt.internal.core.CompilationUnit.java

License:Open Source License

public void becomeWorkingCopy(IProblemRequestor problemRequestor, IProgressMonitor monitor)
        throws JavaModelException {
    JavaModelManager manager = JavaModelManager.getJavaModelManager();
    JavaModelManager.PerWorkingCopyInfo perWorkingCopyInfo = manager.getPerWorkingCopyInfo(this,
            false/*don't create*/, true /*record usage*/, null/*no problem requestor needed*/);
    if (perWorkingCopyInfo == null) {
        // close cu and its children
        close();//from  ww  w .ja v  a2  s  . co  m

        BecomeWorkingCopyOperation operation = new BecomeWorkingCopyOperation(this, problemRequestor);
        operation.runOperation(monitor);
    }
}

From source file:org.eclipse.jdt.internal.core.CompilationUnit.java

License:Open Source License

/**
 * @see ICompilationUnit#getWorkingCopy(WorkingCopyOwner, IProblemRequestor, IProgressMonitor)
 * @deprecated//from w  ww.j a  v  a 2 s. c o m
 */
public ICompilationUnit getWorkingCopy(WorkingCopyOwner workingCopyOwner, IProblemRequestor problemRequestor,
        IProgressMonitor monitor) throws JavaModelException {
    if (!isPrimary())
        return this;

    JavaModelManager manager = JavaModelManager.getJavaModelManager();

    // GROOVY start
    /* old {
    CompilationUnit workingCopy = new CompilationUnit((PackageFragment)getParent(), getElementName(), workingCopyOwner);
    } new */
    CompilationUnit workingCopy = LanguageSupportFactory.newCompilationUnit((PackageFragment) getParent(),
            getElementName(), workingCopyOwner);
    // GROOVY end
    JavaModelManager.PerWorkingCopyInfo perWorkingCopyInfo = manager.getPerWorkingCopyInfo(workingCopy,
            false/*don't create*/, true/*record usage*/, null/*not used since don't create*/);
    if (perWorkingCopyInfo != null) {
        return perWorkingCopyInfo.getWorkingCopy(); // return existing handle instead of the one created above
    }
    BecomeWorkingCopyOperation op = new BecomeWorkingCopyOperation(workingCopy, problemRequestor);
    op.runOperation(monitor);
    return workingCopy;
}