/** * Convenience method for running this pass over a tree with this * class as a callback. */ @Override public void process(Node externs, Node root) { NodeTraversal t = new NodeTraversal(compiler, this, scopeCreator); t.traverseRoots(externs, root); }
@Override public void exitScope(NodeTraversal t) { if (t.getScope() == dynamicImportScope) { dynamicImportScope = null; } }
@Override public void process(Node externs, Node root) { requiresTypes = false; NodeTraversal.traverse(compiler, root, this); }
void process(Node externs, Node root) { if (externs == null) { NodeTraversal.traverse(compiler, root, this); } else { NodeTraversal.traverseRoots(compiler, this, externs, root); } }
/** Traverse the scope root and build it. */ void build() { new NodeTraversal(compiler, this, ScopeCreator.ASSERT_NO_SCOPES_CREATED) .traverseAtScope(currentScope); }
@Override public void process(Node externs, Node root) { //NodeTraversal.traverse(compiler, root, this); NodeTraversal.traverseRoots(compiler, this, externs, root); }
public void process(Node root) { NodeTraversal t = new NodeTraversal(compiler, this, scopeCreator); t.traverse(root); }
traversal.makeError(node, MESSAGE_HAS_NO_VALUE, messageKey)); return; compiler.report(traversal.makeError(node, MESSAGE_NOT_INITIALIZED_USING_NEW_SYNTAX)); if (style == JsMessage.Style.CLOSURE) { isUnnamedMsg ? null : messageKey); OriginalMapping mapping = compiler.getSourceMapping( traversal.getSourceName(), traversal.getLineNumber(), traversal.getCharno()); if (mapping != null) { builder.setSourceName(mapping.getOriginalFile()); } else { builder.setSourceName(traversal.getSourceName()); compiler.report(traversal.makeError(ex.getNode(), MESSAGE_TREE_MALFORMED, ex.getMessage())); return; compiler.report(traversal.makeError(node, MESSAGE_HAS_NO_TEXT, messageKey)); && (desc == null || desc.trim().isEmpty()) && !extractedMessage.isExternal()) { compiler.report(traversal.makeError(node, MESSAGE_HAS_NO_DESCRIPTION, messageKey));
@Override public void enterScope(NodeTraversal t) { if (t.inGlobalHoistScope()) { return; } if (inGoogScopeBody()) { Scope hoistedScope = t.getClosestHoistScope().untyped(); if (isGoogScopeFunctionBody(hoistedScope.getRootNode())) { findAliases(t, hoistedScope); } } Node scopeMethodCall = findScopeMethodCall(t.getScopeRoot()); if (scopeMethodCall != null) { transformation = transformationHandler.logAliasTransformation( scopeMethodCall.getSourceFileName(), getSourceRegion(scopeMethodCall)); findAliases(t, t.getScope()); scopeFunctionBody = scopeMethodCall.getLastChild().getLastChild(); } }
void check(Node node, boolean externs) { checkNotNull(node); NodeTraversal t = new NodeTraversal(compiler, this, scopeCreator); inExterns = externs; t.traverseWithScope(node, topScope); if (externs) { inferJSDocInfo.process(node, null); } else { inferJSDocInfo.process(null, node); } }
/** Determines whether {@code n} is the FUNCTION node in a global function declaration. */ private boolean isGlobalFunctionDeclaration(NodeTraversal t, Node n) { // Make sure we're not in a function scope, or if we are then the function we're looking at // is defined in the global scope. if (!(t.inGlobalHoistScope() || (n.isFunction() && t.getScopeRoot() == n && t.getScope().getParent().getClosestHoistScope().isGlobal()))) { return false; } return NodeUtil.isFunctionDeclaration(n) || (n.isFunction() && n.getParent().isName()); }
@Override public void enterScope(NodeTraversal t) { if (t.inGlobalHoistScope()) { return; } if (inGoogScopeBody()) { Scope hoistedScope = t.getClosestHoistScope(); if (isGoogScopeFunctionBody(hoistedScope.getRootNode())) { findAliases(t, hoistedScope); } } Node scopeMethodCall = findScopeMethodCall(t.getScope().getRootNode()); if (scopeMethodCall != null) { transformation = transformationHandler.logAliasTransformation( scopeMethodCall.getSourceFileName(), getSourceRegion(scopeMethodCall)); findAliases(t, t.getScope()); scopeFunctionBody = scopeMethodCall.getLastChild().getLastChild(); } }
@Override public void enterScope(NodeTraversal t) { if (t.inGlobalScope()) { this.globalScope = t.getScope(); references.globalScope = this.globalScope; } }
new NodeTraversal(compiler, gatherFunctions, new Es6SyntacticScopeCreator(compiler)) .traverseInnerNode( rValue, rValue.getParent(), t.getClosestHoistScope().getParent()); if (badFunctionNodes.contains(rValue)) { return;
@Override public void visit(NodeTraversal t, Node n, Node parent) { // In the top scope, "this" is a reference to "value" boolean isThis = false; if (t.getClosestHoistScope() == this.startingScope) { isThis = n.isThis(); } if (isThis || n.isName() && !isShadowed(n.getString(), t.getScope())) { String nodeValue = isThis ? null : n.getString(); if (!isThis && keyName != null && nodeValue.equals(keyName)) { keyReferences.add(n); } else if (isThis || (valueName != null && nodeValue.equals(valueName))) { valueReferences.add(n); } } }
/** Traverses in post order. */ public static void traversePostOrder( AbstractCompiler compiler, Node root, AbstractPostOrderCallbackInterface cb) { traverse(compiler, root, makePostOrderCallback(cb)); }
/** Examines the functions stack for the last instance of a function node. When possible, prefer * this method over NodeUtil.getEnclosingFunction() because this in general looks at less nodes. */ public Node getEnclosingFunction() { Node root = getCfgRoot(); return root.isFunction() ? root : null; }
@Override public void visit(NodeTraversal t, Node n, Node parent) { int nodeType = n.getType(); if (nodeType == Token.CALL || nodeType == Token.NEW) { Callsite callsite = createCallsite(n); Node containingFunctionNode = NodeUtil.getEnclosingFunction(t.getScopeRoot()); if (containingFunctionNode == null) { containingFunctionNode = t.getClosestHoistScope().getRootNode(); } Function containingFunction = functionsByNode.get(containingFunctionNode); if (containingFunction == null) { containingFunction = createFunction(containingFunctionNode); } callsite.containingFunction = containingFunction; containingFunction.addCallsiteInFunction(callsite); connectCallsiteToTargets(callsite, provider); } else if (n.isFunction()) { if (!functionsByNode.containsKey(n)) { createFunction(n); } } } });
/** Traverses from a particular scope node using the ES6SyntacticScopeCreator */ private static void traverseEs6ScopeRoot( AbstractCompiler compiler, Node scopeNode, Callback cb, MemoizedScopeCreator scopeCreator) { NodeTraversal t = new NodeTraversal(compiler, cb, scopeCreator); t.traverseScopeRoot(scopeNode); }