When a statement must be inserted after another statement (as in e.g. export const varName = …; → const varName = …;$h_once.varName(varName);), the inserted statement follows any trailing comment, even if the comment is logically associated with a later node.
This is a problem of the sort for which concrete syntax representation such as that of https://github.com/estree/estree/pull/107 would be desirable, but we don't necessary need to go that far here.
Describe the bug
When a statement must be inserted after another statement (as in e.g.
export const varName = …;
→const varName = …;$h_once.varName(varName);
), the inserted statement follows any trailing comment, even if the comment is logically associated with a later node.Example
https://github.com/Agoric/dapp-offer-up/blob/774d1826eb54487e3401fe8f07db68b89f790820/contract/src/start-game1-proposal.js#L102
becomes
(with the
$h_once.startGameContract(startGameContract)
placed after the doc comment for the next statement)Expected behavior
The new statement should be inserted before any trailing comment.
Additional context
This is a problem of the sort for which concrete syntax representation such as that of https://github.com/estree/estree/pull/107 would be desirable, but we don't necessary need to go that far here.