Package de.monticore.utils
Class Link<S extends ASTNode,T extends ASTNode>
java.lang.Object
de.monticore.utils.Link<S,T>
public final class Link<S extends ASTNode,T extends ASTNode>
extends Object
implements Iterable<Link<?,?>>
Represents a link between two ASTNodes.
When writing transformations that translate from one AST to another, it is often cleaner not to translate all information in a single operation. Splitting this translation process however necessitates that sequentially executed translations always operate on the same source and target nodes. For this purpose a Link provides a way for the program to "remember" which source nodes are associated with which target nodes.
Going beyond that, Links also form a tree that mirrors the structure in both ASTs. This is based on the assumption that the overall structure of both source and target AST will also be equivalent.
-
Field Details
-
source
-
target
-
parent
-
childLinks
-
-
Constructor Details
-
Link
-
-
Method Details
-
addChildLink
-
source
- Returns:
- the source node of this Link
-
target
- Returns:
- the target node of this Link
-
parent
- Returns:
- the parent Link of this Link
-
rootLink
- Returns:
- the topmost Link in the tree to which this Link belongs
-
iterator
-
getLinks
public <O extends ASTNode,D extends ASTNode> Set<Link<O,D>> getLinks(Class<O> sourceType, Class<D> targetType) Looks up all Links in the subtree spanned by this Link by type of source and target. You can use super classes like 'ASTNode.class' if you want to filter more loosely.- Parameters:
sourceType- the class of the source nodetargetType- the class of the target node- Returns:
- the set of all Links with the specified source and target types
-