Java Code Examples for com.google.javascript.jscomp.NodeTraversal#traverse()
The following examples show how to use
com.google.javascript.jscomp.NodeTraversal#traverse() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TypeConversionPass.java From clutz with MIT License | 6 votes |
@Override public void process(Node externs, Node root) { this.typesToRename = new LinkedHashMap<>(); this.typesToFilename = new LinkedHashMap<>(); for (Node child : root.children()) { // We convert each file independently to avoid merging class methods from different files. if (child.isScript()) { this.types = new LinkedHashMap<>(); NodeTraversal.traverse(compiler, child, new TypeConverter(this.nodeComments)); NodeTraversal.traverse(compiler, child, new TypeMemberConverter()); NodeTraversal.traverse(compiler, child, new FieldOnThisConverter()); NodeTraversal.traverse(compiler, child, new InheritanceConverter()); NodeTraversal.traverse(compiler, child, new AbstractAnnotationConverter()); NodeTraversal.traverse(compiler, child, new EnumConverter()); } } convertTypeAlias(); }
Example 2
Source File: FileVisibilityPass.java From js-dossier with Apache License 2.0 | 6 votes |
@Override public void process(DossierCompiler compiler, Node root) { NodeTraversal.traverse( compiler, root, new NodeTraversal.AbstractShallowCallback() { @Override public void visit(NodeTraversal t, Node n, Node parent) { if (n.isScript()) { JsDoc docs = JsDoc.from(n.getJSDocInfo()); Visibility visibility = docs.getVisibility(); if (visibility != null && visibility != Visibility.INHERITED) { Path path = inputFs.getPath(n.getSourceFileName()); typeRegistry.setDefaultVisibility(path, visibility); } } } }); }
Example 3
Source File: CommentLinkingPass.java From clutz with MIT License | 5 votes |
@Override public void process(Node externs, Node root) { for (Node script : root.children()) { if (script.isScript()) { // Note: this doesn't actually copy the list since the underlying list is already an // immutable list. ImmutableList<Comment> comments = ImmutableList.copyOf(compiler.getComments(script.getSourceFileName())); NodeTraversal.traverse( compiler, script, new LinkCommentsForOneFile(compiler, comments, nodeComments)); } } }
Example 4
Source File: TypeAnnotationPass.java From clutz with MIT License | 5 votes |
@Override public void process(Node externs, Node root) { NodeTraversal.traverse(compiler, root, new TypeAnnotationConverter()); NodeTraversal.traverse(compiler, root, new AccessModifierConverter()); NodeTraversal.traverse(compiler, root, new TemplateAnnotationConverter()); for (Node script : root.children()) { addTypeOnlyImports(script); } }
Example 5
Source File: MinerrPass.java From ng-closure-runner with MIT License | 5 votes |
@Override public void process(Node externs, Node root) { NodeTraversal.traverse(compiler, root, this); boolean codeChanged = false; PrintStream stream; for (Node instance : minerrInstances) { Node templateNode = instance.getChildAtIndex(2); Node errCodeNode = instance.getChildAtIndex(1); String namespace = getNamespace(instance); if (namespace != null) { addMessageToNamespace(namespace, getExprString(errCodeNode), getExprString(templateNode)); } else { addMessageToGlobalNamespace(getExprString(errCodeNode), getExprString(templateNode)); } instance.removeChild(templateNode); codeChanged = true; } if (minerrDefNode != null && minerrDefSource != null) { Node newMinErrDef = createSubstituteMinerrDefinition(); newMinErrDef.useSourceInfoFromForTree(minerrDefNode); minerrDefNode.getParent().replaceChild(minerrDefNode, newMinErrDef); codeChanged = true; } Map<String, Object> jsonBuilder = new HashMap<String, Object>(namespaces); jsonBuilder.putAll(globalNamespace); JSONObject json = new JSONObject(jsonBuilder); errorConfigOutput.print(json.toString()); if (codeChanged) { compiler.reportCodeChange(); } }
Example 6
Source File: CollectModuleMetadata.java From clutz with MIT License | 4 votes |
@Override public void process(Node externs, Node root) { NodeTraversal.traverse(compiler, root, this); }
Example 7
Source File: ModuleConversionPass.java From clutz with MIT License | 4 votes |
@Override public void process(Node externs, Node root) { NodeTraversal.traverse(compiler, root, new ModuleExportConverter()); NodeTraversal.traverse(compiler, root, new ModuleImportConverter()); NodeTraversal.traverse(compiler, root, new ModuleImportRewriter()); }
Example 8
Source File: StyleFixPass.java From clutz with MIT License | 4 votes |
@Override public void process(Node externs, Node root) { NodeTraversal.traverse(compiler, root, this); }
Example 9
Source File: RemoveGoogScopePass.java From clutz with MIT License | 4 votes |
@Override public void process(Node externs, Node root) { NodeTraversal.traverse(compiler, root, this); }
Example 10
Source File: MinimizeExitPoints.java From astor with GNU General Public License v2.0 | 4 votes |
@Override public void process(Node externs, Node root) { NodeTraversal.traverse(compiler, root, this); }