Don't merge locations in JS source map test cases

Don't merge locations of containing if/while/do..while/for
statements with locations of conditions
This commit is contained in:
Alexey Andreev
2017-06-21 16:05:23 +03:00
parent dea73ebecf
commit 2122f57f51
7 changed files with 10 additions and 6 deletions
@@ -71,6 +71,7 @@ class LineCollector : RecursiveJsVisitor() {
override fun visitIf(x: JsIf) {
withStatement(x) {
handleNodeLocation(x)
lineNumbersByStatement[x]?.add(-1)
x.ifExpression.accept(this)
}
x.thenStatement.accept(this)
@@ -80,6 +81,7 @@ class LineCollector : RecursiveJsVisitor() {
override fun visitWhile(x: JsWhile) {
withStatement(x) {
handleNodeLocation(x)
lineNumbersByStatement[x]?.add(-1)
x.condition.accept(this)
}
x.body.accept(this)
@@ -94,6 +96,8 @@ class LineCollector : RecursiveJsVisitor() {
override fun visitFor(x: JsFor) {
withStatement(x) {
handleNodeLocation(x)
lineNumbersByStatement[x]?.add(-1)
x.initExpression?.accept(this)
x.initVars?.accept(this)
x.condition?.accept(this)
@@ -89,7 +89,7 @@ class LineOutputToStringVisitor(output: TextOutput, val lineCollector: LineColle
}
else if (statement in lineCollector.lineNumbersByStatement) {
p.print("/* ")
p.print(lineCollector.lineNumbersByStatement[statement]!!.joinToString(" ") { (it + 1).toString() })
p.print(lineCollector.lineNumbersByStatement[statement]!!.filter { it >= 0 }.joinToString(" ") { (it + 1).toString() })
p.print(" */ ")
}
}
@@ -6,4 +6,4 @@ fun box(x: Int, y: Int) {
fun foo(x: Int) = x
// LINES: 3 3 * 3 4 4 * 4 4 2 3 7
// LINES: 3 3 * 3 3 4 4 * 4 4 2 3 7
+1 -1
View File
@@ -19,4 +19,4 @@ fun bar() {
}
}
// LINES: 3 5 6 8 9 * 15 18
// LINES: 3 5 5 6 8 8 9 * 15 18
+1 -1
View File
@@ -17,4 +17,4 @@ fun box() {
}
}
// LINES: 2 10 15 2 2 2 3 6 6 7 10 10 10 11 14 15 15 15 15 15 15 16
// LINES: 2 10 15 2 2 2 2 3 6 6 6 7 10 10 10 10 11 14 15 15 15 15 15 15 15 16
@@ -9,4 +9,4 @@ fun bar() {
foo(42)
}
// LINES: 2 3 4 * 2 9 2 3 4
// LINES: 2 3 3 4 * 2 9 2 3 3 4
+1 -1
View File
@@ -21,4 +21,4 @@ fun bar(x: Int) {
println("%")
}
// LINES: 2 3 4 7 9 10 11 14 16 * 20 * 2 3 4 3 7 9 10 11 10 14 16 * 20 21
// LINES: 2 2 3 4 7 9 9 10 11 14 16 * 20 * 2 2 3 4 3 7 9 9 10 11 10 14 16 * 20 21