@@ -45,6 +45,7 @@ export class Walker extends EventEmitter<Dictionary<WalkerEventHandler, WalkerEv
45
45
this . path . splice ( 0 , this . path . length , ...snapshot . path ) ;
46
46
this . depth = snapshot . depth ;
47
47
this . fragment = snapshot . fragment ;
48
+ this . schemaNode = snapshot . schemaNode ;
48
49
49
50
yield * this . walk ( ) ;
50
51
}
@@ -53,6 +54,7 @@ export class Walker extends EventEmitter<Dictionary<WalkerEventHandler, WalkerEv
53
54
return {
54
55
depth : this . depth ,
55
56
fragment : this . fragment ,
57
+ schemaNode : this . schemaNode ,
56
58
path : this . path . slice ( ) ,
57
59
} ;
58
60
}
@@ -61,6 +63,13 @@ export class Walker extends EventEmitter<Dictionary<WalkerEventHandler, WalkerEv
61
63
this . hooks [ action ] = handler ;
62
64
}
63
65
66
+ public restoreWalkerAtNode ( node : RegularNode ) {
67
+ this . path . splice ( 0 , this . path . length , ...node . path ) ;
68
+ this . depth = node . depth ;
69
+ this . fragment = node . fragment ;
70
+ this . schemaNode = node ;
71
+ }
72
+
64
73
public * walk ( ) : IterableIterator < WalkerItem > {
65
74
const {
66
75
depth : initialDepth ,
@@ -93,13 +102,15 @@ export class Walker extends EventEmitter<Dictionary<WalkerEventHandler, WalkerEv
93
102
}
94
103
}
95
104
96
- if ( ! ( schemaNode instanceof RegularNode ) ) continue ;
105
+ super . emit ( 'acceptNode' , schemaNode ) ;
97
106
98
- this . schemaNode = schemaNode ;
107
+ if ( schemaNode instanceof RegularNode ) {
108
+ this . schemaNode = schemaNode ;
99
109
100
- if ( this . hooks . stepIn ?.( schemaNode ) === false ) {
101
- super . emit ( 'enterNode' , schemaNode ) ;
102
- yield * this . walkNodeChildren ( ) ;
110
+ if ( this . hooks . stepIn ?.( schemaNode ) !== false ) {
111
+ super . emit ( 'enterNode' , schemaNode ) ;
112
+ yield * this . walkNodeChildren ( ) ;
113
+ }
103
114
}
104
115
105
116
super . emit ( 'exitNode' , schemaNode ) ;
0 commit comments