Class Projection<L extends Label>
- All Implemented Interfaces:
HasNodeType
DiffNode
as variation node at a specific time.
See the project
function in section 3.1 of
our paper.
This class has to be instantiated using DiffNode.projection(org.variantsync.diffdetective.variation.diff.Time)
.
-
Field Summary
-
Constructor Summary
ConstructorDescriptionProjection
(DiffNode<L> backingNode, Time time) Creates a new projection of aDiffNode
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addChild
(Projection<L> child) The same asVariationNode.insertChild(T,int)
but puts the node at the end of the children list instead of inserting it at a specific index.List<Projection<L>>
Returns an unmodifiable list representing the children of this node.org.prop4j.Node
Returns the formula that is stored in this node.int
getID()
Returns an integer that uniquely identifies this node within its tree.getLabel()
Returns the label of this node.Returns the range of line numbers of this node's corresponding source code.Returns the node type of this node which determines the type of the represented element in the variation tree (e.g., mapping or artifact).Returns the parent of this node, ornull
if this node doesn't have a parent.getTime()
void
insertChild
(Projection<L> child, int index) Adds a child before the given index to the children list of this node and sets its parent to this node.void
Removes all children of this node and sets their parent tonull
.void
removeChild
(Projection<L> child) Removes the given node from this node's children list and sets the parent ofchild
tonull
.void
setLineRange
(LineRange lineRange) Sets the range of line numbers of this node's corresponding source code.upCast()
Returns this instance as the derived class typeT
.Methods inherited from class org.variantsync.diffdetective.variation.tree.VariationNode
addBelow, addChildren, anyMatch, assertConsistency, downCast, drop, forAllPreorder, forMeAndMyAncestors, getChildCount, getDepth, getFeatureMapping, getIfNode, getPresenceCondition, indexOfChild, isChild, isLeaf, isRoot, isSameAs, printSourceCode, removeChildren, shallowIsSameAs, stealChildrenOf, toVariationTree, toVariationTree
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.variantsync.diffdetective.variation.tree.HasNodeType
isAnnotation, isArtifact, isConditionalAnnotation, isElif, isElse, isIf
-
Field Details
-
backingNode
-
time
-
-
Constructor Details
-
Projection
Creates a new projection of aDiffNode
. OnlyDiffNode
is allowed to call this method to guarantee the identity of this class (see above for details). If you want to get the projection of aDiffNode
useDiffNode.projection(org.variantsync.diffdetective.variation.diff.Time)
.- Parameters:
backingNode
- theDiffNode
which should be projectedtime
- which projection this should be
-
-
Method Details
-
getTime
-
getBackingNode
-
upCast
Description copied from class:VariationNode
Returns this instance as the derived class typeT
. The deriving class will only have to returnthis
here but this can't be implemented in the base class. If some derived class can't implement this method by returningthis
, it probably violates the requirements for the type parameterT
(namely that it' the derived class itself).- Specified by:
upCast
in classVariationNode<Projection<L extends Label>,
L extends Label>
-
getNodeType
Description copied from class:VariationNode
Returns the node type of this node which determines the type of the represented element in the variation tree (e.g., mapping or artifact).- Specified by:
getNodeType
in interfaceHasNodeType
- Specified by:
getNodeType
in classVariationNode<Projection<L extends Label>,
L extends Label> - See Also:
-
getLabel
Description copied from class:VariationNode
Returns the label of this node.If
HasNodeType.isArtifact()
istrue
this may represent the source code of this artifact. Otherwise it may represent the preprocessor expression which was parsed to obtainVariationNode.getFormula()
. In either case, this label may be an arbitrary value, selected according to the needs of the user of this class.- Specified by:
getLabel
in classVariationNode<Projection<L extends Label>,
L extends Label>
-
getLineRange
Description copied from class:VariationNode
Returns the range of line numbers of this node's corresponding source code.- Specified by:
getLineRange
in classVariationNode<Projection<L extends Label>,
L extends Label> - See Also:
-
setLineRange
Description copied from class:VariationNode
Sets the range of line numbers of this node's corresponding source code.- Specified by:
setLineRange
in classVariationNode<Projection<L extends Label>,
L extends Label> - See Also:
-
getParent
Description copied from class:VariationNode
Returns the parent of this node, ornull
if this node doesn't have a parent.- Specified by:
getParent
in classVariationNode<Projection<L extends Label>,
L extends Label> - See Also:
-
getChildren
Description copied from class:VariationNode
Returns an unmodifiable list representing the children of this node.The following invariant has to hold for all
node
s:for (var child : node.getChildren()) { Assert.assertTrue(node == child.getParent(node)) }
- Specified by:
getChildren
in classVariationNode<Projection<L extends Label>,
L extends Label> - See Also:
-
addChild
Description copied from class:VariationNode
The same asVariationNode.insertChild(T,int)
but puts the node at the end of the children list instead of inserting it at a specific index.- Specified by:
addChild
in classVariationNode<Projection<L extends Label>,
L extends Label> - See Also:
-
insertChild
Description copied from class:VariationNode
Adds a child before the given index to the children list of this node and sets its parent to this node.When calling
VariationNode.indexOfChild(T)
withchild
the returned index will beindex
as long as the children list isn't modified.- Specified by:
insertChild
in classVariationNode<Projection<L extends Label>,
L extends Label> - See Also:
-
removeChild
Description copied from class:VariationNode
Removes the given node from this node's children list and sets the parent ofchild
tonull
.- Specified by:
removeChild
in classVariationNode<Projection<L extends Label>,
L extends Label> - See Also:
-
removeAllChildren
public void removeAllChildren()Description copied from class:VariationNode
Removes all children of this node and sets their parent tonull
. Afterwards, this node will have no children.- Specified by:
removeAllChildren
in classVariationNode<Projection<L extends Label>,
L extends Label>
-
getFormula
public org.prop4j.Node getFormula()Description copied from class:VariationNode
Returns the formula that is stored in this node. The formula is notnull
formapping nodes with annotations
andnull
otherwise (NodeType.ARTIFACT
,NodeType.ELSE
).If the type parameter
T
of this class is not a concrete variation tree, then the returnedformula
should be treated as unmodifiable to prevent undesired side effects (e.g., toDiffNode
s).- Specified by:
getFormula
in classVariationNode<Projection<L extends Label>,
L extends Label>
-
getID
public int getID()Description copied from class:VariationNode
Returns an integer that uniquely identifies this node within its tree.Some attributes may be recovered from this ID but this depends on the derived class. For example
VariationTreeNode.fromID(int, L)
can recoverVariationNode.getNodeType()
andthe start line number
. Beware thatProjection
returnsDiffNode.getID()
so this id is not fully compatible withVariationTreeNode.getID()
.- Specified by:
getID
in classVariationNode<Projection<L extends Label>,
L extends Label>
-