See go/soy-element-keyed-roots for reasoning on why this is disallowed.
512646
private void validateNoKey(HtmlOpenTagNode firstTagNode) {
    for (SoyNode child : firstTagNode.getChildren()) {
      if (child instanceof KeyNode) {
        errorReporter.report(firstTagNode.getSourceLocation(), ROOT_HAS_KEY_NODE);
      }
    }
  }
278279
private SoyMsgBundle doExtractMsgs() {
    // extractMsgs disables a bunch of passes since it is typically not configured with things
    // like global definitions, type definitions, plugins, etc.
    SoyFileSetNode soyTree =
        parse(
                passManagerBuilder()
                    .allowUnknownGlobals()
                    .allowV1Expression()
                    .setTypeRegistry(SoyTypeRegistry.DEFAULT_UNKNOWN)
                    // TODO(lukes): consider changing this to pass a null resolver instead of the
                    // ALLOW_UNDEFINED mode
                    .setPluginResolver(
                        new PluginResolver(
                            PluginResolver.Mode.ALLOW_UNDEFINED,
                            printDirectives,
                            soyFunctionMap,
                            soySourceFunctionMap,
                            errorReporter))
                    .disableAllTypeChecking(),
                // override the type registry so that the parser doesn't report errors when it
                // can't resolve strict types
                SoyTypeRegistry.DEFAULT_UNKNOWN)
            .fileSet();
    throwIfErrorsPresent();
    SoyMsgBundle bundle = new ExtractMsgsVisitor().exec(soyTree);
    throwIfErrorsPresent();
    return bundle;
  }
510844
private Element searchForKey(final Element root, final String keyValue) {
        if (root == null || keyValue == null) {
            return null;
        }
        final LinkedList<Element> queue = new LinkedList<>();
        queue.add(root);
        while (!queue.isEmpty()) {
            final Element node = queue.removeFirst();
            final NodeList children = node.getChildNodes();
            for (int i = 0; i < children.getLength(); i++) {
                if (children.item(i).getNodeType() == Node.ELEMENT_NODE) {
                    queue.add((Element)children.item(i));
                }
            }
            if (SUBJECTSCHEME_SUBJECTDEF.matches(node)) {
                final String key = node.getAttribute(ATTRIBUTE_NAME_KEYS);
                if (keyValue.equals(key)) {
                    return node;
                }
            }
        }
        return null;
    }
748849
function(key, searchRoot) {
			// Search the DOM by element ID (assuming this is faster than traversing all nodes).
			var el, match;
			// TODO: use tree.keyMap if available
			// TODO: check opts.generateIds === true
			if (!searchRoot) {
				el = document.getElementById(this.options.idPrefix + key);
				if (el) {
					return el.ftnode ? el.ftnode : null;
				}
			}
			// Not found in the DOM, but still may be in an unrendered part of tree
			searchRoot = searchRoot || this.rootNode;
			match = null;
			searchRoot.visit(function(node) {
				if (node.key === key) {
					match = node;
					return false; // Stop iteration
				}
			}, true);
			return match;
		}
676512
@Override
  public void putSingle(String key, SoyData value) {
    map.put(key, value);
  }
707238
private JSType restrictByUndefined(JSType type) {
    // If not voidable, there's nothing to do. If not nullable then the easiest
    // thing is to simply remove both null and undefined. If nullable, then add
    // null back into the union after removing null and undefined.
    if (!type.isVoidable()) {
      return type;
    }
    JSType restricted = type.restrictByNotNullOrUndefined();
    if (type.isNullable()) {
      JSType nullType = registry.getNativeType(JSTypeNative.NULL_TYPE);
      return registry.createUnionType(ImmutableList.of(restricted, nullType));
    }
    // The bottom type cannot appear in a jsdoc
    return restricted.isEmptyType() ? type : restricted;
  }
954748
@Override
    public T visitElement(Element elm, C context) {
        if (elm instanceof IncludeDef) return visitIncludeDef((IncludeDef)elm, context);
        else if (elm instanceof Library) return visitLibrary((Library)elm, context);
        else if (elm instanceof UsingDef) return visitUsingDef((UsingDef)elm, context);
        else return super.visitElement(elm, context);
    }
878852
public final SoyTypeP toProto() {
    SoyTypeP local = protoDual;
    if (local == null) {
      SoyTypeP.Builder builder = SoyTypeP.newBuilder();
      doToProto(builder);
      local = builder.build();
      protoDual = local;
    }
    return local;
  }
1304661
public SoyExpression coerceToDouble() {
    if (!isBoxed()) {
      if (soyRuntimeType.isKnownFloat()) {
        return this;
      }
      if (soyRuntimeType.isKnownInt()) {
        return forFloat(BytecodeUtils.numericConversion(delegate, Type.DOUBLE_TYPE));
      }
      throw new UnsupportedOperationException("Can't convert " + resultType() + " to a double");
    }
    if (soyRuntimeType.isKnownFloat()) {
      return forFloat(delegate.invoke(MethodRef.SOY_VALUE_FLOAT_VALUE));
    }
    return forFloat(delegate.invoke(MethodRef.SOY_VALUE_NUMBER_VALUE));
  }
349184
private void parseLikelySubtags(JsonObject root) {
    JsonObject node = resolve(root, "supplemental", "likelySubtags");
    for (Map.Entry<String, JsonElement> entry : node.entrySet()) {
      likelySubtags.put(entry.getKey(), entry.getValue().getAsString());
    }
  }
1295160
private Statement generateFunctionBodyForSoyElement(TemplateNode node) {
    String soyElementClassName = this.getSoyElementClassName();
    Expression firstElementKey =
        // Since Soy element roots cannot have manual keys (see go/soy-element-keyed-roots),
        // this will always be the first element key.
        JsRuntime.XID.call(Expression.stringLiteral(node.getTemplateName() + "-0"));

    VariableDeclaration elementInstanceDeclaration =
        VariableDeclaration.builder("element")
            .setRhs(
                SOY_IDOM
                    .dotAccess("$$tryGetElement")
                    .call(INCREMENTAL_DOM, id(soyElementClassName), firstElementKey))
            .build();
    Statement maybeCreateElement =
        Statement.ifStatement(
                elementInstanceDeclaration.ref().tripleEquals(Expression.LITERAL_NULL),
                elementInstanceDeclaration
                    .ref()
                    .assign(
                        Expression.construct(
                            id(soyElementClassName), JsRuntime.OPT_DATA, JsRuntime.OPT_IJ_DATA))
                    .asStatement())
            .build();

    Statement elementRenderInvocation =
        elementInstanceDeclaration
            .ref()
            .dotAccess("renderInternal")
            .call(INCREMENTAL_DOM, JsRuntime.OPT_DATA)
            .asStatement();

    return Statement.of(maybeCreateElement, elementInstanceDeclaration, elementRenderInvocation);
  }
977198
Mappings matchRoot(IAtom root) {
        checkCompatibleAPI(root);
        IAtomContainer mol = root.getContainer();
        if (query.getAtomCount() > 0 && ((IQueryAtom) query.getAtom(0)).matches(root)) {
            DfState local = new DfState(state);
            local.setRoot(root);
            return filter(new Mappings(query, mol, local), query, mol);
        } else {
            return new Mappings(query, mol, Collections.<int[]>emptySet());
        }
    }
665544
private int getIntegerIndex(SoyValue key) {
    try {
      return ((IntegerData) key).integerValue();
    } catch (ClassCastException cce) {
      try {
        // TODO: Remove this old bad behavior after existing code is compliant.
        return Integer.parseInt(key.coerceToString());
      } catch (NumberFormatException nfe) {
        throw new SoyDataException(
            "SoyList accessed with non-integer key (got key type "
                + key.getClass().getName()
                + ").");
      }
    }
  }
46688
private SoyValue visitNullSafeNode(ExprNode node) {
    SoyValue value = visitNullSafeNodeRecurse(node);
    // Transform null sentinel into a normal null value.
    if (value == NullSafetySentinel.INSTANCE) {
      return NullData.INSTANCE;
    }
    return value;
  }
293593
private void  g(Attributes attributes) throws SVGParseException
   {
      debug("<g>");

      if (currentElement == null)
         throw new SVGParseException("Invalid document. Root element must be <svg>");
      SVG.Group  obj = new SVG.Group();
      obj.document = svgDocument;
      obj.parent = currentElement;
      parseAttributesCore(obj, attributes);
      parseAttributesStyle(obj, attributes);
      parseAttributesTransform(obj, attributes);
      parseAttributesConditional(obj, attributes);
      currentElement.addChild(obj);
      currentElement = obj;
   }
781276
public static SanitizedContent filterSmsUri(SoyValue value) {
    value = normalizeNull(value);
    return filterSmsUri(value.coerceToString());
  }
816266
V removeMapping(final Object o) {
        if (!(o instanceof Map.Entry)) {
            throw new IllegalArgumentException();
        }

        @SuppressWarnings("unchecked") final Entry<? extends CharSequence, V> e = (Map.Entry<? extends CharSequence, V>) o;
        final CharSequence key = keyCheck(e.getKey());
        final V value = e.getValue();
        final TrieNode<V> currentNode = findPreviousNode(key);

        if (currentNode == null) {
			/* Node not found for the given key */
            return null;
        }

        final TrieNode<V> node = currentNode.children.get(key.charAt(key
                .length() - 1));

        if (node == null || !node.inUse) {
			/* Node not found for the given key or is not in use */
            return null;
        }

        final V removed = node.value;

        if (removed != value && (removed == null || !removed.equals(value))) {
			/*
			 * Value in the map differs from the value given in the entry so do
			 * nothing and return null.
			 */
            return null;
        }

        node.unset();
        --size;
        ++modCount;

        if (node.children.isEmpty()) {
			/* Since there are no children left, we can compact the trie */
            compact(key);
        }

        return removed;
    }