ASEmitter, JSEmitter: fixed issue where line and column numbers could be wrong when stringifyNode() is used and source map offset could be wrong too
Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/1753f4e2 Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/1753f4e2 Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/1753f4e2 Branch: refs/heads/develop Commit: 1753f4e238f8523b5f3fb367d8ba745cb54d268d Parents: 838a0fc Author: Josh Tynjala <joshtynj...@gmail.com> Authored: Mon Oct 17 15:18:43 2016 -0700 Committer: Josh Tynjala <joshtynj...@gmail.com> Committed: Mon Oct 17 15:18:43 2016 -0700 ---------------------------------------------------------------------- .../compiler/internal/codegen/as/ASEmitter.java | 22 ++++++++++++-------- .../compiler/internal/codegen/js/JSEmitter.java | 8 +++++++ 2 files changed, 21 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/1753f4e2/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/as/ASEmitter.java ---------------------------------------------------------------------- diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/as/ASEmitter.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/as/ASEmitter.java index 6f48f8e..f25d6c9 100644 --- a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/as/ASEmitter.java +++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/as/ASEmitter.java @@ -220,20 +220,24 @@ public class ASEmitter implements IASEmitter, IEmitter { try { - int newLineCount = value.length() - value.replace("\n", "").length(); - currentLine += newLineCount; - if (newLineCount > 0) + if (!bufferWrite) { - currentColumn = value.length() - value.lastIndexOf("\n") - 1; + int newLineCount = value.length() - value.replace("\n", "").length(); + currentLine += newLineCount; + if (newLineCount > 0) + { + currentColumn = value.length() - value.lastIndexOf("\n") - 1; + } + else + { + currentColumn += value.length(); + } + out.write(value); } else { - currentColumn += value.length(); - } - if (!bufferWrite) - out.write(value); - else builder.append(value); + } } catch (IOException e) { http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/1753f4e2/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/JSEmitter.java ---------------------------------------------------------------------- diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/JSEmitter.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/JSEmitter.java index 94155df..5b1f770 100644 --- a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/JSEmitter.java +++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/JSEmitter.java @@ -387,6 +387,10 @@ public class JSEmitter extends ASEmitter implements IJSEmitter public void startMapping(ISourceLocation node, int line, int column) { + if (isBufferWrite()) + { + return; + } if (lastMapping != null) { FilePosition sourceStartPosition = lastMapping.sourceStartPosition; @@ -428,6 +432,10 @@ public class JSEmitter extends ASEmitter implements IJSEmitter public void endMapping(ISourceLocation node) { + if (isBufferWrite()) + { + return; + } if (lastMapping == null) { throw new IllegalStateException("Cannot end mapping when a mapping has not been started");