Java Code Examples for com.google.javascript.rhino.IR#script()

The following examples show how to use com.google.javascript.rhino.IR#script() . 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: JsAst.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
private void parse(AbstractCompiler compiler) {
  try {
    logger_.fine("Parsing: " + sourceFile.getName());
    ParserRunner.ParseResult result = ParserRunner.parse(sourceFile, sourceFile.getCode(),
        compiler.getParserConfig(),
        compiler.getDefaultErrorReporter(),
        logger_);
    root = result.ast;
    compiler.setOldParseTree(sourceFile.getName(), result.oldAst);
  } catch (IOException e) {
    compiler.report(
        JSError.make(AbstractCompiler.READ_ERROR, sourceFile.getName()));
  }

  if (root == null || compiler.hasHaltingErrors()) {
    // There was a parse error or IOException, so use a dummy block.
    root = IR.script();
  } else {
    compiler.prepareAst(root);
  }

  // Set the source name so that the compiler passes can track
  // the source file and module.
  root.setStaticSourceFile(sourceFile);
}
 
Example 2
Source File: Cardumen_0017_t.java    From coming with MIT License 5 votes vote down vote up
private Node createTemplateNode() {
  // The Node type choice is arbitrary.
  Node templateNode = IR.script();
  templateNode.setStaticSourceFile(
    this.associatedNode != null ?
    this.associatedNode.getStaticSourceFile() :
    null);
  return templateNode;
}
 
Example 3
Source File: Cardumen_0017_s.java    From coming with MIT License 5 votes vote down vote up
private Node createTemplateNode() {
  // The Node type choice is arbitrary.
  Node templateNode = IR.script();
  templateNode.setStaticSourceFile(
    this.associatedNode != null ?
    this.associatedNode.getStaticSourceFile() :
    null);
  return templateNode;
}
 
Example 4
Source File: Nopol2017_0025_t.java    From coming with MIT License 5 votes vote down vote up
private Node createTemplateNode() {
  // The Node type choice is arbitrary.
  Node templateNode = IR.script();
  templateNode.setStaticSourceFile(
    this.associatedNode != null ?
    this.associatedNode.getStaticSourceFile() :
    null);
  return templateNode;
}
 
Example 5
Source File: Nopol2017_0025_s.java    From coming with MIT License 5 votes vote down vote up
private Node createTemplateNode() {
  // The Node type choice is arbitrary.
  Node templateNode = IR.script();
  templateNode.setStaticSourceFile(
    this.associatedNode != null ?
    this.associatedNode.getStaticSourceFile() :
    null);
  return templateNode;
}
 
Example 6
Source File: Closure_32_JsDocInfoParser_t.java    From coming with MIT License 5 votes vote down vote up
private Node createTemplateNode() {
  // The Node type choice is arbitrary.
  Node templateNode = IR.script();
  templateNode.setStaticSourceFile(
    this.associatedNode != null ?
    this.associatedNode.getStaticSourceFile() :
    null);
  return templateNode;
}
 
Example 7
Source File: Closure_32_JsDocInfoParser_s.java    From coming with MIT License 5 votes vote down vote up
private Node createTemplateNode() {
  // The Node type choice is arbitrary.
  Node templateNode = IR.script();
  templateNode.setStaticSourceFile(
    this.associatedNode != null ?
    this.associatedNode.getStaticSourceFile() :
    null);
  return templateNode;
}
 
Example 8
Source File: Closure_133_JsDocInfoParser_t.java    From coming with MIT License 5 votes vote down vote up
private Node createTemplateNode() {
  // The Node type choice is arbitrary.
  Node templateNode = IR.script();
  templateNode.setStaticSourceFile(
    this.associatedNode != null ?
    this.associatedNode.getStaticSourceFile() :
    null);
  return templateNode;
}
 
Example 9
Source File: Closure_133_JsDocInfoParser_s.java    From coming with MIT License 5 votes vote down vote up
private Node createTemplateNode() {
  // The Node type choice is arbitrary.
  Node templateNode = IR.script();
  templateNode.setStaticSourceFile(
    this.associatedNode != null ?
    this.associatedNode.getStaticSourceFile() :
    null);
  return templateNode;
}
 
Example 10
Source File: Closure_109_JsDocInfoParser_t.java    From coming with MIT License 5 votes vote down vote up
private Node createTemplateNode() {
  // The Node type choice is arbitrary.
  Node templateNode = IR.script();
  templateNode.setStaticSourceFile(
    this.associatedNode != null ?
    this.associatedNode.getStaticSourceFile() :
    null);
  return templateNode;
}
 
Example 11
Source File: Closure_109_JsDocInfoParser_s.java    From coming with MIT License 5 votes vote down vote up
private Node createTemplateNode() {
  // The Node type choice is arbitrary.
  Node templateNode = IR.script();
  templateNode.setStaticSourceFile(
    this.associatedNode != null ?
    this.associatedNode.getStaticSourceFile() :
    null);
  return templateNode;
}
 
Example 12
Source File: ObjectPropertyStringPreprocess.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
private void addExternDeclaration(Node externs, Node declarationStmt) {
  Node script = externs.getLastChild();
  if (script == null || !script.isScript()) {
    script = IR.script();
    externs.addChildToBack(script);
  }
  script.addChildToBack(declarationStmt);
}
 
Example 13
Source File: Reader.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
private void transformProgram(JsonML element, Node parent)
    throws JsonMLException {
  Preconditions.checkNotNull(parent);
  insertExprResultState = true;

  Node script = IR.script();
  parent.addChildToBack(script);

  for (JsonML child : element.getChildren()) {
    transformElement(child, script);
  }
}
 
Example 14
Source File: JsDocInfoParser.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
private Node createTemplateNode() {
  // The Node type choice is arbitrary.
  Node templateNode = IR.script();
  templateNode.setStaticSourceFile(
    this.associatedNode != null ?
    this.associatedNode.getStaticSourceFile() :
    null);
  return templateNode;
}
 
Example 15
Source File: SyntheticAst.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void clearAst() {
  root = IR.script();
  root.setInputId(inputId);
  root.setStaticSourceFile(sourceFile);
}