Functionality for reading and writing LazyNode structures
504697
protected static LazyNode readFromBuffer(byte[] raw){
		ByteBuffer buf=ByteBuffer.wrap(raw);
		return readFromBuffer(buf);
	}
143726
function readFullTree() {
                        // Return null if the contextTree is not correctly closed
                        if (root !== currentContext) {
                            return null;
                        }

                        function recusiveRead(node) {
                            if (node.children.length === 0) {
                                delete node.children;
                            } else {
                                for (var i=0, max=node.children.length ; i<max ; i++) {
                                    recusiveRead(node.children[i]);
                                }
                            }
                            delete node.parent;
                        }
                        recusiveRead(root);

                        return root;
                    }
913239
def lazy_property(function):
    
    cached_val = []
    def _wrapper(*args):
        try:
            return cached_val[0]
        except IndexError:
            ret_val = function(*args)
            cached_val.append(ret_val)
            return ret_val
    return _wrapper
1159305
private ObjectJS jsonTreeNode(CallTreeNode node, StringifierFactory jsonStringifierFactory) {
		final ObjectJS nodeJS = ObjectJS.create(node, jsonStringifierFactory);
		if (!node.getChildren().isEmpty()) {
			final ArrayJS childNodesJS=new ArrayJS(node.getChildren().size());
			for(CallTreeNode childNode:node.getChildren()) {
				childNodesJS.addElement(jsonTreeNode(childNode, jsonStringifierFactory));
			}
			nodeJS.setAttribute("children", childNodesJS);
		}
		return nodeJS;
	}
1015140
private void visitMemberDeclarator(AstNode node) {

    if (isOverriddenMethod(node)) {
      // assume that ancestor method is documented
      // and do not count as public API
      return;
    }

    AstNode container = node.getFirstAncestor(
      CxxGrammarImpl.templateDeclaration,
      CxxGrammarImpl.classSpecifier);

    AstNode docNode = node;
    List<Token> comments;

    if (container == null || container.getType().equals(CxxGrammarImpl.classSpecifier)) {
      comments = getBlockDocumentation(docNode);
    } else { // template
      do {
        comments = getBlockDocumentation(container);
        if (!comments.isEmpty()) {
          break;
        }
        container = container.getFirstAncestor(CxxGrammarImpl.templateDeclaration);
      } while (container != null);
    }

    // documentation may be inlined
    if (comments.isEmpty()) {
      comments = getDeclaratorInlineComment(node);
    }

    // find the identifier to present to concrete visitors
    String id = null;

    // first look for an operator function id
    AstNode idNode = node.getFirstDescendant(CxxGrammarImpl.operatorFunctionId);

    if (idNode != null) {
      id = getOperatorId(idNode);
    } else {
      // look for a declarator id
      idNode = node.getFirstDescendant(CxxGrammarImpl.declaratorId);

      if (idNode != null) {
        id = idNode.getTokenValue();
      } else {
        // look for an identifier (e.g in bitfield declaration)
        idNode = node.getFirstDescendant(GenericTokenType.IDENTIFIER);

        if (idNode != null) {
          id = idNode.getTokenValue();
        } else {
          LOG.error("Unsupported declarator at {}", node.getTokenLine());
        }
      }
    }

    if (idNode != null && id != null) {
      visitPublicApi(idNode, id, comments);
    }
  }
351805
def _node(handler, single=None, multi=None):
    """"""
    return _AbstractSyntaxTreeNode(handler=handler,
                                   single=(single if single else []),
                                   multi=(multi if multi else []))
704973
private void compilePlanToJSON(List<DumpableNode<?>> nodes, PrintWriter writer) {
		// initialization to assign node ids
		this.nodeIds = new HashMap<DumpableNode<?>, Integer>();
		this.nodeCnt = 0;
		
		// JSON header
		writer.print("{\n\t\"nodes\": [\n\n");

		// Generate JSON for plan
		for (int i = 0; i < nodes.size(); i++) {
			visit(nodes.get(i), writer, i == 0);
		}
		
		// JSON Footer
		writer.println("\n\t]\n}");
	}
905629
private LinkedList<T> computeRecursiveTraversal(T node, NodePath<T> nodePath) {
    try {


      LinkedList<T> imports = new LinkedList<>();
      Set<T> alreadyIncludedImports = new HashSet<>();

      for (T neighbor : this.traversalFunction.apply(node)) {
        nodePath.appendNode(neighbor);
        addSubtraversal(neighbor, imports, alreadyIncludedImports, nodePath);
        nodePath.popTail();
      }

      return imports;
    } catch (ExecutionException ee) {
      throw new RuntimeException(ee);
    }
  }
193058
def dump_tree(node, name=None, initial_indent='', indentation='    ',
              maxline=120, maxmerged=80,
              # Runtime optimization
              iter_node=iter_node, special=ast.AST,
              list=list, isinstance=isinstance, type=type, len=len):
    
    def dump(node, name=None, indent=''):
        level = indent + indentation
        name = name and name + '=' or ''
        values = list(iter_node(node))
        if isinstance(node, list):
            prefix, suffix = '%s[' % name, ']'
        elif values:
            prefix, suffix = '%s%s(' % (name, type(node).__name__), ')'
        elif isinstance(node, special):
            prefix, suffix = name + type(node).__name__, ''
        else:
            return '%s%s' % (name, repr(node))
        node = [dump(a, b, level) for a, b in values if b != 'ctx']
        oneline = '%s%s%s' % (prefix, ', '.join(node), suffix)
        if len(oneline) + len(indent) < maxline:
            return '%s' % oneline
        if node and len(prefix) + len(node[0]) < maxmerged:
            prefix = '%s%s,' % (prefix, node.pop(0))
        node = (',\n%s' % level).join(node).lstrip()
        return '%s\n%s%s%s' % (prefix, level, node, suffix)
    return dump(node, name, initial_indent)
718808
private void formatNodeTo(Formatter f, int level, RadixTreeNode<T> node) {
        for (int i = 0; i < level; i++) {
            f.format(" ");
        }
        f.format("|");
        for (int i = 0; i < level; i++) {
        	f.format("-");
        }

        if (node.isReal() == true)
        	f.format("%s[%s]*%n", node.getKey(),  node.getValue());
        else
        	f.format("%s%n", node.getKey());

        for (RadixTreeNode<T> child : node.getChildern()) {
        	formatNodeTo(f, level + 1, child);
        }		
	}
90651
private LeftJoinNode updateRightNodesAndLJ(LeftJoinNode leftJoinNode,
                                               DataNodeAndSubstitution rightComponent,
                                               Optional<ImmutableExpression> newLJCondition,
                                               Optional<DataNode> proposedRightDataNode,
                                               QueryTreeComponent treeComponent) {
        rightComponent.constructionNode
                .ifPresent(n -> treeComponent.replaceNodeByChild(n, Optional.empty()));
        rightComponent.filterNode
                .ifPresent(n -> treeComponent.replaceNodeByChild(n, Optional.empty()));
        proposedRightDataNode
                .ifPresent(n -> treeComponent.replaceNode(rightComponent.dataNode, n));
        LeftJoinNode newLeftJoinNode = leftJoinNode.changeOptionalFilterCondition(newLJCondition);
        treeComponent.replaceNode(leftJoinNode, newLeftJoinNode);

        return newLeftJoinNode;
    }
1301145
function findNode(firstNode, predicate) {
    let curNode = firstNode;
    while (curNode != null) {
        if (predicate(curNode.value))
            return curNode;
        curNode = curNode.next;
    }
}
582288
function scopedNodes(ast, matching, flat) {
    		if (!flat) flat = ['isScope','isLoop'] ;
        var matches = [];
        treeWalk(ast, function (node, descend, path) {
            if (node === ast) 
                return descend();
            if (matching(node, path)) {
                matches.push([].concat(path));
                return;
            }
            if (flat === true) return ;
            var x = examine(node) ;
            for (var i=0; i<flat.length; i++) 
                if (x[flat[i]]) 
            		   return ;
            descend();
        });
        return matches;
    }
1236206
def visit_FunctionBody(self, node):
        """"""
        for child in node.children:
            return_value = self.visit(child)

            if isinstance(child, ReturnStatement):
                return return_value

            if isinstance(child, (IfStatement, WhileStatement)):
                if return_value is not None:
                    return return_value

        return NoneType()
97033
function lazyBuildObjectTree(priv, formatted) {
  definePropertyGetters(formatted, {
    children: lazy(function() { return priv.fqnMap.getChildrenOf(formatted.fqn); }),
    fields: lazy(function() { return formatted.children.filter(Filter.ofType('property')); }),
    methods: lazy(function() { return formatted.children.filter(Filter.ofType('function')); }),
    parent: lazy(function() { return priv.fqnMap.getParentOf(formatted.fqn); }),
    parentElement: lazy(function() { return priv.fqnMap.get(formatted.idTags['parent-element']); }),
  });
}
643093
function lazyClone() {
      var result = new LazyWrapper(this.__wrapped__);
      result.__actions__ = copyArray(this.__actions__);
      result.__dir__ = this.__dir__;
      result.__filtered__ = this.__filtered__;
      result.__iteratees__ = copyArray(this.__iteratees__);
      result.__takeCount__ = this.__takeCount__;
      result.__views__ = copyArray(this.__views__);
      return result;
    }
892701
def _maintain(self, node):
        
        # requires node and its direct descends to be clean
        l = 2 * node
        r = 2 * node + 1
        assert self.lazyset[node] is None
        assert self.lazyadd[node] == 0
        assert self.lazyset[l] is None
        assert self.lazyadd[l] == 0
        assert self.lazyset[r] is None
        assert self.lazyadd[r] == 0
        self.maxval[node] = max(self.maxval[l], self.maxval[r])
        self.minval[node] = min(self.minval[l], self.minval[r])
        self.sumval[node] = self.sumval[l] + self.sumval[r]