How line and column of `SourceNode` instance related to the contained chunk(s)?
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
- Issue type
- Documentation
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- javascript
- Domain
- documentation
Research direction
Start with the SourceNode API and the linked source-map PR #163. Check how the constructor's line and column values are handled when a chunk contains newlines, then document the observed behavior and the recommended handling for multi-line chunks.
Written by the indexing model from the issue text.
Description
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:
let userSourceCodeInGrammar = `potentially
multi
line
string`;
// Actual SourceNode used for mapping is behind a hierarchy of SourceNodes
let node = new SourceNode(
null, null, grammarSource,
[
"some code before",
// actual mapping
new SourceNode(
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?
- Dominant language
- JavaScript
- Stars
- 3.7k
- Forks
- 370
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from mozilla/source-map
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
mozilla/source-map#530 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
mozilla/source-map#527 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
mozilla/source-map#524 · 6 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
mozilla/source-map#516 ·
-
Difficulty 5/5 Over a week Newbie friendliness 30/100
mozilla/source-map#510 · 1 reaction ·
All issues in mozilla/source-map
Similar issues
-
bug confirmed issue
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
open-webui/open-webui#30750 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Mend: dependency security vulnerability untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 70/100