Fix JS source maps for string literals

This commit is contained in:
Alexey Andreev
2017-05-10 20:21:20 +03:00
parent 8dae399945
commit 9692c02f6e
3 changed files with 14 additions and 1 deletions
@@ -132,6 +132,12 @@ public class JsLineNumberTestGenerated extends AbstractJsLineNumberTest {
doTest(fileName);
}
@TestMetadata("stringLiteral.kt")
public void testStringLiteral() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/lineNumbers/stringLiteral.kt");
doTest(fileName);
}
@TestMetadata("syntheticCodeInConstructors.kt")
public void testSyntheticCodeInConstructors() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/lineNumbers/syntheticCodeInConstructors.kt");
@@ -320,7 +320,7 @@ public final class ExpressionVisitor extends TranslatorVisitor<JsNode> {
public JsNode visitStringTemplateExpression(@NotNull KtStringTemplateExpression expression, @NotNull TranslationContext context) {
JsStringLiteral stringLiteral = resolveAsStringConstant(expression, context);
if (stringLiteral != null) {
return stringLiteral;
return stringLiteral.source(expression);
}
return resolveAsTemplate(expression, context).source(expression);
}
@@ -0,0 +1,7 @@
fun box(x: Int): String {
return "" +
x +
"suffix"
}
// LINES: 2 3 4