Java Code Examples for com.google.javascript.rhino.JSDocInfo#isExterns()

The following examples show how to use com.google.javascript.rhino.JSDocInfo#isExterns() . 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_18_Compiler_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Hoists inputs with the @externs annotation into the externs list.
 */
private void hoistExterns(Node externsRoot) {
  boolean staleInputs = false;
  for (CompilerInput input : inputs) {
    if (options.dependencyOptions.needsManagement() &&
        options.closurePass) {
      // If we're doing scanning dependency info anyway, use that
      // information to skip sources that obviously aren't externs.
      if (!input.getProvides().isEmpty() || !input.getRequires().isEmpty()) {
        continue;
      }
    }

    Node n = input.getAstRoot(this);

    // Inputs can have a null AST on a parse error.
    if (n == null) {
      continue;
    }

    JSDocInfo info = n.getJSDocInfo();
    if (info != null && info.isExterns()) {
      // If the input file is explicitly marked as an externs file, then
      // assume the programmer made a mistake and throw it into
      // the externs pile anyways.
      externsRoot.addChildToBack(n);
      input.setIsExtern(true);

      input.getModule().remove(input);

      externs.add(input);
      staleInputs = true;
    }
  }

  if (staleInputs) {
    repartitionInputs();
  }
}
 
Example 2
Source File: Closure_18_Compiler_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * Hoists inputs with the @externs annotation into the externs list.
 */
private void hoistExterns(Node externsRoot) {
  boolean staleInputs = false;
  for (CompilerInput input : inputs) {
    if (options.dependencyOptions.needsManagement() &&
        options.closurePass) {
      // If we're doing scanning dependency info anyway, use that
      // information to skip sources that obviously aren't externs.
      if (!input.getProvides().isEmpty() || !input.getRequires().isEmpty()) {
        continue;
      }
    }

    Node n = input.getAstRoot(this);

    // Inputs can have a null AST on a parse error.
    if (n == null) {
      continue;
    }

    JSDocInfo info = n.getJSDocInfo();
    if (info != null && info.isExterns()) {
      // If the input file is explicitly marked as an externs file, then
      // assume the programmer made a mistake and throw it into
      // the externs pile anyways.
      externsRoot.addChildToBack(n);
      input.setIsExtern(true);

      input.getModule().remove(input);

      externs.add(input);
      staleInputs = true;
    }
  }

  if (staleInputs) {
    repartitionInputs();
  }
}
 
Example 3
Source File: Compiler.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Hoists inputs with the @externs annotation into the externs list.
 */
private void hoistExterns(Node externsRoot) {
  boolean staleInputs = false;
  for (CompilerInput input : inputs) {
    if (options.dependencyOptions.needsManagement()) {
      // If we're doing scanning dependency info anyway, use that
      // information to skip sources that obviously aren't externs.
      if (!input.getProvides().isEmpty() || !input.getRequires().isEmpty()) {
        continue;
      }
    }

    Node n = input.getAstRoot(this);

    // Inputs can have a null AST on a parse error.
    if (n == null) {
      continue;
    }

    JSDocInfo info = n.getJSDocInfo();
    if (info != null && info.isExterns()) {
      // If the input file is explicitly marked as an externs file, then
      // assume the programmer made a mistake and throw it into
      // the externs pile anyways.
      externsRoot.addChildToBack(n);
      input.setIsExtern(true);

      input.getModule().remove(input);

      externs.add(input);
      staleInputs = true;
    }
  }

  if (staleInputs) {
    repartitionInputs();
  }
}