OptionaldefaultContext: TransformContextOptionaldefaultNodePreVisitor: DefaultNodePreVisitor<Sparql12Nodes>Protected ReadonlydefaultProtecteddefaultProtectedmaxThe number of times transformObjectPreOrder may hand the same position in the tree back to the traversal - by remapping it, or by wrapping it in an array - before we assume the rules do not converge.
ProtectedmaxOptionalnewDefaultContext: TransformContextOptionalnewDefaultNodePreVisitor: DefaultNodePreVisitor<Sparql12Nodes>ProtectedcloneTransform a single node (Typed).
the object from which we will start the transformation, potentially visiting and transforming its descendants along the way.
a dictionary mapping the various node types to objects optionally containing preVisitor and transformer. The preVisitor allows you to provide TransformContext for the current object, altering how it will be transformed. The transformer allows you to manipulate the copy of the current object, and expects you to return the value that should take the current objects place.
the result of transforming the requested descendant operations (based on the preVisitor) using a transformer that works its way back up from the descendant to the startObject.
Transform a single node (Typed) pre-order, the dual of this.transformObjectPreOrder with the same type specification as this.transformNode: a node is transformed before its descendants, and we iterate into the result of that transformation. This is what you want when a node has to travel deeper into the tree: the callback only describes how a node swaps places with the node right below it, the copy it sank into is dispatched in turn, and swaps places with the node below that one.
Contrary to this.transformNode, a callback does not just return the value taking the place of the node, it returns a PreOrderMappingReturn: that value, plus the TransformContext of that value. Since the callback decides what we iterate into, it is the one telling us how to iterate into it, so there is no separate preVisitor - it only completes the per type defaults of this transformer, which are looked up using the type of the node it was called on. A node without a callback is left alone: it keeps those defaults, but is never re-transformed.
Also contrary to this.transformNode, the descendants of the node given to the callback are not transformed yet: they are the nodes of the input tree itself.
the object from which we will start the transformation, potentially visiting and transforming its descendants along the way.
a dictionary mapping the various node types to a mapper. The mapper allows you to manipulate the copy of the current node, and expects you to return the value that should take the current nodes place, together with the context of that value. That context steers how we iterate into the returned value.
the result of transforming the startObject and the descendants of its rewrites.
Transform a single node (Typed). Similar to this.transformNode but also allowing you to target the subTypes.
the object from which we will start the transformation, potentially visiting and transforming its descendants along the way.
a dictionary mapping the various operation types to objects optionally containing preVisitor and transformer. The preVisitor allows you to provide TransformContext for the current object, altering how it will be transformed. The transformer allows you to manipulate the copy of the current object, and expects you to return the value that should take the current objects place.
Same as nodeCallBacks but using an additional level of indirection to indicate the subType.
the result of transforming the requested descendant operations (based on the preVisitor) using a transformer that works its way back up from the descendant to the startObject.
Transform a single node pre-order, the dual of this.transformObjectPreOrder with the same type specification as this.transformNodeSpecific: Similar to TransformerTyped.transformNodePreOrder, but also allowing you to target the subTypes: the node is transformed before its descendants, and we iterate into the result of that transformation, making it the tool of choice for nodes that have to travel deeper into the tree, like a filter pushdown.
Contrary to this.transformNodeSpecific, a callback does not just return the value taking the place of the node, it returns a PreOrderMappingReturn: that value, plus the TransformContext of that value, so there is no separate preVisitor. Also contrary to this.transformNodeSpecific, the descendants of the node given to the callback are not transformed yet: they are the nodes of the input tree itself.
the object from which we will start the transformation, potentially visiting and transforming its descendants along the way.
a dictionary mapping the various node types to a mapper. The mapper allows you to manipulate the copy of the current node, and expects you to return the value that should take the current nodes place, together with the context of that value. That context steers how we iterate into the returned value.
Same as nodeCallBacks but using an additional level of indirection to indicate the subType.
the result of transforming the startObject and the descendants of its rewrites.
Recursively transforms all objects that are not arrays. Mapper is called on deeper objects first.
object to start iterating from
postMapper to transform the various objects - argument is a copy of the original
OptionalpreVisitor: (orig: object) => TransformContextcallback that is evaluated before iterating deeper. If continues is false, we do not iterate deeper, current object is still mapped. - default: true If shortcut is true, we do not iterate deeper, nor do we branch out, this postMapper will be the last one called.
Recursively transforms all objects that are not arrays, calling the preMapper on an object before iterating into its descendants, and iterating into the result of that preMapper. It should be noted that the preMapper is called using a shallow copy of the object. Meaning manipulation of nested objects changes the original!
object to start iterating from
mapper to transform the various objects - first argument is a copy of the original if default setup says to copy. It returns a PreOrderMappingReturn: the value taking the place of the object - the value we iterate into - together with the TransformContext steering that iteration. Since the mapper is the one deciding what the descendants of that value are, it hands us that context itself, there is no separate preVisitor. Whether we copy is therefore not up to the mapper either, the default context of this transformer decides that. The returned value is only handed back to the traversal - and thus mapped again - when the mapper asked for TransformContext.reTransform, in any other case we iterate straight into its descendants. An array is the exception: it is never mapped as a whole, its elements are handed back and mapped in turn. Either way the rules have to settle a position within maxNodeRewrites hand-backs of that position, or we assume they do not converge and throw. A VisitContext.shortcut simply ends the traversal - since an object is already mapped when we iterate into it, there is nothing left to unwind - leaving the objects still on the stack in the place they have in the (shallow) copy of their parent.
Visit a selected subTree given a startObject, steering the visits based on Typed nodes. Will first call the preVisitor on the project and notice it should not iterate on its descendants. It then visits the project, and the outermost distinct, printing '21'. The pre-visitor visits starting from the root, going deeper, while the actual visitor goes in reverse.
the object from which we will start visiting, potentially visiting its descendants along the way.
a dictionary mapping the various operation types to objects optionally containing preVisitor and visitor. The preVisitor allows you to provide VisitContext for the current object, altering how it will be visited. The visitor allows you to visit the object from deepest to the outermost object. This is useful if you for example want to manipulate the objects you visit during your visits, similar to this.transformNode.
Visit a selected subTree given a startObject, steering the visits based on Typed nodes. Similar to this.visitNode, but also allowing you to target subTypes. Will call the preVisitor on the outer distinct, then the visitor of the special distinct, followed by the visiting the outer distinct, printing '231'. The pre-visitor visits starting from the root, going deeper, while the actual visitor goes in reverse.
the object from which we will start visiting, potentially visiting its descendants along the way.
a dictionary mapping the various operation types to objects optionally containing preVisitor and visitor. The preVisitor allows you to provide VisitContext for the current object, altering how it will be visited. The visitor allows you to visit the object from deepest to the outermost object. This is useful if you for example want to manipulate the objects you visit during your visits, similar to mapOperation.
Same as nodeCallBacks but using an additional level of indirection to indicate the subType.
Visitor that visits all objects. Visits deeper objects first.
OptionalpreVisitor: (orig: object) => VisitContext
Most specific AST transformer that dispatches visit and transform callbacks based on both the
typeandsubTypefields of SubTyped nodes.Extends TransformerTyped with an additional dispatch level. When a callback is registered for a specific
(type, subType)pair, it takes precedence over the type-only callback from TransformerTyped.transformNode.This is the recommended transformer for SPARQL ASTs where nodes have both type and subType discriminators (e.g.,
{ type: 'term', subType: 'literal' }).