Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Encapsulate block end delimiter as language specific attribute #29

Merged
merged 2 commits into from
Dec 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions matching/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,14 @@ mod tests {
value: "value",
start_position: Point { row: 0, column: 0 },
end_position: Point { row: 0, column: 5 },
is_block_end_delimiter: false,
});
let right = CSTNode::Terminal(Terminal {
kind: "kind",
value: "value",
start_position: Point { row: 0, column: 0 },
end_position: Point { row: 0, column: 5 },
is_block_end_delimiter: false,
});

let matchings = calculate_matchings(&left, &right);
Expand All @@ -85,12 +87,14 @@ mod tests {
value: "value_a",
start_position: Point { row: 0, column: 0 },
end_position: Point { row: 0, column: 7 },
is_block_end_delimiter: false,
});
let right = CSTNode::Terminal(Terminal {
kind: "kind",
value: "value_b",
start_position: Point { row: 0, column: 0 },
end_position: Point { row: 0, column: 7 },
is_block_end_delimiter: false,
});

let matchings = calculate_matchings(&left, &right);
Expand All @@ -108,12 +112,14 @@ mod tests {
value: "value",
start_position: Point { row: 0, column: 0 },
end_position: Point { row: 0, column: 5 },
is_block_end_delimiter: false,
});
let right = CSTNode::Terminal(Terminal {
kind: "kind_b",
value: "value",
start_position: Point { row: 0, column: 0 },
end_position: Point { row: 0, column: 5 },
is_block_end_delimiter: false,
});

let matchings = calculate_matchings(&left, &right);
Expand All @@ -131,12 +137,14 @@ mod tests {
value: "value_a",
start_position: Point { row: 0, column: 0 },
end_position: Point { row: 0, column: 7 },
is_block_end_delimiter: false,
});
let right = CSTNode::Terminal(Terminal {
kind: "kind_b",
value: "value_a",
start_position: Point { row: 0, column: 0 },
end_position: Point { row: 0, column: 7 },
is_block_end_delimiter: false,
});

let matchings = calculate_matchings(&left, &right);
Expand Down
2 changes: 2 additions & 0 deletions matching/src/matchings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ mod tests {
value: "value",
start_position: Point { row: 0, column: 0 },
end_position: Point { row: 0, column: 5 },
is_block_end_delimiter: false,
});

assert_eq!(None, Matchings::empty().find_matching_for(&a_node))
Expand All @@ -105,6 +106,7 @@ mod tests {
value: "value",
start_position: Point { row: 0, column: 0 },
end_position: Point { row: 0, column: 5 },
is_block_end_delimiter: false,
});

let mut matchings = HashMap::new();
Expand Down
7 changes: 7 additions & 0 deletions matching/src/ordered_tree_matching.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ mod tests {
value: "value_b",
start_position: Point { row: 1, column: 0 },
end_position: Point { row: 1, column: 7 },
is_block_end_delimiter: false,
});
let left = CSTNode::NonTerminal(NonTerminal {
kind: "kind_a",
Expand Down Expand Up @@ -142,12 +143,14 @@ mod tests {
value: "value_b",
start_position: Point { row: 0, column: 0 },
end_position: Point { row: 0, column: 7 },
is_block_end_delimiter: false,
});
let right_child = CSTNode::Terminal(Terminal {
kind: "kind_c",
value: "value_c",
start_position: Point { row: 1, column: 0 },
end_position: Point { row: 1, column: 7 },
is_block_end_delimiter: false,
});

let left = CSTNode::NonTerminal(NonTerminal {
Expand Down Expand Up @@ -180,12 +183,14 @@ mod tests {
value: "value_b",
start_position: Point { row: 0, column: 0 },
end_position: Point { row: 0, column: 7 },
is_block_end_delimiter: false,
});
let unique_right_child = CSTNode::Terminal(Terminal {
kind: "kind_c",
value: "value_c",
start_position: Point { row: 0, column: 0 },
end_position: Point { row: 0, column: 7 },
is_block_end_delimiter: false,
});

let left = CSTNode::NonTerminal(NonTerminal {
Expand Down Expand Up @@ -218,6 +223,7 @@ mod tests {
start_position: Point { row: 0, column: 0 },
end_position: Point { row: 0, column: 7 },
value: "value_b",
is_block_end_delimiter: false,
});

let left = CSTNode::NonTerminal(NonTerminal {
Expand Down Expand Up @@ -250,6 +256,7 @@ mod tests {
start_position: Point { row: 0, column: 0 },
end_position: Point { row: 0, column: 7 },
value: "value_b",
is_block_end_delimiter: false,
});

let intermediate = CSTNode::NonTerminal(NonTerminal {
Expand Down
2 changes: 2 additions & 0 deletions merge/src/merge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,14 @@ mod tests {
start_position: Point { row: 0, column: 0 },
end_position: Point { row: 0, column: 7 },
value: "value",
is_block_end_delimiter: false,
}),
&CSTNode::Terminal(Terminal {
kind: "kind",
start_position: Point { row: 0, column: 0 },
end_position: Point { row: 0, column: 7 },
value: "value",
is_block_end_delimiter: false,
}),
&CSTNode::NonTerminal(NonTerminal {
kind: "kind",
Expand Down
11 changes: 11 additions & 0 deletions merge/src/merge_terminals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ mod tests {
start_position: Point { row: 0, column: 0 },
end_position: Point { row: 0, column: 7 },
value: "value",
is_block_end_delimiter: false,
};

assert_merge_is_correct_and_idempotent_with_respect_to_parent_side(
Expand All @@ -85,18 +86,21 @@ mod tests {
start_position: Point { row: 0, column: 0 },
end_position: Point { row: 0, column: 7 },
value: "\nvalue\n",
is_block_end_delimiter: false,
};
let left = Terminal {
kind: "kind",
start_position: Point { row: 0, column: 0 },
end_position: Point { row: 0, column: 7 },
value: "left\nvalue\n",
is_block_end_delimiter: false,
};
let right = Terminal {
kind: "kind",
start_position: Point { row: 0, column: 0 },
end_position: Point { row: 0, column: 7 },
value: "\nvalue\nright",
is_block_end_delimiter: false,
};

assert_merge_is_correct_and_idempotent_with_respect_to_parent_side(
Expand All @@ -118,18 +122,21 @@ mod tests {
start_position: Point { row: 0, column: 0 },
end_position: Point { row: 0, column: 7 },
value: "value",
is_block_end_delimiter: false,
};
let left = Terminal {
kind: "kind",
start_position: Point { row: 0, column: 0 },
end_position: Point { row: 0, column: 7 },
value: "left_value",
is_block_end_delimiter: false,
};
let right = Terminal {
kind: "kind",
start_position: Point { row: 0, column: 0 },
end_position: Point { row: 0, column: 7 },
value: "right_value",
is_block_end_delimiter: false,
};

assert_eq!(
Expand All @@ -151,12 +158,14 @@ mod tests {
start_position: Point { row: 0, column: 0 },
end_position: Point { row: 0, column: 7 },
value: "value",
is_block_end_delimiter: false,
};
let changed_parent = Terminal {
kind: "kind",
start_position: Point { row: 0, column: 0 },
end_position: Point { row: 0, column: 7 },
value: "value_right",
is_block_end_delimiter: false,
};

assert_merge_is_correct_and_idempotent_with_respect_to_parent_side(
Expand All @@ -174,12 +183,14 @@ mod tests {
start_position: Point { row: 0, column: 0 },
end_position: Point { row: 0, column: 7 },
value: "value",
is_block_end_delimiter: false,
};
let kind_b = Terminal {
kind: "kind_b",
start_position: Point { row: 0, column: 0 },
end_position: Point { row: 0, column: 7 },
value: "value_right",
is_block_end_delimiter: false,
};

let result = merge_terminals(&kind_a, &kind_a, &kind_b);
Expand Down
Loading
Loading