public class SourceElementBody extends Body implements ISourceElementInfo
This implementation is not synchronized. If multiple threads access a source element body concurrently, and at least one of them modifies the body, it must be synchronized externally. Note, however, that the typical usage pattern is that a source element body is not modified after initialization.
Clients can use this class as it stands or subclass it as circumstances warrant.
| Constructor and Description |
|---|
SourceElementBody() |
| Modifier and Type | Method and Description |
|---|---|
void |
findContentChange(Body oldBody,
IElement element,
IElementDeltaBuilder builder)
Finds whether this body has had a content change.
|
<T> T |
get(Property<T> p)
Returns the cached value for the given property, or
null
if no value is set. |
ISourceConstruct[] |
getChildren()
Returns the child elements for this body.
|
TextRange |
getFullRange()
Returns the text range of the whole element, or
null if none. |
TextRange |
getIdentifyingRange()
Returns the text range of the element's identifier, or
null
if none. |
protected java.util.Set<java.lang.String> |
getPropertyNames() |
protected java.lang.Object |
getPropertyValue(java.lang.String propertyName) |
ISnapshot |
getSnapshot()
Returns the source snapshot on which this object is based,
or
null if the element has no associated source code
or if the snapshot is unknown. |
protected boolean |
isPropertyChanged(java.lang.String propertyName,
java.lang.Object newValue,
java.lang.Object oldValue)
Returns whether the given property has changed its value.
|
<T> void |
set(Property<T> p,
T value)
Sets the cached value for the given property.
|
void |
setFullRange(TextRange fullRange)
Sets the text range of the whole element.
|
void |
setIdentifyingRange(TextRange identifyingRange)
Sets the text range of the element's identifier.
|
void |
setSnapshot(ISnapshot snapshot)
Sets the source snapshot on which this object is based.
|
addChild, removeChild, setChildrenpublic ISourceConstruct[] getChildren()
This implementation returns an array of exactly the same runtime type as
the array given in the most recent call to setChildren if that type is assignable to ISourceConstruct[].
getChildren in interface ISourceElementInfogetChildren in class Bodynull).
Clients must not modify the returned array.public <T> T get(Property<T> p)
ISourceElementInfonull
if no value is set.
To find the value to which the given property object is mapped, implementations of this method may use an identity-based lookup, name-based lookup, or anything in-between. Clients need to use unique property instances with unique names for unambiguous identification of a mapping.
Note that the result correlates to a source snapshot (if there is one) and may be inconsistent with the current
source contents.
get in interface ISourceElementInfop - a source element's property (not null)null
if no value is set. Clients must not modify the returned value
even if mutation is technically possible (e.g., for a non-empty array).public ISnapshot getSnapshot()
ISourceElementInfonull if the element has no associated source code
or if the snapshot is unknown.getSnapshot in interface ISourceElementInfonull if the element has no associated source code
or if the snapshot is unknownpublic TextRange getFullRange()
ISourceElementInfonull if none.
Note that the result correlates to a source snapshot (if there is one) and may be inconsistent with the current
source contents.
getFullRange in interface ISourceElementInfonull if nonepublic TextRange getIdentifyingRange()
ISourceElementInfonull
if none.
Note that the result correlates to a source snapshot (if there is one) and may be inconsistent with the current
source contents.
getIdentifyingRange in interface ISourceElementInfonull if nonepublic <T> void set(Property<T> p, T value)
p - a source element's property (not null)value - a value for the given property (may be null)get(Property)public void setSnapshot(ISnapshot snapshot)
snapshot - may be nullgetSnapshot()public void setFullRange(TextRange fullRange)
fullRange - may be nullgetFullRange()public void setIdentifyingRange(TextRange identifyingRange)
identifyingRange - may be nullgetIdentifyingRange()public void findContentChange(Body oldBody, IElement element, IElementDeltaBuilder builder)
Implementations can compare this body and the given old body and,
if there are differences (excepting children), insert an appropriate
change delta (such as F_CONTENT) for the given element into
the delta tree being built. Implementations should not take changes in
children into account.
This implementation inserts a change delta with flags
F_CONTENT and F_FINE_GRAINED if there is
a change in the
value of one of the element's
properties. For a source file, this
implicitly includes a change in its source range or snapshot.
findContentChange in class BodyoldBody - the old version of the body (not null)element - the element this body corresponds to (not null)builder - represents the delta tree being built (not null)protected boolean isPropertyChanged(java.lang.String propertyName,
java.lang.Object newValue,
java.lang.Object oldValue)
This implementation compares the new value and the old value
for equality; arrays are compared with Arrays.equals.
propertyName - the name of the property (not null)newValue - the new value of the property (may be null)oldValue - the old value of the property (may be null)true if the property has changed its value, and
false otherwiseprotected final java.lang.Object getPropertyValue(java.lang.String propertyName)
protected final java.util.Set<java.lang.String> getPropertyNames()
Copyright (c) 2014, 2020 1C-Soft LLC and others. Made available under the Eclipse Public License 2.0