public final Iterable<Node> getParameters() { Node n = getParametersNode(); if (n != null) { return n.children(); } else { return Collections.emptySet(); } }
private void checkNamingAndAssignmentUsage(NodeTraversal t, Node n) { for (Node child : n.children()) { checkName(t, child); } }
public Iterable<Node> getParameters() { Node n = getParametersNode(); if (n != null) { return n.children(); } else { return Collections.emptySet(); } }
private FlowScope traverseDeclaration(Node n, FlowScope scope) { for (Node declarationChild : n.children()) { scope = traverseDeclarationChild(declarationChild, scope); } return scope; }
/** * @return The first property in the objlit that matches the key. */ private static Node extractProperty(Node objlit, String keyName) { for (Node keyNode : objlit.children()) { if (keyNode.getString().equals(keyName)) { return keyNode.getFirstChild(); } } return null; }
private boolean hasEs6Syntax(Node root) { checkState(root.isRoot()); for (Node script : root.children()) { checkState(script.isScript()); if (TranspilationPasses.isScriptEs6OrHigher(script)) { return true; } } return false; }
private static boolean hasJ2cl(Node root) { for (Node script : root.children()) { checkState(script.isScript()); if (script.getSourceFileName() != null && script.getSourceFileName().endsWith(".java.js")) { return true; } } return false; }
public final void makeNonIndexableRecursive() { this.makeNonIndexable(); for (Node child : children()) { child.makeNonIndexableRecursive(); } }
/** @return The first setter in the class members that matches the key. */ @Nullable static Node getFirstSetterMatchingKey(Node n, String keyName) { checkState(n.isClassMembers() || n.isObjectLit(), n); for (Node keyNode : n.children()) { if (keyNode.isSetterDef() && keyNode.getString().equals(keyName)) { return keyNode; } } return null; }
@Override public void process(Node externs, Node root) { checkArgument(externs.isRoot(), externs); checkArgument(root.isRoot(), root); for (Node file : Iterables.concat(externs.children(), root.children())) { checkState(file.isScript(), file); hotSwapScript(file, null); } compiler.setFeatureSet(compiler.getFeatureSet().without(MODULES)); // This pass may add getters properties on module objects. GatherGettersAndSetterProperties.update(compiler, externs, root); }
private void renameTypeNode(NodeTraversal t, Iterable<Node> typeNodes) { for (Node type : typeNodes) { if (type.isString()) { renameReference(t, type, true); } renameTypeNode(t, type.children()); } }
private void fixLineNumbers(Node expr) { // TODO(tbreisacher): Also fix column numbers. expr.setLineno(expr.getLineno() + templateLineno); for (Node child : expr.children()) { fixLineNumbers(child); } }
/** Traverses a non-function block. */ private void traverseBlockScope(Node n) { pushScope(n); for (Node child : n.children()) { traverseBranch(child, n); } popScope(); }
private void validateImportSpecifier(Node n) { validateNodeType(Token.IMPORT_SPEC, n); validateChildCountIn(n, 1, 2); for (Node child : n.children()) { validateName(child); } }
private boolean hasAnyInlineJsDoc(Node function) { if (function.getFirstChild().getJSDocInfo() != null) { // Inline return annotation. return true; } for (Node param : NodeUtil.getFunctionParameters(function).children()) { if (param.getJSDocInfo() != null) { return true; } } return false; }
private void processClass(Node n) { checkArgument(isClass(n)); for (Node member : n.getLastChild().children()) { if (member.isEmpty()) { NodeUtil.deleteNode(member, compiler); continue; } processFunction(member.getLastChild()); } }
private void nameClassMethods(Node classMembersNode, String className) { for (Node methodNode : classMembersNode.children()) { if (methodNode.isMemberFunctionDef()) { Node valueNode = methodNode.getFirstChild(); String name = namer.getCombinedName(className, namer.getName(methodNode)); namer.setFunctionName(name, valueNode); } } } }
@Override public void process(Node externs, Node root) { for (Node script : root.children()) { if (Es6RewriteModules.isEs6ModuleRoot(script)) { NodeTraversal.traverse(compiler, script, new Rewriter(compiler, script)); script.putBooleanProp(Node.TRANSPILED, true); } } compiler.setFeatureSet(compiler.getFeatureSet().without(Feature.MODULES)); }
/** Remove values from enums */ private void simplifyEnumValues(AbstractCompiler compiler) { if (getRhs().isObjectLit() && getRhs().hasChildren()) { for (Node key : getRhs().children()) { removeStringKeyValue(key); } compiler.reportChangeToEnclosingScope(getRhs()); } }