Skip to content

Commit

Permalink
fixed files form Closure #108
Browse files Browse the repository at this point in the history
  • Loading branch information
tdurieux committed Mar 7, 2017
1 parent f65d09a commit b3cd33b
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ private class Traversal implements NodeTraversal.ScopedCallback {
private final Map<String, Var> aliases = Maps.newHashMap();

// Also temporary and cleared for each scope.
private final Set<Node> injectedDecls = Sets.newHashSet();

// Suppose you create an alias.
// var x = goog.x;
Expand Down Expand Up @@ -313,6 +314,7 @@ public void exitScope(NodeTraversal t) {

if (t.getScopeDepth() == 2) {
renameNamespaceShadows(t);
injectedDecls.clear();
aliases.clear();
forbiddenLocals.clear();
transformation = null;
Expand Down Expand Up @@ -429,6 +431,7 @@ private void findAliases(NodeTraversal t) {
} else {
grandparent.addChildBefore(newDecl, varNode);
}
injectedDecls.add(newDecl.getFirstChild());
}

// Rewrite "var name = EXPR;" to "var name = $jscomp.scope.name;"
Expand Down Expand Up @@ -578,7 +581,7 @@ public void visit(NodeTraversal t, Node n, Node parent) {
// When we inject declarations, we duplicate jsdoc. Make sure
// we only process that jsdoc once.
JSDocInfo info = n.getJSDocInfo();
if (info != null) {
if (info != null && !injectedDecls.contains(n)) {
for (Node node : info.getTypeNodes()) {
fixTypeNode(node);
}
Expand Down

0 comments on commit b3cd33b

Please sign in to comment.