@@ -53,9 +53,9 @@ pub fn estimate_node_range(
53
53
} ;
54
54
} ) ;
55
55
56
- // second iteration using the nearest parent from the first
56
+ // second iteration using the nearest parent from the first, or the location of the nearest
57
+ // parent node
57
58
for idx in too_many_tokens_at {
58
- // get the nearest parent location
59
59
let nearest_parent_start =
60
60
get_nearest_parent_start ( & nodes[ idx] , & nodes, & child_token_ranges) ;
61
61
let nearest_parent_location = get_nearest_parent_location ( & nodes[ idx] , & nodes) ;
@@ -90,7 +90,7 @@ pub fn estimate_node_range(
90
90
. filter ( |x| x. inner . path . starts_with ( n. path . as_str ( ) ) )
91
91
. collect :: < Vec < & RangedNode > > ( ) ;
92
92
93
- // get `from` location
93
+ // get `from` location as the smaller value of the location of the node, the start of all children nodes, and the start of the first child token
94
94
let node_location = match get_location ( & n. node ) {
95
95
Some ( l) => Some ( TextSize :: from ( l) ) ,
96
96
None => None ,
@@ -141,6 +141,7 @@ pub fn estimate_node_range(
141
141
let to = to_locations. iter ( ) . filter ( |v| v. is_some ( ) ) . max ( ) ;
142
142
143
143
if from. is_some ( ) && to. is_some ( ) {
144
+ // ignore nodes that have no range. They are not relevant for the cst.
144
145
ranged_nodes. push ( RangedNode {
145
146
inner : n. to_owned ( ) ,
146
147
range : TextRange :: new ( from. unwrap ( ) . unwrap ( ) , to. unwrap ( ) . unwrap ( ) ) ,
0 commit comments