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).
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionProjection(DiffNode<L> backingNode, Time time) Creates a new projection of aDiffNode. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddChild(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.NodeReturns the formula that is stored in this node.intgetID()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, ornullif this node doesn't have a parent.getTime()voidinsertChild(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.voidRemoves all children of this node and sets their parent tonull.voidremoveChild(Projection<L> child) Removes the given node from this node's children list and sets the parent ofchildtonull.voidsetLineRange(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, toVariationTreeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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. OnlyDiffNodeis allowed to call this method to guarantee the identity of this class (see above for details). If you want to get the projection of aDiffNodeuseDiffNode.projection(org.variantsync.diffdetective.variation.diff.Time).- Parameters:
backingNode- theDiffNodewhich should be projectedtime- which projection this should be
-
-
Method Details
-
getTime
-
getBackingNode
-
upCast
Description copied from class:VariationNodeReturns this instance as the derived class typeT. The deriving class will only have to returnthishere 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:
upCastin classVariationNode<Projection<L extends Label>,L extends Label>
-
getNodeType
Description copied from class:VariationNodeReturns 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:
getNodeTypein interfaceHasNodeType- Specified by:
getNodeTypein classVariationNode<Projection<L extends Label>,L extends Label> - See Also:
-
getLabel
Description copied from class:VariationNodeReturns the label of this node.If
HasNodeType.isArtifact()istruethis 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:
getLabelin classVariationNode<Projection<L extends Label>,L extends Label>
-
getLineRange
Description copied from class:VariationNodeReturns the range of line numbers of this node's corresponding source code.- Specified by:
getLineRangein classVariationNode<Projection<L extends Label>,L extends Label> - See Also:
-
setLineRange
Description copied from class:VariationNodeSets the range of line numbers of this node's corresponding source code.- Specified by:
setLineRangein classVariationNode<Projection<L extends Label>,L extends Label> - See Also:
-
getParent
Description copied from class:VariationNodeReturns the parent of this node, ornullif this node doesn't have a parent.- Specified by:
getParentin classVariationNode<Projection<L extends Label>,L extends Label> - See Also:
-
getChildren
Description copied from class:VariationNodeReturns an unmodifiable list representing the children of this node.The following invariant has to hold for all
nodes:for (var child : node.getChildren()) { Assert.assertTrue(node == child.getParent(node)) }- Specified by:
getChildrenin classVariationNode<Projection<L extends Label>,L extends Label> - See Also:
-
addChild
Description copied from class:VariationNodeThe 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:
addChildin classVariationNode<Projection<L extends Label>,L extends Label> - See Also:
-
insertChild
Description copied from class:VariationNodeAdds 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)withchildthe returned index will beindexas long as the children list isn't modified.- Specified by:
insertChildin classVariationNode<Projection<L extends Label>,L extends Label> - See Also:
-
removeChild
Description copied from class:VariationNodeRemoves the given node from this node's children list and sets the parent ofchildtonull.- Specified by:
removeChildin classVariationNode<Projection<L extends Label>,L extends Label> - See Also:
-
removeAllChildren
public void removeAllChildren()Description copied from class:VariationNodeRemoves all children of this node and sets their parent tonull. Afterwards, this node will have no children.- Specified by:
removeAllChildrenin classVariationNode<Projection<L extends Label>,L extends Label>
-
getFormula
public org.prop4j.Node getFormula()Description copied from class:VariationNodeReturns the formula that is stored in this node. The formula is notnullformapping nodes with annotationsandnullotherwise (NodeType.ARTIFACT,NodeType.ELSE).If the type parameter
Tof this class is not a concrete variation tree, then the returnedformulashould be treated as unmodifiable to prevent undesired side effects (e.g., toDiffNodes).- Specified by:
getFormulain classVariationNode<Projection<L extends Label>,L extends Label>
-
getID
public int getID()Description copied from class:VariationNodeReturns 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 thatProjectionreturnsDiffNode.getID()so this id is not fully compatible withVariationTreeNode.getID().- Specified by:
getIDin classVariationNode<Projection<L extends Label>,L extends Label>
-