Detailed changes
@@ -750,21 +750,12 @@ dependencies = [
"arrayvec 0.7.1",
"clock",
"gpui",
- "lazy_static",
"log",
- "parking_lot",
"rand 0.8.3",
"rpc",
"seahash",
- "serde 1.0.125",
- "similar",
"smallvec",
- "smol",
"sum_tree",
- "theme",
- "tree-sitter",
- "tree-sitter-rust",
- "unindent",
]
[[package]]
@@ -2822,7 +2813,6 @@ name = "language"
version = "0.1.0"
dependencies = [
"anyhow",
- "arrayvec 0.7.1",
"buffer",
"clock",
"gpui",
@@ -2831,12 +2821,9 @@ dependencies = [
"parking_lot",
"rand 0.8.3",
"rpc",
- "seahash",
"serde 1.0.125",
"similar",
- "smallvec",
"smol",
- "sum_tree",
"theme",
"tree-sitter",
"tree-sitter-rust",
@@ -4,30 +4,20 @@ version = "0.1.0"
edition = "2018"
[features]
-test-support = ["rand"]
+test-support = ["rand", "seahash"]
[dependencies]
clock = { path = "../clock" }
-gpui = { path = "../gpui" }
rpc = { path = "../rpc" }
sum_tree = { path = "../sum_tree" }
-theme = { path = "../theme" }
anyhow = "1.0.38"
arrayvec = "0.7.1"
-lazy_static = "1.4"
log = "0.4"
-parking_lot = "0.11.1"
rand = { version = "0.8.3", optional = true }
-seahash = "4.1"
-serde = { version = "1", features = ["derive"] }
-similar = "1.3"
+seahash = { version = "4.1", optional = true }
smallvec = { version = "1.6", features = ["union"] }
-smol = "1.2"
-tree-sitter = "0.19.5"
[dev-dependencies]
gpui = { path = "../gpui", features = ["test-support"] }
-
+seahash = "4.1"
rand = "0.8.3"
-tree-sitter-rust = "0.19.0"
-unindent = "0.1.7"
@@ -29,7 +29,8 @@ use std::{
sync::Arc,
time::{Duration, Instant},
};
-use sum_tree::{Bias, FilterCursor, SumTree};
+pub use sum_tree::Bias;
+use sum_tree::{FilterCursor, SumTree};
#[derive(Clone, Default)]
struct DeterministicState;
@@ -109,21 +109,3 @@ impl Ord for Point {
}
}
}
-
-impl Into<tree_sitter::Point> for Point {
- fn into(self) -> tree_sitter::Point {
- tree_sitter::Point {
- row: self.row as usize,
- column: self.column as usize,
- }
- }
-}
-
-impl From<tree_sitter::Point> for Point {
- fn from(point: tree_sitter::Point) -> Self {
- Self {
- row: point.row as u32,
- column: point.column as u32,
- }
- }
-}
@@ -4,7 +4,11 @@ version = "0.1.0"
edition = "2018"
[features]
-test-support = ["buffer/test-support", "gpui/test-support"]
+test-support = [
+ "buffer/test-support",
+ "language/test-support",
+ "gpui/test-support",
+]
[dependencies]
buffer = { path = "../buffer" }
@@ -11,25 +11,20 @@ buffer = { path = "../buffer" }
clock = { path = "../clock" }
gpui = { path = "../gpui" }
rpc = { path = "../rpc" }
-sum_tree = { path = "../sum_tree" }
theme = { path = "../theme" }
anyhow = "1.0.38"
-arrayvec = "0.7.1"
lazy_static = "1.4"
log = "0.4"
parking_lot = "0.11.1"
rand = { version = "0.8.3", optional = true }
-seahash = "4.1"
serde = { version = "1", features = ["derive"] }
similar = "1.3"
-smallvec = { version = "1.6", features = ["union"] }
smol = "1.2"
tree-sitter = "0.19.5"
[dev-dependencies]
buffer = { path = "../buffer", features = ["test-support"] }
gpui = { path = "../gpui", features = ["test-support"] }
-
rand = "0.8.3"
tree-sitter-rust = "0.19.0"
unindent = "0.1.7"
@@ -30,7 +30,6 @@ use std::{
sync::Arc,
time::{Duration, Instant, SystemTime, UNIX_EPOCH},
};
-use sum_tree::Bias;
use tree_sitter::{InputEdit, Parser, QueryCursor, Tree};
thread_local! {
@@ -456,12 +455,12 @@ impl Buffer {
start_byte: start_offset,
old_end_byte: start_offset + edit.deleted_bytes(),
new_end_byte: start_offset + edit.inserted_bytes(),
- start_position: start_point.into(),
- old_end_position: (start_point + edit.deleted_lines()).into(),
+ start_position: start_point.to_ts_point(),
+ old_end_position: (start_point + edit.deleted_lines()).to_ts_point(),
new_end_position: self
.as_rope()
.to_point(start_offset + edit.inserted_bytes())
- .into(),
+ .to_ts_point(),
});
delta += edit.inserted_bytes() as isize - edit.deleted_bytes() as isize;
}
@@ -1150,8 +1149,8 @@ impl Snapshot {
let indent_capture_ix = language.indents_query.capture_index_for_name("indent");
let end_capture_ix = language.indents_query.capture_index_for_name("end");
query_cursor.set_point_range(
- Point::new(prev_non_blank_row.unwrap_or(row_range.start), 0).into()
- ..Point::new(row_range.end, 0).into(),
+ Point::new(prev_non_blank_row.unwrap_or(row_range.start), 0).to_ts_point()
+ ..Point::new(row_range.end, 0).to_ts_point(),
);
let mut indentation_ranges = Vec::<(Range<Point>, &'static str)>::new();
for mat in query_cursor.matches(
@@ -1165,10 +1164,10 @@ impl Snapshot {
for capture in mat.captures {
if Some(capture.index) == indent_capture_ix {
node_kind = capture.node.kind();
- start.get_or_insert(capture.node.start_position().into());
- end.get_or_insert(capture.node.end_position().into());
+ start.get_or_insert(Point::from_ts_point(capture.node.start_position()));
+ end.get_or_insert(Point::from_ts_point(capture.node.end_position()));
} else if Some(capture.index) == end_capture_ix {
- end = Some(capture.node.start_position().into());
+ end = Some(Point::from_ts_point(capture.node.start_position().into()));
}
}
@@ -1439,11 +1438,26 @@ impl Drop for QueryCursorHandle {
fn drop(&mut self) {
let mut cursor = self.0.take().unwrap();
cursor.set_byte_range(0..usize::MAX);
- cursor.set_point_range(Point::zero().into()..Point::MAX.into());
+ cursor.set_point_range(Point::zero().to_ts_point()..Point::MAX.to_ts_point());
QUERY_CURSORS.lock().push(cursor)
}
}
+trait ToTreeSitterPoint {
+ fn to_ts_point(self) -> tree_sitter::Point;
+ fn from_ts_point(point: tree_sitter::Point) -> Self;
+}
+
+impl ToTreeSitterPoint for Point {
+ fn to_ts_point(self) -> tree_sitter::Point {
+ tree_sitter::Point::new(self.row as usize, self.column as usize)
+ }
+
+ fn from_ts_point(point: tree_sitter::Point) -> Self {
+ Point::new(point.row as u32, point.column as u32)
+ }
+}
+
fn contiguous_ranges(
values: impl IntoIterator<Item = u32>,
max_len: usize,