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 = expression.evaluate(null, compiler.getTypeRegistry());
Preconditions.checkNotNull(type);
params.add(name);
paramTypes.put(name, type);
}
// Find references to 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);
replaceNodeInPlace(n,
createTemplateParameterNode(params.indexOf(name), type));
} else if (locals.contains(name)) {
replaceNodeInPlace(n,
createTemplateLocalNameNode(locals.indexOf(name)));