Closed
Description
Consider the following code:
// a
var q = /*b*/ //c
/*d*/ 1 /*e*/ //f
/*g*/ + /*h*/ //i
/*j*/ 2 /*k*/ //l
/*m*/; /*n*/ //o
Suppose we extract the range from 1
to 2
(inclusive) into a separate function. We would like comments e-j to move to the new function and the others to remain where they are:
// a
var q = /*b*/ //c
/*d*/ newFunction() /*k*/ //l
/*m*/; /*n*/ //o
function newFunction() {
return 1 /*e*/ //f
/*g*/ + /*h*/ //i
/*j*/ 2;
}
Presently, there doesn't seem to be a way to express this. We can cause the leading and trailing trivia to remain at the call site by replacing a range ({pos: expr.getStart(), end: expr.end}
), rather than a node (expr
), but there doesn't seem to be a way to strip the leading and trailing trivia in the body of the extracted function.