DefaultDocumentElement
ISourceElement
, IStructureFeature.IStructureNode
A default implementation of ISourceElement
.
Object
DefaultElement
DefaultTreeElement
DefaultDocumentElement
DefaultSourceElement
IDocumentElement
, IElement
, ISourceElement
, IStructureFeature.IStructureNode
, ITreeElement
InvalidElement
, JavaElement
, XmlDocumentRoot
, XmlNode
Nested Class Summary |
protected class | DefaultSourceElement.CompilerPropertyDescriptor
A CompilerPropertyDescriptor object describes a property that is found on a given source element type. |
protected class | DefaultSourceElement.DefaultAuthorElement
DefaultAuthorElement are returned from createAuthorNode as part of the two-way editing
process. |
protected static class | DefaultSourceElement.StaticCompilerPropertyDescriptor
For performance, a class that can be passed to CompilerPropertyDescriptor's constructor to save the overhead of finding the getter and setter methods. |
protected class | DefaultSourceElement.StickyRange
A StickyRange is a Range object whose start and end offsets
track modifications to the source document. |
Field Summary |
protected |
|
public static final |
|
public static final |
|
Fields from com.bea.ide.element. |
|
Fields from interface com.bea.ide.sourceeditor.element. |
|
Constructor Summary |
|
Method Summary |
public void |
|
public |
|
public void |
|
public boolean | |
public |
|
public |
|
public final |
|
protected abstract |
|
public |
|
public |
|
public |
|
public |
|
public |
|
public final |
|
protected |
|
protected |
|
protected |
|
public |
|
public |
|
public |
|
protected |
|
public int |
|
public abstract |
|
public void |
|
protected void |
|
public void |
|
protected boolean |
|
public void |
|
public boolean |
|
public void |
|
public void |
|
public |
|
public void |
|
public |
|
public |
|
public |
|
public void |
|
public void |
|
public void |
|
protected void |
|
Methods from com.bea.ide.document. |
|
Methods from com.bea.ide.element. |
|
Methods from class java.lang. |
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods from interface com.bea.ide.document. |
|
Methods from interface com.bea.ide.element. |
|
Methods from interface com.bea.ide.sourceeditor.element. |
|
Methods from interface com.bea.compiler.feature. |
getCookie, getTypeCode |
Methods from interface com.bea.ide.element. |
|
Field Detail |
protected DefaultSourceElement.StickyRange
_range
initializeRange
has been called, so it is generally best to get range information by calling getRange
, unless
direct access to this member variable is required.
public static final String
PROP_NAME
public static final String
PROP_VALUE
Constructor Detail |
public DefaultSourceElement(Object
structureNodeCookie)
Method Detail |
public void addChild(ITreeElement
child)
Adds a child to this element. This method may only be called on elements that are not part of a parse tree.
Once an element is part of a parse tree, DefaultSourceElement.requestAddChild(ISourceElement)
must be used instead.
DefaultDocumentElement.addChild(ITreeElement)
public IStructureFeature.IAuthorNode
createAuthorNode()
Description copied from ISourceElement.createAuthorNode()
Related Topics
ISourceElement.createAuthorNode()
public void debugDump(StringBuffer
buf,
int depth)
A simple means of viewing the document's parse tree for debugging purposes.
public boolean equals(Object
o)
Compares two elements with each other. Two elements are only equal if they are of the same type and if all
of their properties are equal. If both elements are part of a compiler-produced parse trees,
their documents and document ranges are compared as well.
Object.equals(Object)
publicAllows for quick retrieval of all children of a given type.List
getChildrenByClass(Class
type)
public ClassLoader
getClassLoader()
Utility method to return the current application classloader.
public final Object
getCookie()
Description copied from ISourceElement.getCookie()
protected abstract DefaultSourceElement.CompilerPropertyDescriptor
[] getDefaultPropertyDescriptors()
DefaultSourceElement subclasses define their set of available CompilerPropertyDescriptor objects by implementing
this method.
public List
getDiagnostics()
Returns a list of all diagnostics that overlap or are contained by the range of this element. This method can
only be used to determine if any diagnostics will be visible within this element in source view. This method
cannot determine if the cause of a diagnostic (a code error, for example) lies within a particular source
element.
public ISourceElementGroup
getGroup()
By default, elements are not grouped together (other than by parentage).
To be groupable, a class must override this method.
public String
getInstanceName()
Returns the name property for this element, if such a property exists.
publicGets a property from this source element.Object
getProperty(String
sProp)
DefaultElement.getProperty(String)
publicReturns a code used by the compiler to identify property types.IStructureFeature.StructureCode
getPropertyCode(String
propertyName)
DefaultSourceElement.CompilerPropertyDescriptor
public final PropertyDescriptor
[] getPropertyDescriptors()
This method returns this element's set of property descriptors. DefaultSourceElements do not provide their
properties directly via this method. This functionality is handled by the getDefaultPropertyDescriptors
method.
DefaultElement.getPropertyDescriptors()
protectedReturns the source range that is occupied by an element property. If a property occupies more than one disjoint range, the first range will be returned. For example, take the following variable declaration:DefaultSourceElement.StickyRange
getPropertySourceRange(IStructureFeature.StructureCode
prop)
int a[];
If we assume that this declaration starts at offset 100, the range of the type property occupies [100, 103) and
[105, 107). This method would return the StickyRange corresponding to [100, 103) only. If the both ranges are
needed, call DefaultSourceElement.getPropertySourceRanges(IStructureFeature.StructureCode)
.
protectedReturns nn array of source ranges occupied by an element property. This array almost always contains just one entry. However, in some circumstances, two or more entries are possible. For example, take the following variable declaration:DefaultSourceElement.StickyRange
[] getPropertySourceRanges(IStructureFeature.StructureCode
prop)
int a[];
If we assume that this declaration starts at offset 100, the range of the type property occupies [100, 103) and [105, 107). This method would return the an array that contains both ranges.
protectedGets the source text for a particular property. For example, the return type property of a JavaMethod will always be fully qualified- to determine the return type type as it appears in source, this method must be used.String
getPropertySourceText(IStructureFeature.StructureCode
prop)
publicGets the source text for a particular property. For example, the return type property of a JavaMethod will always be fully qualified- to determine the return type type as it appears in source, this method must be used.String
getPropertySourceText(String
sProp)
publicGets the range of this source element. This method may only be called on methods that are part of a valid parse tree. For example, callingRange
getRange(ISourceDocument
doc)
(new JavaMethod()).getRange()
will fail with an
UnsupportedOperationException.
public Range
getRange()
Gets the range of this source element. This method may only be called on methods that are part of a valid
parse tree. For example, calling (new JavaMethod()).getRange()
will fail with an
UnsupportedOperationException.
protected Set
getRangePrefetchProperties()
Returns a Set of IStructureFeature.StructureCode objects. This set defines those properties that will
contain range information in the parse tree.
public int getStatus()Gets the tree status of this element.
ISourceElement
status constants.
public abstract IStructureFeature.StructureCode
getTypeCode()
This method returns a code used by the compiler to identify the type of this element.
This method should not be called directly, since the return value isn't useful outside
of the compiler.
public void initializeRange(ISourceDocument
doc)
Initializes the range of this element. Called as part of construction of a new parse tree, before the tree
has been associated with a document. This method is public for implementation purposes only, and should not
be called externally. Call DefaultSourceElement.getRange(ISourceDocument)
to get the range of an element.
protected void initializeRange(Converts compiler provided range information into source model sticky positions. This method assumes it is run on the AWT thread.IStructureFeature
structureFeature,ISourceModel
model)
public void insertChild(int index,
ISourceElement
newChild)
Adds a child to this element. This method may only be called on elements that are not part of a parse tree.
Once an element is part of a parse tree, ISourceElement.requestAddChild(ISourceElement, int)
must be
used instead.
protected boolean isAuthorProperty(DefaultSourceElement.CompilerPropertyDescriptor
pd)
Allows a DefaultSourceElement derivation to specify that certain
properties should not be passed to the compiler when performing
a two way edit.
public void markRemovedFromTree()Mark this element as removed from the parse tree. This will cascade down through all of this element's children.
public boolean mergeElements(ISourceElement
sourceElement)
Called when a new parse tree has been made available by the compiler to merge the new data into the existing
tree generating appropriate change events. This method is public for implementation reasons, and should not
generally be called directly.
The merge algorithm is recursive, descending down through the element tree starting from the root. Each element first checks its properties (in the case of a method, these would be name, return type, access specification, etc.) against the element to which it is being compared. Property change notifications are sent if any properties differ. The element is then responsible for determining if the child sets of the old and new elements differ. This is done by first comparing the left-most child in each child in each list. If they are the same, we move one child to the right in each list, and repeat the comparison. This continues until we find a child pair that is not equal, or run out of children to compare. If we run out of children, we know the child lists are the same, and we move on, recursing down into each. If an inequality was found, we store the location of the inequality and start comparisons again, this time from the right side of the lists, working our way left. In this way, we end up with an interval (the “gap�) in each list where we know changes have occurred.
For example, lets say that the old list contained three elements, A, B, and C, and that the new list contained two elements, A and C. Starting from the left, we see that the elements in the first position are equal (A and A), but the elements in the second position of each list are not (B and C). From the right, we see that the elements in the last position are the same (C and C), but the elements in the second-to-last position are not (B and A). We now have two gaps, on in each list, between known list equalities. The gap in the old list is between items 1 and 3, since items 1 and 3 both had matches in the other list. The gap in the new list is empty, since every item was matched up. A non-empty gap in the old list and an empty gap in the new list indicates the removal of all elements in the gap, so element-removed notifications are sent for the missing elements. Likewise, an empty gap in the old list and a non-empty gap in the new list indicates that elements were inserted, and non-empty gaps in both lists indicate to changes to single children, or combinations of replacements and removals, as can occur when pasting one block of code over another.
This algorithm is very fast (linear time for number of elements in the tree), and works because we can safely make the assumption that code changes tend to be contiguous. The algorithm falls apart in the case where there are simultaneous insertions at the top and bottom of the file, for example, since the gaps would then span the entirety of both lists. In practice, this occurs extremely rarely.
public void mergeFrom(ISourceElement
sourceElement)
Description copied from ISourceElement.mergeFrom(ISourceElement)
this.equals(sourceElement)
will return true while this ==
sourceElement
will return false. Note that this method has no effect on the children of the source or
destination elements: it only applies to element properties.
Related Topics
ISourceElement.mergeFrom(ISourceElement)
public void propertyModified(Utility method used to initiate an element change events. This method is public for implmentation reasons, and should not be called directly.String
sProperty,Object
oldValue,Object
newValue)
public ISourceElement
removeChild(int index)
Removes a child from this element. This method may only be called on elements that are not part of a parse tree.
Once an element is part of a parse tree, DefaultSourceElement.requestRemoveChild(ISourceElement)
must be used instead.
public void removeChild(ITreeElement
child)
Removes a child from this element. This method may only be called on elements that are not part of a parse tree.
Once an element is part of a parse tree, DefaultSourceElement.requestRemoveChild(ISourceElement)
must be used instead.
DefaultTreeElement.removeChild(ITreeElement)
publicReplaces a child of this element. This method may only be called on elements that are not part of a parse tree. Once an element is part of a parse tree,ISourceElement
replaceChild(int index,ISourceElement
replacement)
DefaultSourceElement.requestRemoveChild(ISourceElement)
and DefaultSourceElement.requestAddChild(ISourceElement)
must be used.
instead.
publicDescription copied fromISourceElement
requestAddChild(ISourceElement
newChild)
throwsInvalidElementException
ISourceElement.requestAddChild(ISourceElement)
newChild
itself will NOT be added
to the parse tree, though an element equivalent to it will appear after the edit completes. Source code
corresponding to this element will be inserted into the source document. InvalidElementException
Related Topics
ISourceElement.requestAddChild(ISourceElement)
publicDescription copied fromISourceElement
requestAddChild(ISourceElement
newChild, int index)
throwsInvalidElementException
ISourceElement.requestAddChild(ISourceElement, int)
newChild
itself will NOT be added
to the parse tree, though an element equivalent to it will appear after the edit completes. Source code
corresponding to this element will be inserted into the source document. InvalidElementException
Related Topics
ISourceElement.requestAddChild(ISourceElement, int)
public void requestRemoveChild(Description copied fromISourceElement
child)
throwsInvalidElementException
ISourceElement.requestRemoveChild(ISourceElement)
InvalidElementException
Related Topics
ISourceElement.requestRemoveChild(ISourceElement)
public void requestSetProperty(Description copied fromString
strProp,Object
value)
throwsInvalidElementException
ISourceElement.requestSetProperty(String, Object)
InvalidElementException
Related Topics
ISourceElement.requestSetProperty(String, Object)
public void setProperty(Sets a property on this element, firing property change events as appropriate. This method may only be called on elements that are not part of a parse tree. Once an element is part of a parse tree,String
sProp,Object
value)
ISourceElement.requestSetProperty(String, Object)
must be used instead.
DefaultElement.setProperty(String, Object)
protected void setStatus(int status)Set the status of this element. Note that setting the status to
ISourceElement.STATUS_REMOVED_FROM_TREE
will additionally cascade down through this element's children.