@@ -6,14 +6,13 @@ import { removeCstBlankLine } from "./preprocess.js";
66import Context from "./transforms/context.js" ;
77import { transformError } from "./transforms/error.js" ;
88import { type Root } from "./types.js" ;
9- import { addOrigRange } from "./utils/add-orig-range.js" ;
109import { removeFakeNodes } from "./utils/remove-fake-nodes.js" ;
1110import { updatePositions } from "./utils/update-positions.js" ;
1211
1312export function parse ( text : string ) : Root {
1413 const cst = parseCST ( text ) ;
15-
16- addOrigRange ( cst ) ;
14+ const context = new Context ( cst , text ) ;
15+ context . setOrigRanges ( ) ;
1716
1817 const documents = cst . map ( cstDocument =>
1918 new Document ( {
@@ -22,8 +21,6 @@ export function parse(text: string): Root {
2221 } ) . parse ( cstDocument ) ,
2322 ) ;
2423
25- const context = new Context ( cst , text ) ;
26-
2724 for ( const document of documents ) {
2825 for ( const error of document . errors ) {
2926 if (
@@ -39,7 +36,7 @@ export function parse(text: string): Root {
3936 documents . forEach ( document => removeCstBlankLine ( document . cstNode ! ) ) ;
4037
4138 const root = createRoot (
42- context . transformRange ( { origStart : 0 , origEnd : context . text . length } ) ,
39+ context . transformRange ( { origStart : 0 , origEnd : text . length } ) ,
4340 documents . map ( document => context . transformNode ( document ) ) ,
4441 context . comments ,
4542 ) ;
0 commit comments