Skip to content

Commit

Permalink
Add comments for sourceNode functions on TranspileState
Browse files Browse the repository at this point in the history
  • Loading branch information
TwitchBronBron committed Feb 17, 2021
1 parent 5d6c5f3 commit 951e885
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/parser/TranspileState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ export class TranspileState {
*/
public sourceNode(locatable: { range: Range }, code: string | SourceNode | Array<string | SourceNode>): SourceNode | undefined {
return new SourceNode(
//convert 0-based range line to 1-based SourceNode line
locatable.range.start.line + 1,
//range and SourceNode character are both 0-based, so no conversion necessary
locatable.range.start.character,
this.pathAbsolute,
code
Expand All @@ -85,7 +87,9 @@ export class TranspileState {
*/
public tokenToSourceNode(token: Token) {
return new SourceNode(
//convert 0-based range line to 1-based SourceNode line
token.range.start.line + 1,
//range and SourceNode character are both 0-based, so no conversion necessary
token.range.start.character,
this.pathAbsolute,
token.text
Expand Down

0 comments on commit 951e885

Please sign in to comment.