Keep JS AST source information after refreshing local names
This commit is contained in:
+3
-3
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2015 JetBrains s.r.o.
|
* Copyright 2010-2017 JetBrains s.r.o.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -22,14 +22,14 @@ class NameReplacingVisitor(private val replaceMap: Map<JsName, JsExpression>) :
|
|||||||
|
|
||||||
override fun endVisit(x: JsNameRef, ctx: JsContext<JsNode>) {
|
override fun endVisit(x: JsNameRef, ctx: JsContext<JsNode>) {
|
||||||
val replacement = replaceMap[x.name] ?: return
|
val replacement = replaceMap[x.name] ?: return
|
||||||
ctx.replaceMe(replacement.deepCopy())
|
ctx.replaceMe(replacement.deepCopy().source(x.source))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun endVisit(x: JsVars.JsVar, ctx: JsContext<JsNode>) {
|
override fun endVisit(x: JsVars.JsVar, ctx: JsContext<JsNode>) {
|
||||||
val replacement = replaceMap[x.name]
|
val replacement = replaceMap[x.name]
|
||||||
if (replacement is HasName) {
|
if (replacement is HasName) {
|
||||||
val replacementVar = JsVars.JsVar(replacement.name, x.initExpression)
|
val replacementVar = JsVars.JsVar(replacement.name, x.initExpression)
|
||||||
ctx.replaceMe(replacementVar)
|
ctx.replaceMe(replacementVar.source(x.source))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -60,6 +60,12 @@ public class JsLineNumberTestGenerated extends AbstractJsLineNumberTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("inlineLocalVarsRef.kt")
|
||||||
|
public void testInlineLocalVarsRef() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/lineNumbers/inlineLocalVarsRef.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("inlineReturn.kt")
|
@TestMetadata("inlineReturn.kt")
|
||||||
public void testInlineReturn() throws Exception {
|
public void testInlineReturn() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/lineNumbers/inlineReturn.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/lineNumbers/inlineReturn.kt");
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
inline fun foo(x: Int) {
|
||||||
|
val y = x > 23
|
||||||
|
if (y) {
|
||||||
|
println("foo")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun bar() {
|
||||||
|
foo(42)
|
||||||
|
}
|
||||||
|
|
||||||
|
// LINES: 2 3 4 * 2 9 2 3 4
|
||||||
+1
-1
@@ -21,4 +21,4 @@ fun bar(x: Int) {
|
|||||||
println("%")
|
println("%")
|
||||||
}
|
}
|
||||||
|
|
||||||
// LINES: 2 3 4 7 9 10 11 14 16 * 20 * 2 3 3 7 9 10 10 14 16 20 21
|
// LINES: 2 3 4 7 9 10 11 14 16 * 20 * 2 3 4 3 7 9 10 11 10 14 16 20 21
|
||||||
Reference in New Issue
Block a user