1- import type * as YAML from "yaml" ;
1+ import YAML from "yaml" ;
22import type * as YAMLTypes from "yaml/types" ;
33import { createPosition } from "../factories/position.js" ;
4- import type {
5- Comment ,
6- Content ,
7- ParsedCST ,
8- Point ,
9- Position ,
10- Range ,
11- } from "../types.js" ;
4+ import type { Comment , Content , Point , Position , Range } from "../types.js" ;
125import { transformContent } from "./content.js" ;
136import { transformNode , type YamlNode , type YamlToUnist } from "./transform.js" ;
147
@@ -29,29 +22,30 @@ let rangeAsLinePosGetter: RangeAsLinePosGetter;
2922class Context {
3023 text ;
3124 comments : Comment [ ] = [ ] ;
32- # cst;
25+ cst ;
3326 #cstContext: CSTContext | undefined ;
3427
35- constructor ( cst : ParsedCST , text : string ) {
28+ constructor ( text : string ) {
3629 this . text = text ;
37- this . #cst = cst ;
30+ this . cst = YAML . parseCST ( text ) ;
31+ this . setOrigRanges ( ) ;
3832 }
3933
4034 setOrigRanges ( ) {
41- if ( this . # cst. setOrigRanges ( ) ) {
35+ if ( this . cst . setOrigRanges ( ) ) {
4236 return ;
4337 }
4438
4539 // From `yaml/parse-cst`
4640 // https://github.com/eemeli/yaml/blob/4cdcde632ece71155f3108ec0120c1a0329a6914/src/cst/parse.js#L22
47- for ( const document of this . # cst) {
41+ for ( const document of this . cst ) {
4842 document . setOrigRanges ( [ ] , 0 ) ;
4943 }
5044 }
5145
5246 #getRangePosition( range : Range ) : { start : Point ; end : Point } {
5347 if ( ! rangeAsLinePosGetter ) {
54- const [ document ] = this . # cst;
48+ const [ document ] = this . cst ;
5549 const Node = Object . getPrototypeOf (
5650 Object . getPrototypeOf ( document ) ,
5751 ) as YAML . CST . Node ;
0 commit comments