public interface ISourceFileImplSupport extends ISourceElementImplSupport, ISourceFileImplExtension
ISourceFileImplExtension
to minimize the effort required to implement
that interface. Clients may implement ("mix in") this interface directly or
extend SourceFile
.
In general, the members first defined in this interface are not intended to be referenced outside the subtype hierarchy.
If a notification manager is registered in the model context,
this implementation will take advantage of it to send out working copy
notifications. See workingCopyModeChanged_()
and ISourceFileImplSupport.NotifyingReconcileOperation
.
Modifier and Type | Interface and Description |
---|---|
static class |
ISourceFileImplSupport.NotifyingReconcileOperation
Reconciles a working copy and sends out a delta notification
indicating the nature of the change of the working copy since
the last time it was reconciled.
|
static class |
ISourceFileImplSupport.ReconcileOperation
Reconciles a working copy.
|
IElementImplExtension.CloseHint
Modifier and Type | Field and Description |
---|---|
static Property<java.lang.Object> |
SOURCE_AST
Specifies the source AST.
|
static Property<java.lang.String> |
SOURCE_CONTENTS
Specifies the source string.
|
static Property<ISnapshot> |
SOURCE_SNAPSHOT
Specifies the source snapshot.
|
NEW_ELEMENTS, NO_BODY
CLOSE_HINT, FORCE_OPEN
WORKING_COPY_BUFFER, WORKING_COPY_CALLBACK, WORKING_COPY_CONTEXT
Modifier and Type | Method and Description |
---|---|
default boolean |
acquireExistingWorkingCopy_(org.eclipse.core.runtime.IProgressMonitor monitor)
If this source file is already in working copy mode, acquires a new
independent ownership of the working copy by incrementing an internal
counter.
|
default boolean |
becomeWorkingCopy_(IContext context,
org.eclipse.core.runtime.IProgressMonitor monitor)
If this source file is not already in working copy mode, switches it
into a working copy, associates it with a working copy buffer, and
acquires an independent ownership of the working copy (and, hence,
of the working copy buffer).
|
void |
buildSourceStructure_(IContext context,
org.eclipse.core.runtime.IProgressMonitor monitor)
Creates and initializes bodies for this element and for each
of its descendant elements according to options specified in the
given context.
|
default void |
buildStructure_(IContext context,
org.eclipse.core.runtime.IProgressMonitor monitor)
This implementation delegates to
buildSourceStructure_(IContext,
IProgressMonitor) with an appropriately augmented context. |
default void |
close_(IContext context)
Closes this element if, and only if, the current state of this element
permits closing according to options specified in the given context.
|
default boolean |
defaultEquals_(java.lang.Object obj)
A default implementation of
IElement.equals(Object) cannot be provided in
an interface, but clients can implement equals by
delegating to this default method. |
default int |
defaultHashCode_()
A default implementation of
IElement.hashCode() cannot be provided in
an interface, but clients can implement hashCode by
delegating to this default method. |
default boolean |
fileExists_()
Returns whether the underlying file exists.
|
default IBuffer |
getBuffer_(IContext context,
org.eclipse.core.runtime.IProgressMonitor monitor)
Returns a buffer opened for this source file.
|
default IBuffer |
getFileBuffer_(IContext context,
org.eclipse.core.runtime.IProgressMonitor monitor)
Returns a buffer opened for the underlying file of this source file.
|
default ISnapshotProvider |
getFileSnapshotProvider_()
Returns a snapshot provider for the underlying file's stored contents.
|
default ISourceFileImplSupport.ReconcileOperation |
getReconcileOperation_()
Returns a reconcile operation for this source file.
|
default IContext |
getWorkingCopyContext_()
Returns the context associated with the working copy, or
null
if this source file is not a working copy. |
default boolean |
isWorkingCopy_()
Returns whether this source file is a working copy.
|
default boolean |
needsReconciling_()
Returns whether this source file needs reconciling.
|
default IContext |
newWorkingCopyContext_(IContext context)
Returns a context to be associated with a new working copy of this
source file.
|
default void |
openParent_(IContext context,
org.eclipse.core.runtime.IProgressMonitor monitor)
Opens the parent element if necessary.
|
default void |
reconcile_(IContext context,
org.eclipse.core.runtime.IProgressMonitor monitor)
Reconciles this source file.
|
default boolean |
releaseWorkingCopy_()
Relinquishes an independent ownership of the working copy by decrementing
an internal counter.
|
default void |
toStringName_(java.lang.StringBuilder builder,
IContext context) |
default void |
validateExistence_(IContext context)
Validates that this element may be "opened", i.e., begin existence
in the model.
|
default void |
workingCopyModeChanged_()
Informs this source file about a working copy mode change: either
the source file became a working copy or reverted back from the
working copy mode.
|
checkInRange, getSourceElementAt_, getSourceElementAt_, getSourceElementInfo_
canEqual_, exists_, findBody_, getChildrenFromBody_, getElementManager_, getModel_, isOpenable_, newDoesNotExistException_, open_, peekAtBody_, remove_, removing_, toString_, toStringAncestors_, toStringBody_, toStringChildren_
close_, getBody_, getBody_, getChildren_
getModelManager_
getFile_
static final Property<java.lang.Object> SOURCE_AST
static final Property<java.lang.String> SOURCE_CONTENTS
default int defaultHashCode_()
IElementImplSupport
IElement.hashCode()
cannot be provided in
an interface, but clients can implement hashCode
by
delegating to this default method.
By default, the hash code for an element is a combination of hash codes
for its name and its parent element. This method is specialized in ISourceConstructImplSupport
to include the element's occurrence count,
and in ISourceFileImplSupport
to return the hash code for the
underlying IFile
, if there is one. This method is not intended
to be replaced by clients; if necessary, clients should override
hashCode
directly.
defaultHashCode_
in interface IElementImplSupport
default boolean defaultEquals_(java.lang.Object obj)
IElementImplSupport
IElement.equals(Object)
cannot be provided in
an interface, but clients can implement equals
by
delegating to this default method.
By default, two elements that implement this interface are equal if they
are identical or if they can equal
each other
and do have equal names and equal parents. This method is specialized in
ISourceConstructImplSupport
and ISourceFileImplSupport
to also compare occurrence counts and underlying IFile
s
respectively. This method is not intended to be replaced by clients;
if necessary, clients should override equals
directly.
defaultEquals_
in interface IElementImplSupport
obj
- the object with which to comparetrue
if this element is equal to the given object,
and false
otherwisedefault IBuffer getBuffer_(IContext context, org.eclipse.core.runtime.IProgressMonitor monitor) throws org.eclipse.core.runtime.CoreException
The client takes (potentially shared) ownership of the returned buffer and is responsible for releasing it when finished. The buffer will be disposed only after it is released by every owner. The buffer must not be accessed by clients which do not own it.
A new object may be returned, even for the same underlying buffer, each time this method is invoked. For working copies, the relationship between the source file and the underlying working copy buffer does not change over the lifetime of a working copy.
Implementations are encouraged to support the following standard options, which may be specified in the given context:
CREATE_BUFFER
-
Indicates whether a new buffer should be created if none already exists
for this source file.
This implementation delegates to getFileBuffer_(IContext,
IProgressMonitor)
if this source file is not a working copy;
otherwise, it returns the working copy buffer.
getBuffer_
in interface ISourceFileImpl
context
- the operation context (not null
)monitor
- a progress monitor, or null
if progress reporting is not desired. The caller must not rely on
IProgressMonitor.done()
having been called by the receivernull
if CREATE_BUFFER
is false
in the given context
and there is no buffer currently opened for the source fileorg.eclipse.core.runtime.CoreException
- if this source file does not exist or if an
exception occurs while accessing its corresponding resourceorg.eclipse.core.runtime.OperationCanceledException
- if this method is canceleddefault boolean becomeWorkingCopy_(IContext context, org.eclipse.core.runtime.IProgressMonitor monitor) throws org.eclipse.core.runtime.CoreException
ISourceFileImplExtension
In working copy mode, the source file's structure and properties
shall no longer correspond to the underlying resource contents and
must no longer be updated by a resource delta processor. Instead,
the source file's structure and properties can be explicitly reconciled
with the current
contents of the working copy buffer.
This method supports the following options, which may be specified in the given context:
ISourceFileImplExtension.WORKING_COPY_BUFFER
- Specifies the working copy buffer.
If not set, a default buffer for this source file will be used for
the working copy.
ISourceFileImplExtension.WORKING_COPY_CALLBACK
- Specifies the working copy callback.
If set, the given callback must be a new instance: callbacks may not be
shared or reused between working copies.
ISourceFileImplExtension.WORKING_COPY_CONTEXT
- Specifies the working copy context.
If set, the given context will be associated with the working copy and
can be accessed via ISourceFileImplExtension.getWorkingCopyContext_()
method.
If the source file was already in working copy mode, this method acquires a new independent ownership of the working copy by incrementing an internal counter; the given context is ignored.
Each call to this method that did not throw an exception must ultimately
be followed by exactly one call to ISourceFileImplExtension.releaseWorkingCopy_()
.
becomeWorkingCopy_
in interface ISourceFileImplExtension
context
- the operation context (not null
)monitor
- a progress monitor, or null
if progress reporting is not desired. The caller must not rely on
IProgressMonitor.done()
having been called by the receivertrue
if this source file became a working copy,
and false
if it was already in working copy modeorg.eclipse.core.runtime.CoreException
- if the working copy could not be createdISourceFileImplExtension.acquireExistingWorkingCopy_(IProgressMonitor)
default boolean acquireExistingWorkingCopy_(org.eclipse.core.runtime.IProgressMonitor monitor)
ISourceFileImplExtension
false
if this source file is not a working
copy. Performs atomically.
Each successful call to this method that did not return false
must ultimately be followed by exactly one call to ISourceFileImplExtension.releaseWorkingCopy_()
.
acquireExistingWorkingCopy_
in interface ISourceFileImplExtension
monitor
- a progress monitor, or null
if progress reporting is not desired. The caller must not rely on
IProgressMonitor.done()
having been called by the receivertrue
if an existing working copy was acquired,
and false
if this source file is not a working copyISourceFileImplExtension.becomeWorkingCopy_(IContext, IProgressMonitor)
default boolean releaseWorkingCopy_()
ISourceFileImplExtension
Each independent ownership of the working copy must ultimately end with exactly one call to this method. Clients which do not own the working copy must not call this method.
releaseWorkingCopy_
in interface ISourceFileImplExtension
true
if this source file was switched from
working copy mode back to its original mode, and false
otherwisedefault IContext getWorkingCopyContext_()
ISourceFileImplExtension
null
if this source file is not a working copy. The context, as a set of
bindings, and its association with the working copy do not change
over the lifetime of the working copy.
The returned context is composed of the context explicitly specified
when creating the working copy and
an intrinsic context of the working copy itself, in that order.
getWorkingCopyContext_
in interface ISourceFileImplExtension
null
if this source file is not a working copydefault boolean isWorkingCopy_()
ISourceFileImpl
isWorkingCopy_
in interface ISourceFileImpl
true
if this source file is a working copy,
and false
otherwisedefault boolean needsReconciling_()
This implementation delegates to the namesake method of the working copy callback, provided that this source file is a working copy.
needsReconciling_
in interface ISourceFileImpl
true
if this source file needs reconciling,
and false
otherwiseIWorkingCopyCallback.needsReconciling()
default void reconcile_(IContext context, org.eclipse.core.runtime.IProgressMonitor monitor) throws org.eclipse.core.runtime.CoreException
Implementations are encouraged to support the following standard options, which may be specified in the given context:
FORCE_RECONCILING
- Indicates whether reconciling has to be performed
even if the working copy buffer has not been modified since the last time
the working copy was reconciled.
This implementation delegates to the namesake method of the working copy callback, provided that this source file is a working copy.
reconcile_
in interface ISourceFileImpl
context
- the operation context (not null
)monitor
- a progress monitor, or null
if progress reporting is not desired. The caller must not rely on
IProgressMonitor.done()
having been called by the receiverorg.eclipse.core.runtime.CoreException
- if the working copy could not be reconciledorg.eclipse.core.runtime.OperationCanceledException
- if this method is canceledIWorkingCopyCallback.reconcile(IContext, IProgressMonitor)
default ISourceFileImplSupport.ReconcileOperation getReconcileOperation_()
This method is called internally; it is not intended to be invoked by clients.
This implementation returns a new instance of ISourceFileImplSupport.NotifyingReconcileOperation
if there is a notification manager
registered in the model context; otherwise, a new instance of
ISourceFileImplSupport.ReconcileOperation
is returned.
null
)default IContext newWorkingCopyContext_(IContext context)
becomeWorkingCopy_(IContext, IProgressMonitor)
method.
The returned context is composed of the context explicitly specified
when creating
the working copy and an intrinsic context of the working copy itself,
in that order.
This method is called internally; it is not intended to be invoked by clients.
This implementation returns context.getOrDefault(WORKING_COPY_CONTEXT)
.
context
- the operation context (never null
)null
)getWorkingCopyContext_()
default void workingCopyModeChanged_()
This method is called internally; it is not intended to be invoked by clients.
This implementation sends out a delta notification indicating the nature of the working copy mode change, provided that a notification manager is registered in the model context.
INotificationManager
default boolean fileExists_()
This implementation returns getFile_().exists()
if
this source file has an underlying IFile
; otherwise,
it throws an assertion error.
true
if the underlying file exists,
and false
otherwisedefault ISnapshotProvider getFileSnapshotProvider_()
The client takes (potentially shared) ownership of the returned provider and is responsible for releasing it. The provider will be disposed only after it is released by every owner. The provider must not be accessed by clients which do not own it.
This implementation returns a snapshot provider for the stored contents
of the underlying IFile
; it throws an assertion error
if this source file has no underlying file in the workspace.
null
)default IBuffer getFileBuffer_(IContext context, org.eclipse.core.runtime.IProgressMonitor monitor) throws org.eclipse.core.runtime.CoreException
The client takes (potentially shared) ownership of the returned buffer and is responsible for releasing it. The buffer will be disposed only after it is released by every owner. The buffer must not be accessed by clients which do not own it.
A new object may be returned, even for the same underlying buffer, each time this method is invoked.
Implementations are encouraged to support the following standard options, which may be specified in the given context:
CREATE_BUFFER
-
Indicates whether a new buffer should be created if none already exists
for the underlying file.
This implementation returns a buffer opened for the underlying IFile
, or null
if CREATE_BUFFER
is
false
in the given context and there is currently no buffer
opened for that file; it throws an assertion error if this source file
has no underlying file in the workspace.
context
- the operation context (not null
)monitor
- a progress monitor, or null
if progress reporting is not desired. The caller must not rely on
IProgressMonitor.done()
having been called by the receivernull
if CREATE_BUFFER
is false
in the given context and there is currently no buffer opened for that fileorg.eclipse.core.runtime.CoreException
- if the buffer could not be openedorg.eclipse.core.runtime.OperationCanceledException
- if this method is canceleddefault void validateExistence_(IContext context) throws org.eclipse.core.runtime.CoreException
Note that ancestor elements may or may not exist; this method need not explicitly verify their existence.
This implementation does nothing if this source file is a working copy;
otherwise, it throws a IElementImplSupport.newDoesNotExistException_()
if the
underlying file does not exist
.
validateExistence_
in interface IElementImplSupport
context
- the operation context (not null
)org.eclipse.core.runtime.CoreException
- if this element shall not existIElementImplSupport.newDoesNotExistException_()
default void openParent_(IContext context, org.eclipse.core.runtime.IProgressMonitor monitor) throws org.eclipse.core.runtime.CoreException
This method is called internally; it is not intended to be invoked by clients.
This implementation does nothing if this source file is a working copy;
otherwise, it attempts to open
the parent element if it supports IElementImplExtension
and
is not already open.
openParent_
in interface IElementImplSupport
context
- the operation context (never null
)monitor
- a progress monitor (never null
).
The caller must not rely on IProgressMonitor.done()
having been called by the receiverorg.eclipse.core.runtime.CoreException
- if an exception occurs while opening this element's
parentorg.eclipse.core.runtime.OperationCanceledException
- if this method is canceledIElementImplSupport.open_(IContext, IProgressMonitor)
default void buildStructure_(IContext context, org.eclipse.core.runtime.IProgressMonitor monitor) throws org.eclipse.core.runtime.CoreException
buildSourceStructure_(IContext,
IProgressMonitor)
with an appropriately augmented context. In particular,
if the given context contains neither SOURCE_CONTENTS
nor SOURCE_AST
, it is augmented with SOURCE_CONTENTS
and the
corresponding SOURCE_SNAPSHOT
obtained from the underlying
file's stored contents
. Also,
performs some post-processing of created SourceElementBody
s
to complete their initialization, such as setting the source snapshot
on which they are based.buildStructure_
in interface IElementImplSupport
context
- the operation context (not null
)monitor
- a progress monitor (not null
).
The caller must not rely on IProgressMonitor.done()
having been called by the receiverorg.eclipse.core.runtime.CoreException
- if the structure could not be determinedorg.eclipse.core.runtime.OperationCanceledException
- if this method is canceledvoid buildSourceStructure_(IContext context, org.eclipse.core.runtime.IProgressMonitor monitor) throws org.eclipse.core.runtime.CoreException
IElementImplSupport.NEW_ELEMENTS
map in the given context
to associate the created bodies with their respective elements.
The following context options, if simultaneously present, must be mutually consistent:
SOURCE_AST
- Specifies the AST to use when building the structure.
The AST is safe to read in the dynamic context of this method call, but
must not be modified.
SOURCE_CONTENTS
- Specifies the source string to use when
building the structure.
At least one of SOURCE_AST
or SOURCE_CONTENTS
must have a non-null value in the given context.
The given context may provide additional data that this method can use, including the following:
SOURCE_SNAPSHOT
- Specifies the source snapshot from which
SOURCE_AST
was created or SOURCE_CONTENTS
was obtained. The snapshot may expire.
context
- the operation context (not null
)monitor
- a progress monitor (not null
).
The caller must not rely on IProgressMonitor.done()
having been called by the receiverorg.eclipse.core.runtime.CoreException
- if the structure could not be determinedorg.eclipse.core.runtime.OperationCanceledException
- if this method is canceleddefault void close_(IContext context)
Closing of an element removes its body from the body cache. In general, closing of a parent element also closes its children. If the current state of an open child element does not permit closing, the child element remains open, which generally does not prevent its parent from closing. Closing of an element which is not open has no effect.
Implementations are encouraged to support the following standard options, which may be specified in the given context:
IElementImplExtension.CLOSE_HINT
- Closing hint.
After checking that the current state of this element permits closing,
this implementation invokes IElementImplSupport.remove_(IContext)
to actually
close this element.
Note that a working copy is never permitted to close.
close_
in interface IElementImplExtension
close_
in interface IElementImplSupport
context
- the operation context (not null
)default void toStringName_(java.lang.StringBuilder builder, IContext context)
toStringName_
in interface IElementImplSupport
Copyright (c) 2014, 2019 1C-Soft LLC and others. Made available under the Eclipse Public License 2.0