code: private void prepTemplatePlaceholders(Node fn) {
      final List<String> locals = templateLocals;
      final List<String> params = templateParams;
      final Map<String, JSType> paramTypes = new HashMap<>();
  
      // drop the function name so it isn't include in the name maps
      String fnName = fn.getFirstChild().getString();
      fn.getFirstChild().setString("");
  
      // Build a list of parameter names and types.
      Node templateParametersNode = fn.getSecondChild();
      JSDocInfo info = NodeUtil.getBestJSDocInfo(fn);
      if (templateParametersNode.hasChildren()) {
        Preconditions.checkNotNull(info,
            "Missing JSDoc declaration for template function %s", fnName);
      }
      for (Node paramNode : templateParametersNode.children()) {
        String name = paramNode.getString();
        JSTypeExpression expression = info.getParameterType(name);
        Preconditions.checkNotNull(expression,
            "Missing JSDoc for parameter %s of template function %s",
            name, fnName);
        JSType type = typeRegistry.evaluateTypeExpressionInGlobalScope(expression);
        checkNotNull(type);
        params.add(name);
        paramTypes.put(name, type);
      }
  
      // Find references to string literals, local variables and parameters and replace them.
      traverse(
          fn,
          new Visitor() {
            @Override
            public void visit(Node n) {
              if (n.isName()) {
                Node parent = n.getParent();
                String name = n.getString();
                if (!name.isEmpty() && parent.isVar() && !locals.contains(name)) {
                  locals.add(n.getString());
                }
  
                if (params.contains(name)) {
                  JSType type = paramTypes.get(name);
                  boolean isStringLiteral =
                      type.isStringValueType() && name.startsWith("string_literal");
                  replaceNodeInPlace(
                      n, createTemplateParameterNode(params.indexOf(name), type, isStringLiteral));
                } else if (locals.contains(name)) {
                  replaceNodeInPlace(n, createTemplateLocalNameNode(locals.indexOf(name)));
                }
              }
            }
          });
    }
docs: Build parameter and local information for the template and replace
  the references in the template 'fn' with placeholder nodes use to
  facility matching.