public abstract class WorkingCopyOwner
extends java.lang.Object
IJavaScriptUnit
handle in working copy mode.
An owner is used to identify a working copy and to create its buffer.
Clients should subclass this class to instantiate a working copy owner that is specific to their need and that
they can pass in to various APIs (e.g. IType.resolveType(String, WorkingCopyOwner)
.
Clients can also override the default implementation of createBuffer(IJavaScriptUnit)
.
Note: even though this class has no abstract method, which means that it provides functional default behavior, it is still an abstract class, as clients are intended to own their owner implementation.
IJavaScriptUnit#becomeWorkingCopy(org.eclipse.core.runtime.IProgressMonitor)
,
IJavaScriptUnit.discardWorkingCopy()
,
Provisional API: This class/interface is part of an interim API that is still under development and expected to
change significantly before reaching stability. It is being made available at this early stage to solicit feedback
from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
(repeatedly) as the API evolves.
Constructor and Description |
---|
WorkingCopyOwner() |
Modifier and Type | Method and Description |
---|---|
IBuffer |
createBuffer(IJavaScriptUnit workingCopy)
Creates a buffer for the given working copy.
|
IProblemRequestor |
getProblemRequestor(IJavaScriptUnit workingCopy)
Returns the problem requestor used by a working copy of this working copy owner.
|
IJavaScriptUnit |
newWorkingCopy(java.lang.String name,
IIncludePathEntry[] classpath,
IProgressMonitor monitor)
Returns a new working copy with the given name using this working copy owner to
create its buffer.
|
static void |
setPrimaryBufferProvider(WorkingCopyOwner primaryBufferProvider)
Sets the buffer provider of the primary working copy owner.
|
public static void setPrimaryBufferProvider(WorkingCopyOwner primaryBufferProvider)
createBuffer(IJavaScriptUnit)
method is used by the primary working copy owner. It doesn't replace the internal primary
working owner.
This method is for internal use by the jsdt-related plug-ins. Clients outside of the jsdt should not reference this method.
primaryBufferProvider
- the primary buffer providerpublic IBuffer createBuffer(IJavaScriptUnit workingCopy)
null
).
Note: This buffer will be associated to the working copy for its entire life-cycle. Another working copy on same unit but owned by a different owner would not share the same buffer unless its owner decided to implement such a sharing behaviour.
workingCopy
- the working copy of the bufferIBuffer
public IProblemRequestor getProblemRequestor(IJavaScriptUnit workingCopy)
By default, no problem requestor is configured. Clients can override this method to provide a requestor.
workingCopy
- The problem requestor used for the given working copy.null
if no problem requestor is configured.public final IJavaScriptUnit newWorkingCopy(java.lang.String name, IIncludePathEntry[] classpath, IProgressMonitor monitor) throws JavaScriptModelException
This working copy always belongs to the default package in a package fragment root that corresponds to its JavaScript project, and this JavaScript project never exists. However this JavaScript project has the given includepath that is used when resolving names in this working copy.
If a DOM AST is created using this working copy, then given includepath will be used
if bindings need to be resolved. Problems will be reported to the problem requestor
of the current working copy owner problem if it is not null
.
JavaScriptCore.getOptions()
as it is not possible to set the options on a non-existing JavaScript project.
When the working copy instance is created, an added delta
is
reported on this working copy.
Once done with the working copy, users of this method must discard it using
IJavaScriptUnit.discardWorkingCopy()
.
Note that when such working copy is committed, only its buffer is saved (see
IBuffer.save(IProgressMonitor, boolean)
) but no resource is created.
This method is not intended to be overriden by clients.
name
- the name of the working copy (e.g. "X.js")classpath
- the includepath used to resolve names in this working copymonitor
- a progress monitor used to report progress while opening the working copy
or null
if no progress should be reportedJavaScriptModelException
- if the contents of this working copy can
not be determined.IJavaScriptUnit.becomeWorkingCopy(IProgressMonitor)
Copyright (c) IBM Corp. and others 2000, 2016. All Rights Reserved.