Class SourceElementBody
- All Implemented Interfaces:
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidfindContentChange(Body oldBody, IElement element, IElementDeltaBuilder builder) Finds whether this body has had a content change.<T> TReturns the cached value for the given property, ornullif no value is set.Returns the child elements for this body.Returns the text range of the whole element, ornullif none.Returns the text range of the element's identifier, ornullif none.protected final ObjectgetPropertyValue(String propertyName) Returns the source snapshot on which this object is based, ornullif the element has no associated source code or if the snapshot is unknown.protected booleanisPropertyChanged(String propertyName, Object newValue, Object oldValue) Returns whether the given property has changed its value.<T> voidSets the cached value for the given property.voidsetFullRange(TextRange fullRange) Sets the text range of the whole element.voidsetIdentifyingRange(TextRange identifyingRange) Sets the text range of the element's identifier.voidsetSnapshot(ISnapshot snapshot) Sets the source snapshot on which this object is based.Methods inherited from class org.eclipse.handly.model.impl.support.Body
addChild, removeChild, setChildren
-
Constructor Details
-
SourceElementBody
public SourceElementBody()
-
-
Method Details
-
getChildren
Returns the child elements for this body.This implementation returns an array of exactly the same runtime type as the array given in the most recent call to
setChildrenif that type is assignable toISourceConstruct[].- Specified by:
getChildrenin interfaceISourceElementInfo- Overrides:
getChildrenin classBody- Returns:
- the child elements for this body (never
null). Clients must not modify the returned array.
-
get
Description copied from interface:ISourceElementInfoReturns the cached value for the given property, ornullif 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.- Specified by:
getin interfaceISourceElementInfo- Parameters:
p- a source element's property (notnull)- Returns:
- the cached value for the given property, or
nullif no value is set. Clients must not modify the returned value even if mutation is technically possible (e.g., for a non-empty array).
-
getSnapshot
Description copied from interface:ISourceElementInfoReturns the source snapshot on which this object is based, ornullif the element has no associated source code or if the snapshot is unknown.- Specified by:
getSnapshotin interfaceISourceElementInfo- Returns:
- the source snapshot on which this object is based,
or
nullif the element has no associated source code or if the snapshot is unknown
-
getFullRange
Description copied from interface:ISourceElementInfoReturns the text range of the whole element, ornullif none.Note that the result correlates to a source
snapshot(if there is one) and may be inconsistent with the current source contents.- Specified by:
getFullRangein interfaceISourceElementInfo- Returns:
- the text range associated with the whole element,
or
nullif none
-
getIdentifyingRange
Description copied from interface:ISourceElementInfoReturns the text range of the element's identifier, ornullif none.Note that the result correlates to a source
snapshot(if there is one) and may be inconsistent with the current source contents.- Specified by:
getIdentifyingRangein interfaceISourceElementInfo- Returns:
- the text range associated with the element's identifier,
or
nullif none
-
set
Sets the cached value for the given property.- Parameters:
p- a source element's property (notnull)value- a value for the given property (may benull)- See Also:
-
setSnapshot
Sets the source snapshot on which this object is based.- Parameters:
snapshot- may benull- See Also:
-
setFullRange
Sets the text range of the whole element.- Parameters:
fullRange- may benull- See Also:
-
setIdentifyingRange
Sets the text range of the element's identifier.- Parameters:
identifyingRange- may benull- See Also:
-
findContentChange
Finds whether this body has had a content change.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_CONTENTandF_FINE_GRAINEDif there is achangein thevalueof one of the element'sproperties. For a source file, this implicitly includes a change in its sourcerangeorsnapshot.- Overrides:
findContentChangein classBody- Parameters:
oldBody- the old version of the body (notnull)element- the element this body corresponds to (notnull)builder- represents the delta tree being built (notnull)
-
isPropertyChanged
Returns whether the given property has changed its value.This implementation compares the new value and the old value for equality; arrays are compared with
Arrays.equals.- Parameters:
propertyName- the name of the property (notnull)newValue- the new value of the property (may benull)oldValue- the old value of the property (may benull)- Returns:
trueif the property has changed its value, andfalseotherwise
-
getPropertyValue
-
getPropertyNames
-