@@ -6,14 +6,13 @@ import { removeCstBlankLine } from "./preprocess.js";
6
6
import Context from "./transforms/context.js" ;
7
7
import { transformError } from "./transforms/error.js" ;
8
8
import { type Root } from "./types.js" ;
9
- import { addOrigRange } from "./utils/add-orig-range.js" ;
10
9
import { removeFakeNodes } from "./utils/remove-fake-nodes.js" ;
11
10
import { updatePositions } from "./utils/update-positions.js" ;
12
11
13
12
export function parse ( text : string ) : Root {
14
13
const cst = parseCST ( text ) ;
15
-
16
- addOrigRange ( cst ) ;
14
+ const context = new Context ( cst , text ) ;
15
+ context . setOrigRanges ( ) ;
17
16
18
17
const documents = cst . map ( cstDocument =>
19
18
new Document ( {
@@ -22,8 +21,6 @@ export function parse(text: string): Root {
22
21
} ) . parse ( cstDocument ) ,
23
22
) ;
24
23
25
- const context = new Context ( cst , text ) ;
26
-
27
24
for ( const document of documents ) {
28
25
for ( const error of document . errors ) {
29
26
if (
@@ -39,7 +36,7 @@ export function parse(text: string): Root {
39
36
documents . forEach ( document => removeCstBlankLine ( document . cstNode ! ) ) ;
40
37
41
38
const root = createRoot (
42
- context . transformRange ( { origStart : 0 , origEnd : context . text . length } ) ,
39
+ context . transformRange ( { origStart : 0 , origEnd : text . length } ) ,
43
40
documents . map ( document => context . transformNode ( document ) ) ,
44
41
context . comments ,
45
42
) ;
0 commit comments