Skip to content

Commit 197f351

Browse files
committed
chore: add comments
1 parent 4d97205 commit 197f351

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

crates/parser/src/estimate_node_range.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ pub fn estimate_node_range(
5353
};
5454
});
5555

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
5758
for idx in too_many_tokens_at {
58-
// get the nearest parent location
5959
let nearest_parent_start =
6060
get_nearest_parent_start(&nodes[idx], &nodes, &child_token_ranges);
6161
let nearest_parent_location = get_nearest_parent_location(&nodes[idx], &nodes);
@@ -90,7 +90,7 @@ pub fn estimate_node_range(
9090
.filter(|x| x.inner.path.starts_with(n.path.as_str()))
9191
.collect::<Vec<&RangedNode>>();
9292

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
9494
let node_location = match get_location(&n.node) {
9595
Some(l) => Some(TextSize::from(l)),
9696
None => None,
@@ -141,6 +141,7 @@ pub fn estimate_node_range(
141141
let to = to_locations.iter().filter(|v| v.is_some()).max();
142142

143143
if from.is_some() && to.is_some() {
144+
// ignore nodes that have no range. They are not relevant for the cst.
144145
ranged_nodes.push(RangedNode {
145146
inner: n.to_owned(),
146147
range: TextRange::new(from.unwrap().unwrap(), to.unwrap().unwrap()),

0 commit comments

Comments
 (0)