src/com/google/javascript/jscomp/gwt/client/GwtRunner.java
/** Generates the output code, taking into account the passed {@code flags}. */
Generates the output code, taking into account the passed  flags.
Generates the output code taking into account the passed flags .
private static ChunkOutput writeChunkOutput(
      Compiler compiler, Flags flags, List<JSModule> chunks) {
    ArrayList<File> outputFiles = new ArrayList<>();
    ChunkOutput output = new ChunkOutput();
    Map<String, String> parsedModuleWrappers =
        parseModuleWrappers(Arrays.asList(getStringArray(flags, "chunkWrapper")), chunks);
    for (JSModule c : chunks) {
      if (flags.createSourceMap != null && !flags.createSourceMap.equals(false)) {
        compiler.getSourceMap().reset();
      }
      File file = new File();
      file.path = flags.chunkOutputPathPrefix + c.getName() + ".js";
      String code = compiler.toSource(c);
      int lastSeparatorIndex = file.path.lastIndexOf('/');
      if (lastSeparatorIndex < 0) {
        lastSeparatorIndex = file.path.lastIndexOf('\\');
      }
      String baseName = file.path.substring(Math.max(0, lastSeparatorIndex));
      String wrapper = parsedModuleWrappers.get(c.getName()).replace("%basename%", baseName);
      StringBuilder out = new StringBuilder();
      int pos = wrapper.indexOf("%s");
      if (pos != -1) {
        String prefix = "";
        if (pos > 0) {
          prefix = wrapper.substring(0, pos);
          out.append(prefix);
        }
        out.append(code);
        int suffixStart = pos + "%s".length();
        if (suffixStart != wrapper.length()) {
          out.append(wrapper, suffixStart, wrapper.length());
        }
        out.append('\n');
        if (compiler != null && compiler.getSourceMap() != null) {
          compiler.getSourceMap().setWrapperPrefix(prefix);
        }
      } else {
        out.append(code);
        out.append('\n');
      }
      file.src = out.toString();
      if (flags.createSourceMap != null && !flags.createSourceMap.equals(false)) {
        StringBuilder b = new StringBuilder();
        try {
          compiler.getSourceMap().appendTo(b, file.path);
        } catch (IOException e) {
        }
        file.sourceMap = b.toString();
      }
      outputFiles.add(file);
    }
    output.compiledFiles = outputFiles.toArray(new File[0]);
    return output;
  }
private static ChunkOutput writeChunkOutput ( Compiler compiler , Flags flags , List < JSModule > chunks ) { ArrayList < File > outputFiles = new ArrayList < > ( ) ; ChunkOutput output = new ChunkOutput ( ) ; Map < String , String > parsedModuleWrappers = parseModuleWrappers ( Arrays . asList ( getStringArray ( flags , "chunkWrapper" ) ) , chunks ) ; for ( JSModule c : chunks ) { if ( flags . createSourceMap != null && ! flags . createSourceMap . equals ( false ) ) { compiler . getSourceMap ( ) . reset ( ) ; } File file = new File ( ) ; file . path = flags . chunkOutputPathPrefix + c . getName ( ) + ".js" ; String code = compiler . toSource ( c ) ; int lastSeparatorIndex = file . path . lastIndexOf ( '/' ) ; if ( lastSeparatorIndex < 0 ) { lastSeparatorIndex = file . path . lastIndexOf ( '\\' ) ; } String baseName = file . path . substring ( Math . max ( 0 , lastSeparatorIndex ) ) ; String wrapper = parsedModuleWrappers . get ( c . getName ( ) ) . replace ( "%basename%" , baseName ) ; StringBuilder out = new StringBuilder ( ) ; int pos = wrapper . indexOf ( "%s" ) ; if ( pos != - 1 ) { String prefix = "" ; if ( pos > 0 ) { prefix = wrapper . substring ( 0 , pos ) ; out . append ( prefix ) ; } out . append ( code ) ; int suffixStart = pos + "%s" . length ( ) ; if ( suffixStart != wrapper . length ( ) ) { out . append ( wrapper , suffixStart , wrapper . length ( ) ) ; } out . append ( '\n' ) ; if ( compiler != null && compiler . getSourceMap ( ) != null ) { compiler . getSourceMap ( ) . setWrapperPrefix ( prefix ) ; } } else { out . append ( code ) ; out . append ( '\n' ) ; } file . src = out . toString ( ) ; if ( flags . createSourceMap != null && ! flags . createSourceMap . equals ( false ) ) { StringBuilder b = new StringBuilder ( ) ; try { compiler . getSourceMap ( ) . appendTo ( b , file . path ) ; } catch ( IOException e ) { } file . sourceMap = b . toString ( ) ; } outputFiles . add ( file ) ; } output . compiledFiles = outputFiles . toArray ( new File [ 0 ] ) ; return output ; }
Generates the output code, taking into account the passed {@code flags}.
Generates the output code taking into account the passed { @code flags } .
// Something after placeholder? // Make sure we always end output with a line feed. // If we have a source map, adjust its offsets to match // the code WITHIN the wrapper. // ignore