Skip to content

Commit

Permalink
Upgraded to tstlaplus 1.5.0
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Helwer <2n8rn1w1f@mozmail.com>
  • Loading branch information
ahelwer committed Oct 21, 2024
1 parent 3d64a46 commit a3b3101
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ anyhow = "1.0.81"
clap = { version = "4.5.4", features = ["derive"] }
csv = "1.3.0"
serde = { version = "1.0.197", features = ["derive"] }
tree-sitter = "0.23"
tree-sitter-language = "0.1.0"
tree-sitter-tlaplus = "1.4.0"
streaming-iterator = "0.1.9"
tree-sitter = "0.24.3"
tree-sitter-language = "0.1.2"
tree-sitter-tlaplus = "1.5.0"

[dev-dependencies]
glob = "0.3.1"
Expand Down
25 changes: 12 additions & 13 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use crate::strmeasure::*;

use serde::{Deserialize, Deserializer};
use std::ops::Range;
use streaming_iterator::StreamingIterator;
use tree_sitter::{Node, Parser, Query, QueryCursor, Tree, TreeCursor};

pub enum Mode {
Expand Down Expand Up @@ -334,7 +335,9 @@ impl JList {

fn mark_jlists(tree: &Tree, query_cursor: &mut QueryCursor, tla_lines: &mut [TlaLine]) {
let mut tree_cursor: TreeCursor = tree.walk();
for capture in query_cursor.matches(&JList::query(), tree.root_node(), "".as_bytes()) {
let query = JList::query();
let mut captures = query_cursor.matches(&query, tree.root_node(), "".as_bytes());
while let Some(capture) = captures.next() {
let node = capture.captures[0].node;
let start_line = node.start_position().row;
let line = &mut tla_lines[start_line];
Expand All @@ -360,11 +363,9 @@ fn mark_jlists(tree: &Tree, query_cursor: &mut QueryCursor, tla_lines: &mut [Tla
line.jlists.push(jlist);
}

for capture in query_cursor.matches(
&JList::terminating_infix_op_query(),
tree.root_node(),
"".as_bytes(),
) {
let query = JList::terminating_infix_op_query();
let mut captures = query_cursor.matches(&query, tree.root_node(), "".as_bytes());
while let Some(capture) = captures.next() {
let infix_op_node = capture.captures[0].node;
let jlist_node = infix_op_node.child_by_field_name("lhs").unwrap();
let jlist_start_line_index = jlist_node.start_position().row;
Expand Down Expand Up @@ -406,7 +407,8 @@ fn mark_symbols(tree: &Tree, cursor: &mut QueryCursor, tla_lines: &mut [TlaLine]
.join("");
let query = Query::new(&tree_sitter_tlaplus::LANGUAGE.into(), queries).unwrap();

for capture in cursor.matches(&query, tree.root_node(), "".as_bytes()) {
let mut captures = cursor.matches(&query, tree.root_node(), "".as_bytes());
while let Some(capture) = captures.next() {
let capture = capture.captures[0];
let mapping = &mappings[capture.index as usize];
let start_position = capture.node.start_position();
Expand Down Expand Up @@ -544,12 +546,9 @@ mod tests {
.collect::<Vec<String>>()
.join("");
let query = Query::new(&tree_sitter_tlaplus::LANGUAGE.into(), &queries).unwrap();
assert_eq!(
0,
cursor
.matches(&query, tree.root_node(), "".as_bytes())
.count()
);
assert!(cursor
.matches(&query, tree.root_node(), "".as_bytes())
.is_done());
}

fn unwrap_conversion(input: Result<String, TlaError>) -> String {
Expand Down

0 comments on commit a3b3101

Please sign in to comment.