You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Working on the PR that enables support of source-maps for peggyjs parsers I found that high-level SourceNode API is not documented enough. In particular, it is non-obvious would SourceNode constructor automatically recalculate lines if chunk parameter is a multi-line string?
I have the following simplified code for generating source-map:
letuserSourceCodeInGrammar=`potentially multi line string`;// Actual SourceNode used for mapping is behind a hierarchy of SourceNodesletnode=newSourceNode(null,null,grammarSource,["some code before",// actual mappingnewSourceNode(line,column,grammarSource,userSourceCodeInGrammar),"some code after",]);let{ code, map }=node.toStringWithSourceMap();
In the result, the code contains content of the userSourceCodeInGrammar as-is, but map maps all strings in it to the (line, column) supplied to the SourceNode constructor.
How to correctly work with multi-line code chunks?
The text was updated successfully, but these errors were encountered:
Working on the PR that enables support of source-maps for peggyjs parsers I found that high-level
SourceNode
API is not documented enough. In particular, it is non-obvious wouldSourceNode
constructor automatically recalculate lines ifchunk
parameter is a multi-line string?I have the following simplified code for generating source-map:
In the result, the
code
contains content of theuserSourceCodeInGrammar
as-is, butmap
maps all strings in it to the(line, column)
supplied to theSourceNode
constructor.How to correctly work with multi-line code chunks?
The text was updated successfully, but these errors were encountered: