Examples of SourceMapGeneratorV3


Examples of com.google.debugging.sourcemap.SourceMapGeneratorV3

        compiler.getSourceLine(origSourceName, 1));
  }

  private SourceMapInput sourcemap(String sourceMapPath, String originalSource,
      FilePosition originalSourcePosition) throws Exception {
    SourceMapGeneratorV3 sourceMap = new SourceMapGeneratorV3();
    sourceMap.addMapping(originalSource, null, originalSourcePosition,
        new FilePosition(1, 1), new FilePosition(100, 1));
    StringBuilder output = new StringBuilder();
    sourceMap.appendTo(output, "unused.js");

    return new SourceMapInput(
        SourceFile.fromCode(sourceMapPath, output.toString()));
  }
View Full Code Here

Examples of com.google.debugging.sourcemap.SourceMapGeneratorV3

    assertEquals("Hello", msg.getDesc());
    assertEquals("[testcode]", msg.getSourceName());
  }

  public void testJsMessagesWithSrcMap() throws Exception {
    SourceMapGeneratorV3 sourceMap = new SourceMapGeneratorV3();
    sourceMap.addMapping("source1.html", null, new FilePosition(10, 0),
        new FilePosition(0, 0), new FilePosition(0, 100));
    sourceMap.addMapping("source2.html", null, new FilePosition(10, 0),
        new FilePosition(1, 0), new FilePosition(1, 100));
    StringBuilder output = new StringBuilder();
    sourceMap.appendTo(output, "unused.js");

    compilerOptions = new CompilerOptions();
    compilerOptions.inputSourceMaps = ImmutableMap.of(
       "[testcode]", new SourceMapInput(
           SourceFile.fromCode("example.srcmap", output.toString())));
View Full Code Here

Examples of com.google.gwt.thirdparty.debugging.sourcemap.SourceMapGeneratorV3

  private String javascript;

  @Override
  protected void setUp() throws Exception {
    super.setUp();
    generator = new SourceMapGeneratorV3();
    writer = new SourceMappingWriter(generator);
  }
View Full Code Here

Examples of com.google.gwt.thirdparty.debugging.sourcemap.SourceMapGeneratorV3

  private List<SyntheticArtifact> createArtifacts()
      throws IOException, SourceMapParseException {
    Event event = SpeedTracerLogger.start(CompilerEventType.SOURCE_MAP_RECORDER);
    List<SyntheticArtifact> toReturn = Lists.newArrayList();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    SourceMapGeneratorV3 generator = new SourceMapGeneratorV3();
    int fragment = 0;
    for (JsSourceMap sourceMap : fragmentMaps) {
      generator.reset();

      if (sourceRoot != null) {
        generator.setSourceRoot(sourceRoot);
      }
      addExtensions(generator, fragment);
      addMappings(new SourceMappingWriter(generator), sourceMap);

      baos.reset();
      OutputStreamWriter out = new OutputStreamWriter(baos);
      generator.appendTo(out, "sourceMap" + fragment);
      out.flush();
      toReturn.add(new SymbolMapsLinker.SourceMapArtifact(permutationId, fragment,
          baos.toByteArray(), sourceRoot));
      fragment++;
    }
View Full Code Here

Examples of com.google.gwt.thirdparty.debugging.sourcemap.SourceMapGeneratorV3

        SyntheticArtifact emArt = null;
        // no need to adjust source map
        if (editArtifact == null) {
          emArt = emitSourceMapString(logger, sourceMapString, partialPath);
        } else {
          SourceMapGeneratorV3 sourceMapGenerator = new SourceMapGeneratorV3();

          if (se.getSourceRoot() != null) {
            // Reapply source root since mergeMapSection() will not copy it.
            sourceMapGenerator.setSourceRoot(se.getSourceRoot());
          }

          try {
            int totalPrefixLines = 0;
            for (ScriptFragmentEditsArtifact.EditOperation op : editArtifact.editOperations) {
              if (op.getOp() == ScriptFragmentEditsArtifact.Edit.PREFIX) {
                totalPrefixLines += op.getNumLines();
              }
            }
            // TODO(cromwellian): apply insert and remove edits
            sourceMapGenerator.mergeMapSection(totalPrefixLines, 0, sourceMapString,
                new ExtensionMergeAction() {
                  @Override
                  public Object merge(String extKey, Object oldVal, Object newVal) {
                    return newVal;
                  }
                });
            StringWriter stringWriter = new StringWriter();
            sourceMapGenerator.appendTo(stringWriter, "sourceMap");
            emArt = emitSourceMapString(logger, stringWriter.toString(), partialPath);
          } catch (Exception e) {
            logger.log(TreeLogger.Type.WARN, "Can't write source map " + partialPath, e);
          }
        }
View Full Code Here

Examples of com.google.gwt.thirdparty.debugging.sourcemap.SourceMapGeneratorV3

  protected List<SyntheticArtifact> recordSourceMap(List<JsSourceMap> sourceInfoMaps)
      throws IOException, JSONException, SourceMapParseException {
    List<SyntheticArtifact> toReturn = Lists.newArrayList();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    SourceMapGeneratorV3 generator = new SourceMapGeneratorV3();
    int fragment = 0;
    if (!sourceInfoMaps.isEmpty()) {
      for (JsSourceMap sourceMap : sourceInfoMaps) {
        generator.reset();
        addMappings(new SourceMappingWriter(generator), sourceMap);
        updateSourceMap(generator, fragment);

        baos.reset();
        OutputStreamWriter out = new OutputStreamWriter(baos);
        generator.appendTo(out, "sourceMap" + fragment);
        out.flush();
        toReturn.add(new SymbolMapsLinker.SourceMapArtifact(permutationId, fragment,
            baos.toByteArray()));
        fragment++;
      }
View Full Code Here

Examples of com.google.gwt.thirdparty.debugging.sourcemap.SourceMapGeneratorV3

        SyntheticArtifact emArt = null;
        // no need to adjust source map
        if (editArtifact == null) {
          emArt = emitSourceMapString(logger, sourceMapString, partialPath);
        } else {
          SourceMapGeneratorV3 sourceMapGenerator = new SourceMapGeneratorV3();
          try {
            int totalPrefixLines = 0;
            for (ScriptFragmentEditsArtifact.EditOperation op : editArtifact.editOperations) {
              if (op.getOp() == ScriptFragmentEditsArtifact.Edit.PREFIX) {
                totalPrefixLines += op.getNumLines();
              }
            }
            // TODO(cromwellian): apply insert and remove edits
            sourceMapGenerator.mergeMapSection(totalPrefixLines, 0, sourceMapString,
                new ExtensionMergeAction() {
                  @Override
                  public Object merge(String extKey, Object oldVal, Object newVal) {
                    return newVal;
                  }
                });
            StringWriter stringWriter = new StringWriter();
            sourceMapGenerator.appendTo(stringWriter, "sourceMap");
            emArt = emitSourceMapString(logger, stringWriter.toString(), partialPath);
          } catch (Exception e) {
            logger.log(TreeLogger.Type.WARN, "Can't write source map " + partialPath, e);
          }
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.