public interface IElement
Base interface for all elements of an Abstract Syntax Tree.
Every AST element implements this interface, either via:
NonStatement
abstract class. Examples: Method
, Constant
, StaticField
, etc.Statement
abstract class. Examples: Assignment
, Continue
, WhileStm
, etc.Since version 1.5.201404100, AST elements can be annotated.
Modifier and Type | Method and Description |
---|---|
void |
attachTag(java.lang.String name,
java.lang.Object data)
Attach a tag to that element.
|
java.util.List<IElement> |
getSubElements()
Get the list of elements contained within this element.
|
boolean |
replaceSubElement(IElement old_elt,
IElement new_elt)
Replace an element by another element.
|
java.lang.Object |
retrieveTag(java.lang.String name)
Retrieve tag data by name.
|
java.util.List<IElement> getSubElements()
Get the list of elements contained within this element.
Example: a Method contains a list of Definition to represent the method parameters, as well as a Block element to represent the method's body.
boolean replaceSubElement(IElement old_elt, IElement new_elt)
Replace an element by another element. Be careful when using this method: no semantic checks are performed on the new and old elements, and the the AST can be corrupted.
old_elt
- the element to be replacednew_elt
- the new elementvoid attachTag(java.lang.String name, java.lang.Object data)
Attach a tag to that element.
name
- the optional tag name (can be null to denote the nameless tag)data
- the mandatory tag datajava.lang.Object retrieveTag(java.lang.String name)
Retrieve tag data by name.
name
- the tag name (can be null to retrieve the nameless tag)