src/com/google/javascript/jscomp/AbstractCommandLineRunner.java
/**
   * Creates inputs from a list of source files, zips and json files.
   *
   * <p>Can be overridden by subclasses who want to pull files from different places.
   *
   * @param files A list of flag entries indicates js and zip file names
   * @param jsonFiles A list of json encoded files.
   * @param allowStdIn Whether '-' is allowed appear as a filename to represent stdin. If true, '-'
   *     is only allowed to appear once.
   * @param jsModuleSpecs A list js module specs.
   * @return An array of inputs
   */
Creates inputs from a list of source files, zips and json files.
Can be overridden by subclasses who want to pull files from different places.

@param files A list of flag entries indicates js and zip file names
@param jsonFiles A list of json encoded files.
@param allowStdIn Whether '-' is allowed appear as a filename to represent stdin. If true, '-'
is only allowed to appear once.
@param jsModuleSpecs A list js module specs.
@return An array of inputs
Creates inputs from a list of source files zips and json files . Can be overridden by subclasses who want to pull files from different places . @param files A list of flag entries indicates js and zip file names @param jsonFiles A list of json encoded files . @param allowStdIn Whether ' - ' is allowed appear as a filename to represent stdin . If true ' - ' is only allowed to appear once . @param jsModuleSpecs A list js module specs . @return An array of inputs
@GwtIncompatible("Unnecessary")
  protected List<SourceFile> createInputs(
      List<FlagEntry<JsSourceType>> files,
      List<JsonFileSpec> jsonFiles,
      boolean allowStdIn,
      List<JsModuleSpec> jsModuleSpecs)
      throws IOException {
    List<SourceFile> inputs = new ArrayList<>(files.size());
    boolean usingStdin = false;
    int jsModuleIndex = 0;
    JsModuleSpec jsModuleSpec = Iterables.getFirst(jsModuleSpecs, null);
    int cumulatedInputFilesExpected =
        jsModuleSpec == null ? Integer.MAX_VALUE : jsModuleSpec.getNumInputs();
    for (int i = 0; i < files.size(); i++) {
      FlagEntry<JsSourceType> file = files.get(i);
      String filename = file.value;
      if (file.flag == JsSourceType.JS_ZIP) {
        if (!"-".equals(filename)) {
          List<SourceFile> newFiles = SourceFile.fromZipFile(filename, inputCharset);
          if (rootRelativePathsMap.containsKey(filename)) {
            String rootFilename = rootRelativePathsMap.get(filename);
            for (SourceFile zipEntry : newFiles) {
              String zipEntryName = zipEntry.getName();
              checkState(zipEntryName.contains(filename));
              String zipmap = zipEntryName.replace(filename, rootFilename);
              rootRelativePathsMap.put(zipEntryName, zipmap);
            }
          }
          inputs.addAll(newFiles);
          if (jsModuleSpec != null) {
            jsModuleSpec.numJsFiles += newFiles.size() - 1;
          }
        }
      } else if (!"-".equals(filename)) {
        SourceKind kind = file.flag == JsSourceType.WEAKDEP ? SourceKind.WEAK : SourceKind.STRONG;
        SourceFile newFile = SourceFile.fromFile(filename, inputCharset, kind);
        inputs.add(newFile);
      } else {
        if (!allowStdIn) {
          throw new FlagUsageException("Can't specify stdin.");
        }
        if (usingStdin) {
          throw new FlagUsageException("Can't specify stdin twice.");
        }
        if (!config.outputManifests.isEmpty()) {
          throw new FlagUsageException(
              "Manifest files cannot be generated when the input is from stdin.");
        }
        if (!config.outputBundles.isEmpty()) {
          throw new FlagUsageException(
              "Bundle files cannot be generated when the input is from stdin.");
        }
        this.err.println(WAITING_FOR_INPUT_WARNING);
        inputs.add(SourceFile.fromInputStream("stdin", this.in, inputCharset));
        usingStdin = true;
      }
      if (i >= cumulatedInputFilesExpected - 1) {
        jsModuleIndex++;
        if (jsModuleIndex < jsModuleSpecs.size()) {
          jsModuleSpec = jsModuleSpecs.get(jsModuleIndex);
          cumulatedInputFilesExpected += jsModuleSpec.getNumInputs();
        }
      }
    }
    if (jsonFiles != null) {
      for (JsonFileSpec jsonFile : jsonFiles) {
        inputs.add(SourceFile.fromCode(jsonFile.getPath(), jsonFile.getSrc()));
      }
    }
    for (JSError error : removeDuplicateZipEntries(inputs, jsModuleSpecs)) {
      compiler.report(error);
    }
    return inputs;
  }
@ GwtIncompatible ( "Unnecessary" ) protected List < SourceFile > createInputs ( List < FlagEntry < JsSourceType > > files , List < JsonFileSpec > jsonFiles , boolean allowStdIn , List < JsModuleSpec > jsModuleSpecs ) throws IOException { List < SourceFile > inputs = new ArrayList < > ( files . size ( ) ) ; boolean usingStdin = false ; int jsModuleIndex = 0 ; JsModuleSpec jsModuleSpec = Iterables . getFirst ( jsModuleSpecs , null ) ; int cumulatedInputFilesExpected = jsModuleSpec == null ? Integer . MAX_VALUE : jsModuleSpec . getNumInputs ( ) ; for ( int i = 0 ; i < files . size ( ) ; i ++ ) { FlagEntry < JsSourceType > file = files . get ( i ) ; String filename = file . value ; if ( file . flag == JsSourceType . JS_ZIP ) { if ( ! "-" . equals ( filename ) ) { List < SourceFile > newFiles = SourceFile . fromZipFile ( filename , inputCharset ) ; if ( rootRelativePathsMap . containsKey ( filename ) ) { String rootFilename = rootRelativePathsMap . get ( filename ) ; for ( SourceFile zipEntry : newFiles ) { String zipEntryName = zipEntry . getName ( ) ; checkState ( zipEntryName . contains ( filename ) ) ; String zipmap = zipEntryName . replace ( filename , rootFilename ) ; rootRelativePathsMap . put ( zipEntryName , zipmap ) ; } } inputs . addAll ( newFiles ) ; if ( jsModuleSpec != null ) { jsModuleSpec . numJsFiles += newFiles . size ( ) - 1 ; } } } else if ( ! "-" . equals ( filename ) ) { SourceKind kind = file . flag == JsSourceType . WEAKDEP ? SourceKind . WEAK : SourceKind . STRONG ; SourceFile newFile = SourceFile . fromFile ( filename , inputCharset , kind ) ; inputs . add ( newFile ) ; } else { if ( ! allowStdIn ) { throw new FlagUsageException ( "Can't specify stdin." ) ; } if ( usingStdin ) { throw new FlagUsageException ( "Can't specify stdin twice." ) ; } if ( ! config . outputManifests . isEmpty ( ) ) { throw new FlagUsageException ( "Manifest files cannot be generated when the input is from stdin." ) ; } if ( ! config . outputBundles . isEmpty ( ) ) { throw new FlagUsageException ( "Bundle files cannot be generated when the input is from stdin." ) ; } this . err . println ( WAITING_FOR_INPUT_WARNING ) ; inputs . add ( SourceFile . fromInputStream ( "stdin" , this . in , inputCharset ) ) ; usingStdin = true ; } if ( i >= cumulatedInputFilesExpected - 1 ) { jsModuleIndex ++ ; if ( jsModuleIndex < jsModuleSpecs . size ( ) ) { jsModuleSpec = jsModuleSpecs . get ( jsModuleIndex ) ; cumulatedInputFilesExpected += jsModuleSpec . getNumInputs ( ) ; } } } if ( jsonFiles != null ) { for ( JsonFileSpec jsonFile : jsonFiles ) { inputs . add ( SourceFile . fromCode ( jsonFile . getPath ( ) , jsonFile . getSrc ( ) ) ) ; } } for ( JSError error : removeDuplicateZipEntries ( inputs , jsModuleSpecs ) ) { compiler . report ( error ) ; } return inputs ; }
Creates inputs from a list of source files, zips and json files.
Creates inputs from a list of source files zips and json files .
// Update the manifest maps for new zip entries.