src/com/google/javascript/jscomp/AbstractCommandLineRunner.java
/**
   * Writes code to an output stream, optionally wrapping it in an arbitrary wrapper that contains a
   * placeholder where the code should be inserted.
   */
Writes code to an output stream, optionally wrapping it in an arbitrary wrapper that contains a
placeholder where the code should be inserted.
Writes code to an output stream optionally wrapping it in an arbitrary wrapper that contains a placeholder where the code should be inserted .
@GwtIncompatible("Unnecessary")
  void writeOutput(
      Appendable out,
      Compiler compiler,
      String code,
      String wrapper,
      String codePlaceholder,
      @Nullable Function<String, String> escaper)
      throws IOException {
    int pos = wrapper.indexOf(codePlaceholder);
    if (pos != -1) {
      String prefix = "";
      if (pos > 0) {
        prefix = wrapper.substring(0, pos);
        out.append(prefix);
      }
      out.append(escaper == null ? code : escaper.apply(code));
      int suffixStart = pos + codePlaceholder.length();
      if (suffixStart != wrapper.length()) {
        out.append(wrapper.substring(suffixStart));
      }
      out.append('\n');
      if (compiler != null && compiler.getSourceMap() != null) {
        compiler.getSourceMap().setWrapperPrefix(prefix);
      }
    } else {
      out.append(code);
      out.append('\n');
    }
  }
@ GwtIncompatible ( "Unnecessary" ) void writeOutput ( Appendable out , Compiler compiler , String code , String wrapper , String codePlaceholder , @ Nullable Function < String , String > escaper ) throws IOException { int pos = wrapper . indexOf ( codePlaceholder ) ; if ( pos != - 1 ) { String prefix = "" ; if ( pos > 0 ) { prefix = wrapper . substring ( 0 , pos ) ; out . append ( prefix ) ; } out . append ( escaper == null ? code : escaper . apply ( code ) ) ; int suffixStart = pos + codePlaceholder . length ( ) ; if ( suffixStart != wrapper . length ( ) ) { out . append ( wrapper . substring ( suffixStart ) ) ; } out . append ( '\n' ) ; if ( compiler != null && compiler . getSourceMap ( ) != null ) { compiler . getSourceMap ( ) . setWrapperPrefix ( prefix ) ; } } else { out . append ( code ) ; out . append ( '\n' ) ; } }
Writes code to an output stream, optionally wrapping it in an arbitrary wrapper that contains a
 placeholder where the code should be inserted.
Writes code to an output stream optionally wrapping it in an arbitrary wrapper that contains a placeholder where the code should be inserted .
// 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.