if (compiler != null && compiler.getSourceMap() != null) { compiler.getSourceMap().setWrapperPrefix(prefix);
private synchronized void addFilesToSourceMap(Iterable<? extends SourceFile> files) { // synchronized annotation guards concurrent access to sourceMap during parsing. if (getOptions().sourceMapIncludeSourcesContent && getSourceMap() != null) { for (SourceFile file : files) { try { getSourceMap().addSourceFile(file.getName(), file.getCode()); } catch (IOException e) { throw new RuntimeException("Cannot read code of a source map's source file.", e); } } } }
if (compiler != null && compiler.getSourceMap() != null) { compiler.getSourceMap().setWrapperPrefix(prefix);
compiler_.getSourceMap().appendTo(sourceMapFile, ""); sourceMapFile.close();
/** Given an output module, convert it to a JSONFileSpec with associated sourcemap */ @GwtIncompatible("Unnecessary") private JsonFileSpec createJsonFileFromModule(JSModule module) throws IOException { compiler.getSourceMap().reset(); StringBuilder output = new StringBuilder(); writeModuleOutput(output, module); JsonFileSpec jsonFile = new JsonFileSpec(output.toString(), getModuleOutputFileName(module)); StringBuilder moduleSourceMap = new StringBuilder(); compiler.getSourceMap().appendTo(moduleSourceMap, getModuleOutputFileName(module)); jsonFile.setSourceMap(moduleSourceMap.toString()); return jsonFile; }
/** * Given an output module, convert it to a JSONFileSpec with associated * sourcemap */ private JsonFileSpec createJsonFileFromModule(JSModule module) throws FlagUsageException, IOException{ compiler.getSourceMap().reset(); StringBuilder output = new StringBuilder(); writeModuleOutput(output, module); JsonFileSpec jsonFile = new JsonFileSpec(output.toString(), getModuleOutputFileName(module)); StringBuilder moduleSourceMap = new StringBuilder(); compiler.getSourceMap().appendTo(moduleSourceMap, getModuleOutputFileName(module)); jsonFile.setSourceMap(moduleSourceMap.toString()); return jsonFile; }
/** Save the compiler output to a JsonFileSpec to be later written to stdout */ @GwtIncompatible("Unnecessary") JsonFileSpec createJsonFile(B options, String outputMarker, Function<String, String> escaper) throws IOException { Appendable jsOutput = new StringBuilder(); writeOutput( jsOutput, compiler, (JSModule) null, config.outputWrapper, outputMarker, escaper); JsonFileSpec jsonOutput = new JsonFileSpec(jsOutput.toString(), Strings.isNullOrEmpty(config.jsOutputFile) ? "compiled.js" : config.jsOutputFile); if (!Strings.isNullOrEmpty(options.sourceMapOutputPath)) { StringBuilder sourcemap = new StringBuilder(); compiler.getSourceMap().appendTo(sourcemap, jsonOutput.getPath()); jsonOutput.setSourceMap(sourcemap.toString()); } return jsonOutput; }
/** * Save the compiler output to a JsonFileSpec to be later written to * stdout */ JsonFileSpec createJsonFile(B options, String outputMarker, Function<String, String> escaper) throws IOException { Appendable jsOutput = new StringBuilder(); writeOutput( jsOutput, compiler, compiler.toSource(), config.outputWrapper, outputMarker, escaper); JsonFileSpec jsonOutput = new JsonFileSpec(jsOutput.toString(), Strings.isNullOrEmpty(config.jsOutputFile) ? "compiled.js" : config.jsOutputFile); if (!Strings.isNullOrEmpty(options.sourceMapOutputPath)) { StringBuilder sourcemap = new StringBuilder(); compiler.getSourceMap().appendTo(sourcemap, jsonOutput.getPath()); jsonOutput.setSourceMap(sourcemap.toString()); } return jsonOutput; }
/** * Outputs the source map found in the compiler to the proper path if one exists. * * @param options The options to the Compiler. */ @GwtIncompatible("Unnecessary") private void outputSourceMap(B options, String associatedName) throws IOException { if (Strings.isNullOrEmpty(options.sourceMapOutputPath) || options.sourceMapOutputPath.equals("/dev/null")) { return; } String outName = expandSourceMapPath(options, null); maybeCreateDirsForPath(outName); try (Writer out = fileNameToOutputWriter2(outName)) { compiler.getSourceMap().appendTo(out, associatedName); } }
final String getCurrentJsSource() { SourceMap sourceMap = getSourceMap(); if (sourceMap != null) { sourceMap.reset();
/** * Outputs the source map found in the compiler to the proper path if one * exists. * * @param options The options to the Compiler. */ private void outputSourceMap(B options, String associatedName) throws IOException { if (Strings.isNullOrEmpty(options.sourceMapOutputPath)) { return; } String outName = expandSourceMapPath(options, null); maybeCreateDirsForPath(outName); Writer out = fileNameToOutputWriter2(outName); try { compiler.getSourceMap().appendTo(out, associatedName); } finally { out.close(); } }
compiler_.getSourceMap().appendTo(sourceMapFile, ""); sourceMapFile.close();
flushSourceMap(sourceMapResult, minifiedFile.getName(), compiler.getSourceMap());
flushSourceMap(sourceMapResult, minifiedFile.getName(), compiler.getSourceMap());
createSourceMapFile(output,compiler.getSourceMap());
try { if (options.sourceMapOutputPath != null) { compiler.getSourceMap().reset(); compiler.getSourceMap().appendTo(mapFileOut, moduleFilename);
try (Writer writer = fileNameToLegacyOutputWriter(moduleFilename)) { if (options.sourceMapOutputPath != null) { compiler.getSourceMap().reset(); compiler.getSourceMap().appendTo(mapFileOut, moduleFilename);
compiler.getSourceMap().appendTo(writer, args.outputFile.getPath()); writer.close(); System.out.println("Wrote: " + args.sourceMap.getAbsolutePath());