Generates an AST fragment that looks like: {if $csp_nonce} nonce="{$csp_nonce}"{/if}

@param insertionLocation The location where it is being inserted
@param nodeIdGen The id generator to use
336024
private static IfNode createCspInjection(
      SourceLocation insertionLocation, IdGenerator nodeIdGen, TemplateParam defn) {
    IfNode ifNode = new IfNode(nodeIdGen.genId(), insertionLocation);
    IfCondNode ifCondNode =
        new IfCondNode(
            nodeIdGen.genId(), insertionLocation, "if", referenceCspNonce(insertionLocation, defn));
    ifNode.addChild(ifCondNode);
    HtmlAttributeNode nonceAttribute =
        new HtmlAttributeNode(
            nodeIdGen.genId(), insertionLocation, insertionLocation.getBeginPoint());
    ifCondNode.addChild(nonceAttribute);
    nonceAttribute.addChild(new RawTextNode(nodeIdGen.genId(), "nonce", insertionLocation));
    HtmlAttributeValueNode attributeValue =
        new HtmlAttributeValueNode(
            nodeIdGen.genId(), insertionLocation, HtmlAttributeValueNode.Quotes.DOUBLE);
    nonceAttribute.addChild(attributeValue);
    // NOTE: we do not need to insert any print directives here, unlike the old implementation since
    // we are running before the autoescaper, so the escaper should insert whatever print directives
    // are appropriate.
    PrintNode printNode =
        new PrintNode(
            nodeIdGen.genId(),
            insertionLocation,
            /* isImplicit= */ true, // Implicit.  {$csp_nonce} not {print $csp_nonce}
            referenceCspNonce(insertionLocation, defn),
            /* attributes= */ ImmutableList.of(),
            ErrorReporter.exploding());
    attributeValue.addChild(printNode);
    return ifNode;
  }
184871
private static Node getXmlSignatureInsertLocation(final Element elem) {
        val nodeListExtensions = elem.getElementsByTagNameNS(SAMLConstants.SAML20P_NS, "Extensions");
        if (nodeListExtensions.getLength() != 0) {
            return nodeListExtensions.item(nodeListExtensions.getLength() - 1);
        }
        val nodeListStatus = elem.getElementsByTagNameNS(SAMLConstants.SAML20P_NS, "Status");
        return nodeListStatus.item(nodeListStatus.getLength() - 1);
    }
431470
void findInsertPointInLeft(
    Object           new1,
    NodeInsertPoint  point)
  {
    int endp = endPoint();
    findIndex(0, endp, new1, point);
  }
1066852
private static void buildNodeName(Node node, StringBuffer buffer) {
        if (node.getParentNode() == null) {
            return;
        }

        buildNodeName(node.getParentNode(), buffer);

        if (node.getParentNode() != null
                && node.getParentNode().getParentNode() != null) {
            buffer.append(".");
        }

        buffer.append(node.getLocalName());
    }
1208920
private SourcePosition getNamePosition(Tree node) {
    int start = (int) sourcePositions.getStartPosition(unit, node);
    if (start == -1) {
      return SourcePosition.NO_POSITION;
    }
    String src = newUnit.getSource();
    Kind kind = node.getKind();
    if (kind == Kind.ANNOTATION_TYPE
        || kind == Kind.CLASS
        || kind == Kind.ENUM
        || kind == Kind.INTERFACE) {
      // Skip the class/enum/interface token.
      while (src.charAt(start++) != ' ') {}
    } else if (kind != Kind.METHOD && kind != Kind.VARIABLE) {
      return getPosition(node);
    }
    if (!Character.isJavaIdentifierStart(src.charAt(start))) {
      return getPosition(node);
    }
    int endPos = start + 1;
    while (Character.isJavaIdentifierPart(src.charAt(endPos))) {
      endPos++;
    }
    return getSourcePosition(start, endPos);
  }
257440
public void insert(E entry, boolean withPreInsert) {
    final Logging log = getLogger();
    if(log.isDebugging()) {
      log.debugFine("insert " + entry.getRoutingObjectID());
    }

    if(!initialized) {
      initialize(entry);
    }

    // choose subtree for insertion
    IndexTreePath<E> subtree = settings.insertStrategy.choosePath(this, entry);
    if(log.isDebugging()) {
      log.debugFine("insertion-subtree " + subtree);
    }

    // determine parent distance
    E parentEntry = subtree.getEntry();
    entry.setParentDistance(distance(parentEntry.getRoutingObjectID(), entry.getRoutingObjectID()));

    // create leaf entry and do pre insert
    if(withPreInsert) {
      preInsert(entry);
    }

    // get parent node
    N parent = getNode(parentEntry);
    parent.addLeafEntry(entry);
    writeNode(parent);

    // adjust the tree from subtree to root
    adjustTree(subtree);

    // test
    if(EXTRA_INTEGRITY_CHECKS) {
      getRoot().integrityCheck(this, getRootEntry());
    }
  }
1230065
@Override
  protected void visitVeLogNode(VeLogNode node) {
    // VeLogValidationPass enforces that the first child is either an open tag, or a placeholder for
    // an open tag. So this will be non-null at this point.
    HtmlOpenTagNode tag = node.getOpenTagNode();
    SourceLocation insertionLocation =
        tag.getSourceLocation()
            .getEndPoint()
            .offset(0, tag.isSelfClosing() ? -2 : -1)
            .asLocation(tag.getSourceLocation().getFilePath());
    FunctionNode funcNode =
        new FunctionNode(
            Identifier.create(VeLogFunction.NAME, insertionLocation),
            VeLogFunction.INSTANCE,
            insertionLocation);
    funcNode.addChild(node.getVeDataExpression().copy(new CopyState()));
    if (node.getLogonlyExpression() != null) {
      funcNode.addChild(node.getLogonlyExpression().copy(new CopyState()));
    }
    PrintNode attributeNode =
        new PrintNode(
            nodeIdGen.genId(),
            insertionLocation,
            /* isImplicit= */ true,
            /* expr= */ funcNode,
            /* attributes= */ ImmutableList.of(),
            ErrorReporter.exploding());
    tag.addChild(attributeNode);
    visitChildrenAllowingConcurrentModification(node);
  }
137089
private void visitGetprop(NodeTraversal t, Node n) {
    Node receiverNode = n.getFirstChild();
    String propName = receiverNode.getNext().getString();
    if (isGlobalSymbol(t, receiverNode)) {
      compiler.ensureLibraryInjected("es6/symbol", false);
      Node statement = NodeUtil.getEnclosingStatement(n);
      switch (propName) {
        case "iterator":
          {
            Node init =
                IR.exprResult(IR.call(NodeUtil.newQName(compiler, "$jscomp.initSymbolIterator")))
                    .useSourceInfoFromForTree(statement);
            statement.getParent().addChildBefore(init, statement);
            compiler.reportChangeToEnclosingScope(init);
            break;
          }
        case "asyncIterator":
          {
            Node init =
                IR.exprResult(
                        IR.call(NodeUtil.newQName(compiler, "$jscomp.initSymbolAsyncIterator")))
                    .useSourceInfoFromForTree(statement);
            statement.getParent().addChildBefore(init, statement);
            compiler.reportChangeToEnclosingScope(init);
            break;
          }
        default:
          // TODO(bradfordcsmith): Should we warn for unrecognized symbol names?
          break;
      }
    }
  }
259207
<E> Node generate(E entity, PersistenceDelegator delegator, PersistenceCache pc, NodeState state)
    {

        EntityMetadata entityMetadata = KunderaMetadataManager.getEntityMetadata(delegator.getKunderaMetadata(),
                entity.getClass());

        if (!new NullOrInvalidEntityRule<E>(entityMetadata).validate(entity))
        {
            Object entityId = onPreChecks(entity, delegator);

            // TODO::check for composite key.
            Node node = builder.buildNode(entity, delegator, entityId, state);

            node = traverseNode(entity, delegator, pc, entityId, node);

            return node;
        }

        return null;
    }
845709
public void insertAsNext(BasicDoubleLinkedNode<V> node) {

    BasicDoubleLinkedNode<V> next = getNext();
    if (next != null) {
      next.previous = node;
      node.setNext(next);
    }
    node.previous = this;
    setNext(node);
  }
168405
public void insert(String str, int lineno, int colno) {
		final String sourceMethod = "insert"; //$NON-NLS-1$
		if (isTraceLogging) {
			log.entering(JSSource.class.getName(), sourceMethod, new Object[]{str, lineno, colno});
		}
		PositionLocator locator = new PositionLocator(lineno, colno);
		locator.insert(str);
		if (isTraceLogging) {
			log.exiting(JSSource.class.getName(), sourceMethod, "String \"" + str + "\" inserted at " + mid + "(" + lineno + "," + colno + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
		}
	}
1018705
@Override protected void visitIfNode(IfNode node) {

    // Create another instance of this visitor class for generating JS expressions from children.
    GenJsExprsVisitor genJsExprsVisitor =
        genJsExprsVisitorFactory.create(translationContext, templateAliases, errorReporter);
    CodeChunk.Generator generator = translationContext.codeGenerator();

    List<Expression> ifs = new ArrayList<>();
    List<Expression> thens = new ArrayList<>();
    Expression trailingElse = null;

    for (SoyNode child : node.getChildren()) {

      if (child instanceof IfCondNode) {
        IfCondNode ifCond = (IfCondNode) child;

        ifs.add(translateExpr(ifCond.getExpr()));
        thens.add(CodeChunkUtils.concatChunks(genJsExprsVisitor.exec(ifCond)));
      } else if (child instanceof IfElseNode) {
        trailingElse = CodeChunkUtils.concatChunks(genJsExprsVisitor.exec(child));
      } else {
        throw new AssertionError();
      }
    }

    Preconditions.checkState(ifs.size() == thens.size());

    ConditionalExpressionBuilder builder = Expression.ifExpression(ifs.get(0), thens.get(0));

    for (int i = 1; i < ifs.size(); i++) {
      builder.addElseIf(ifs.get(i), thens.get(i));
    }

    Expression ifChunk =
        trailingElse != null
            ? builder.setElse(trailingElse).build(generator)
            : builder.setElse(LITERAL_EMPTY_STRING).build(generator);

    chunks.add(ifChunk);
  }
878035
@Override
    public Node visitPositionalArgument(SqlBaseParser.PositionalArgumentContext context)
    {
        return new CallArgument(getLocation(context), (Expression) visit(context.expression()));
    }
302124
private void insert(String key, RadixTreeNode<T> node, T value)
            throws DuplicateKeyException {

        int numberOfMatchingCharacters = node.getNumberOfMatchingCharacters(key);

        // we are either at the root node
        // or we need to go down the tree
        if (node.getKey().equals("") == true || numberOfMatchingCharacters == 0 || (numberOfMatchingCharacters < key.length() && numberOfMatchingCharacters >= node.getKey().length())) {
            boolean flag = false;
            String newText = key.substring(numberOfMatchingCharacters, key.length());
            for (RadixTreeNode<T> child : node.getChildern()) {
                if (child.getKey().startsWith(newText.charAt(0) + "")) {
                    flag = true;
                    insert(newText, child, value);
                    break;
                }
            }

            // just add the node as the child of the current node
            if (flag == false) {
                RadixTreeNode<T> n = new RadixTreeNode<T>();
                n.setKey(newText);
                n.setReal(true);
                n.setValue(value);

                node.getChildern().add(n);
            }
        }
        // there is a exact match just make the current node as data node
        else if (numberOfMatchingCharacters == key.length() && numberOfMatchingCharacters == node.getKey().length()) {
            if (node.isReal() == true) {
                throw new DuplicateKeyException("Duplicate key");
            }

            node.setReal(true);
            node.setValue(value);
        }
        // This node need to be split as the key to be inserted
        // is a prefix of the current node key
        else if (numberOfMatchingCharacters > 0 && numberOfMatchingCharacters < node.getKey().length()) {
            RadixTreeNode<T> n1 = new RadixTreeNode<T>();
            n1.setKey(node.getKey().substring(numberOfMatchingCharacters, node.getKey().length()));
            n1.setReal(node.isReal());
            n1.setValue(node.getValue());
            n1.setChildern(node.getChildern());

            node.setKey(key.substring(0, numberOfMatchingCharacters));
            node.setReal(false);
            node.setChildern(new ArrayList<RadixTreeNode<T>>());
            node.getChildern().add(n1);
            
            if(numberOfMatchingCharacters < key.length()) {
	            RadixTreeNode<T> n2 = new RadixTreeNode<T>();
	            n2.setKey(key.substring(numberOfMatchingCharacters, key.length()));
	            n2.setReal(true);
	            n2.setValue(value);
	            
	            node.getChildern().add(n2);
            } else {
            	node.setValue(value);
                node.setReal(true);
            }
        }        
        // this key need to be added as the child of the current node
        else {
            RadixTreeNode<T> n = new RadixTreeNode<T>();
            n.setKey(node.getKey().substring(numberOfMatchingCharacters, node.getKey().length()));
            n.setChildern(node.getChildern());
            n.setReal(node.isReal());
            n.setValue(node.getValue());

            node.setKey(key);
            node.setReal(true);
            node.setValue(value);

            node.getChildern().add(n);
        }
    }
658899
private void createExtendedElement(StringBuilder sb, RepositoryLogRecord record){
		sb.append(lineSeparator).append(INDENT[0]).append("<extendedDataElements name=\"CommonBaseEventLogRecord:level\" type=\"noValue\">");
		sb.append(lineSeparator).append(INDENT[1]).append("<children name=\"CommonBaseEventLogRecord:name\" type=\"string\">");
		sb.append(lineSeparator).append(INDENT[2]).append("<values>").append(record.getLevel().getName()).append("</values>");
		sb.append(lineSeparator).append(INDENT[1]).append("</children>");
		sb.append(lineSeparator).append(INDENT[1]).append("<children name=\"CommonBaseEventLogRecord:value\" type=\"int\">");
		sb.append(lineSeparator).append(INDENT[2]).append("<values>").append(record.getLevel().intValue()).append("</values>");
		sb.append(lineSeparator).append(INDENT[1]).append("</children>");
		sb.append(lineSeparator).append(INDENT[0]).append("</extendedDataElements>");    	
	}
905102
public int addElementAtPosition(int prevNode, int nextNode, int element,
			boolean bUnique, boolean bCallCompare, int treap) {
		int treap_ = treap;
		if (treap_ == -1) {
			if (m_defaultTreap == nullNode())
				m_defaultTreap = createTreap(-1);
			treap_ = m_defaultTreap;
		}

		// dbg_check_(m_root);
		if (getRoot_(treap_) == nullNode()) {
			assert (nextNode == nullNode() && prevNode == nullNode());
			int root = newNode_(element);
			setRoot_(root, treap_);
			addToList_(-1, root, treap_);
			return root;
		}

		int cmpNext;
		int cmpPrev;
		if (bCallCompare) {
			cmpNext = nextNode != nullNode() ? m_comparator.compare(this,
					element, nextNode) : -1;
			assert (cmpNext <= 0);
			cmpPrev = prevNode != nullNode() ? m_comparator.compare(this,
					element, prevNode) : 1;
			// cmpPrev can be negative in plane sweep when intersection is
			// detected.
		} else {
			cmpNext = -1;
			cmpPrev = 1;
		}

		if (bUnique && (cmpNext == 0 || cmpPrev == 0)) {
			m_comparator.onAddUniqueElementFailedImpl_(element);
			int cur = cmpNext == 0 ? nextNode : prevNode;
			setDuplicateElement_(cur, treap_);
			return -1;// return negative value.
		}

		int cur;
		int cmp;
		boolean bNext;
		if (nextNode != nullNode() && prevNode != nullNode()) {
			// randomize the the cost to insert a node.
			bNext = m_random > NumberUtils.nextRand(m_random) >> 1;
		} else
			bNext = nextNode != nullNode();

		if (bNext) {
			cmp = cmpNext;
			cur = nextNode;
		} else {
			cmp = cmpPrev;
			cur = prevNode;
		}

		int newNode = -1;
		int before = -1;
		boolean b_first = true;
		for (;;) {
			if (cmp < 0) {
				int left = getLeft(cur);
				if (left != nullNode())
					cur = left;
				else {
					before = cur;
					newNode = newNode_(element);
					setLeft_(cur, newNode);
					setParent_(newNode, cur);
					break;
				}
			} else {
				int right = getRight(cur);
				if (right != nullNode())
					cur = right;
				else {
					before = getNext(cur);
					newNode = newNode_(element);
					setRight_(cur, newNode);
					setParent_(newNode, cur);
					break;
				}
			}

			if (b_first) {
				cmp *= -1;
				b_first = false;
			}
		}

		bubbleUp_(newNode);
		if (getParent(newNode) == nullNode())
			setRoot_(newNode, treap_);

		addToList_(before, newNode, treap_);
		// dbg_check_(m_root);
		return newNode;
	}
1128952
public void insertSiblingBefore(Node node) throws ChildNodeException {
    if (node != null) {
      node.setPrevSibling(getPrevSibling());
      node.setNextSibling(this);
    }
  }