Java Code Examples for com.google.javascript.rhino.Node#setDirectives()
The following examples show how to use
com.google.javascript.rhino.Node#setDirectives() .
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: Closure_81_IRFactory_t.java From coming with MIT License | 6 votes |
/** * Parse the directives, encode them in the AST, and remove their nodes. * * For information on ES5 directives, see section 14.1 of * Ecma-262, Edition 5. * * It would be nice if Rhino would eventually take care of this for * us, but right now their directive-processing is a one-off. */ private void parseDirectives(Node node) { // Remove all the directives, and encode them in the AST. Set<String> directives = null; while (isDirective(node.getFirstChild())) { String directive = node.removeFirstChild().getFirstChild().getString(); if (directives == null) { directives = Sets.newHashSet(directive); } else { directives.add(directive); } } if (directives != null) { node.setDirectives(directives); } }
Example 2
Source File: Closure_81_IRFactory_s.java From coming with MIT License | 6 votes |
/** * Parse the directives, encode them in the AST, and remove their nodes. * * For information on ES5 directives, see section 14.1 of * Ecma-262, Edition 5. * * It would be nice if Rhino would eventually take care of this for * us, but right now their directive-processing is a one-off. */ private void parseDirectives(Node node) { // Remove all the directives, and encode them in the AST. Set<String> directives = null; while (isDirective(node.getFirstChild())) { String directive = node.removeFirstChild().getFirstChild().getString(); if (directives == null) { directives = Sets.newHashSet(directive); } else { directives.add(directive); } } if (directives != null) { node.setDirectives(directives); } }
Example 3
Source File: Closure_122_IRFactory_t.java From coming with MIT License | 6 votes |
/** * Parse the directives, encode them in the AST, and remove their nodes. * * For information on ES5 directives, see section 14.1 of * ECMA-262, Edition 5. * * It would be nice if Rhino would eventually take care of this for * us, but right now their directive-processing is a one-off. */ private void parseDirectives(Node node) { // Remove all the directives, and encode them in the AST. Set<String> directives = null; while (isDirective(node.getFirstChild())) { String directive = node.removeFirstChild().getFirstChild().getString(); if (directives == null) { directives = Sets.newHashSet(directive); } else { directives.add(directive); } } if (directives != null) { node.setDirectives(directives); } }
Example 4
Source File: Closure_122_IRFactory_s.java From coming with MIT License | 6 votes |
/** * Parse the directives, encode them in the AST, and remove their nodes. * * For information on ES5 directives, see section 14.1 of * ECMA-262, Edition 5. * * It would be nice if Rhino would eventually take care of this for * us, but right now their directive-processing is a one-off. */ private void parseDirectives(Node node) { // Remove all the directives, and encode them in the AST. Set<String> directives = null; while (isDirective(node.getFirstChild())) { String directive = node.removeFirstChild().getFirstChild().getString(); if (directives == null) { directives = Sets.newHashSet(directive); } else { directives.add(directive); } } if (directives != null) { node.setDirectives(directives); } }
Example 5
Source File: Closure_84_IRFactory_t.java From coming with MIT License | 6 votes |
/** * Parse the directives, encode them in the AST, and remove their nodes. * * For information on ES5 directives, see section 14.1 of * Ecma-262, Edition 5. * * It would be nice if Rhino would eventually take care of this for * us, but right now their directive-processing is a one-off. */ private void parseDirectives(Node node) { // Remove all the directives, and encode them in the AST. Set<String> directives = null; while (isDirective(node.getFirstChild())) { String directive = node.removeFirstChild().getFirstChild().getString(); if (directives == null) { directives = Sets.newHashSet(directive); } else { directives.add(directive); } } if (directives != null) { node.setDirectives(directives); } }
Example 6
Source File: Closure_84_IRFactory_s.java From coming with MIT License | 6 votes |
/** * Parse the directives, encode them in the AST, and remove their nodes. * * For information on ES5 directives, see section 14.1 of * Ecma-262, Edition 5. * * It would be nice if Rhino would eventually take care of this for * us, but right now their directive-processing is a one-off. */ private void parseDirectives(Node node) { // Remove all the directives, and encode them in the AST. Set<String> directives = null; while (isDirective(node.getFirstChild())) { String directive = node.removeFirstChild().getFirstChild().getString(); if (directives == null) { directives = Sets.newHashSet(directive); } else { directives.add(directive); } } if (directives != null) { node.setDirectives(directives); } }
Example 7
Source File: Closure_37_IRFactory_t.java From coming with MIT License | 6 votes |
/** * Parse the directives, encode them in the AST, and remove their nodes. * * For information on ES5 directives, see section 14.1 of * Ecma-262, Edition 5. * * It would be nice if Rhino would eventually take care of this for * us, but right now their directive-processing is a one-off. */ private void parseDirectives(Node node) { // Remove all the directives, and encode them in the AST. Set<String> directives = null; while (isDirective(node.getFirstChild())) { String directive = node.removeFirstChild().getFirstChild().getString(); if (directives == null) { directives = Sets.newHashSet(directive); } else { directives.add(directive); } } if (directives != null) { node.setDirectives(directives); } }
Example 8
Source File: Closure_37_IRFactory_s.java From coming with MIT License | 6 votes |
/** * Parse the directives, encode them in the AST, and remove their nodes. * * For information on ES5 directives, see section 14.1 of * Ecma-262, Edition 5. * * It would be nice if Rhino would eventually take care of this for * us, but right now their directive-processing is a one-off. */ private void parseDirectives(Node node) { // Remove all the directives, and encode them in the AST. Set<String> directives = null; while (isDirective(node.getFirstChild())) { String directive = node.removeFirstChild().getFirstChild().getString(); if (directives == null) { directives = Sets.newHashSet(directive); } else { directives.add(directive); } } if (directives != null) { node.setDirectives(directives); } }
Example 9
Source File: Closure_42_IRFactory_t.java From coming with MIT License | 6 votes |
/** * Parse the directives, encode them in the AST, and remove their nodes. * * For information on ES5 directives, see section 14.1 of * Ecma-262, Edition 5. * * It would be nice if Rhino would eventually take care of this for * us, but right now their directive-processing is a one-off. */ private void parseDirectives(Node node) { // Remove all the directives, and encode them in the AST. Set<String> directives = null; while (isDirective(node.getFirstChild())) { String directive = node.removeFirstChild().getFirstChild().getString(); if (directives == null) { directives = Sets.newHashSet(directive); } else { directives.add(directive); } } if (directives != null) { node.setDirectives(directives); } }
Example 10
Source File: Closure_42_IRFactory_s.java From coming with MIT License | 6 votes |
/** * Parse the directives, encode them in the AST, and remove their nodes. * * For information on ES5 directives, see section 14.1 of * Ecma-262, Edition 5. * * It would be nice if Rhino would eventually take care of this for * us, but right now their directive-processing is a one-off. */ private void parseDirectives(Node node) { // Remove all the directives, and encode them in the AST. Set<String> directives = null; while (isDirective(node.getFirstChild())) { String directive = node.removeFirstChild().getFirstChild().getString(); if (directives == null) { directives = Sets.newHashSet(directive); } else { directives.add(directive); } } if (directives != null) { node.setDirectives(directives); } }
Example 11
Source File: Reader.java From astor with GNU General Public License v2.0 | 6 votes |
private void transformPrologueDecl(JsonML element, Node parent) throws JsonMLException { String directive = getStringAttribute(element, TagAttr.DIRECTIVE); if (ALLOWED_DIRECTIVES.contains(directive)) { Set<String> directives = parent.getDirectives(); if (directives == null) { directives = Sets.newHashSet(); } directives.add(directive); parent.setDirectives(directives); } else { // for a directive which is not supported, we create a regular node Node node = IR.exprResult(IR.string(directive)); parent.addChildToBack(node); } }
Example 12
Source File: IRFactory.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Parse the directives, encode them in the AST, and remove their nodes. * * For information on ES5 directives, see section 14.1 of * ECMA-262, Edition 5. * * It would be nice if Rhino would eventually take care of this for * us, but right now their directive-processing is a one-off. */ private void parseDirectives(Node node) { // Remove all the directives, and encode them in the AST. Set<String> directives = null; while (isDirective(node.getFirstChild())) { String directive = node.removeFirstChild().getFirstChild().getString(); if (directives == null) { directives = Sets.newHashSet(directive); } else { directives.add(directive); } } if (directives != null) { node.setDirectives(directives); } }
Example 13
Source File: NodeModulePass.java From js-dossier with Apache License 2.0 | 5 votes |
private void visitScript(NodeTraversal t, Node script) { if (currentModule == null) { return; } // Remove any 'use strict' directives. The compiler adds these by default to // closure modules and will generate a warning if specified directly. // TODO: remove when https://github.com/google/closure-compiler/issues/1263 is fixed. Set<String> directives = script.getDirectives(); if (directives != null && directives.contains("use strict")) { // Directives is likely an immutable collection, so we need to make a copy. Set<String> newDirectives = new HashSet<>(directives); newDirectives.remove("use strict"); script.setDirectives(newDirectives); } processModuleExportRefs(t); Node moduleBody = createModuleBody(); moduleBody.srcrefTree(script); if (script.getChildCount() > 0) { moduleBody.addChildrenToBack(script.removeChildren()); } script.addChildToBack(moduleBody); script.putBooleanProp(Node.GOOG_MODULE, true); t.getInput().addProvide(currentModule); traverse(t.getCompiler(), script, new TypeCleanup()); googRequireExpr.clear(); currentModule = null; t.reportCodeChange(); }