[JS] Make sourcemaps more precise wrt JS syntax

- Generate mappings for function parameters
- Don't generate debug info for dots in qualified references
- A location of a JsNameRef is considered the start of the rightmost
  name
This commit is contained in:
Sergej Jaskiewicz
2022-11-01 19:19:11 +01:00
committed by Space Team
parent 4515130bfc
commit 8efa72ca36
5 changed files with 34 additions and 15 deletions
@@ -673,10 +673,12 @@ public class JsToStringGenerationVisitor extends JsVisitor {
pushSourceInfo(x.getSource());
leftParen();
boolean notFirst = false;
sourceLocationConsumer.pushSourceInfo(null);
for (JsParameter param : x.getParameters()) {
notFirst = sepCommaOptSpace(notFirst);
accept(param);
}
sourceLocationConsumer.popSourceInfo();
rightParen();
space();
@@ -845,8 +847,9 @@ public class JsToStringGenerationVisitor extends JsVisitor {
}
public void visitNameRef(@NotNull JsNameRef nameRef, boolean withQualifier) {
pushSourceInfo(nameRef.getSource());
printCommentsBeforeNode(nameRef);
p.maybeIndent();
JsExpression qualifier = nameRef.getQualifier();
if (qualifier != null && withQualifier) {
@@ -869,11 +872,11 @@ public class JsToStringGenerationVisitor extends JsVisitor {
p.print('.');
}
p.maybeIndent();
pushSourceInfo(nameRef.getSource());
p.print(nameRef.getIdent());
popSourceInfo();
printCommentsAfterNode(nameRef);
popSourceInfo();
}
@Override
@@ -1004,7 +1007,9 @@ public class JsToStringGenerationVisitor extends JsVisitor {
@Override
public void visitParameter(@NotNull JsParameter x) {
pushSourceInfo(x.getSource());
nameOf(x);
popSourceInfo();
}
@Override