From 6cdf4e98fc7d98605075f9d8a94b4b72d4b0aeaa Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Wed, 12 Oct 2022 15:48:19 -0700 Subject: [PATCH] Re-export basic text types from text and language crates Also avoid production dependencies on fs and rope in collab --- Cargo.lock | 9 --------- crates/collab/Cargo.toml | 6 ++---- crates/collab/src/integration_tests.rs | 3 +-- crates/diagnostics/Cargo.toml | 1 - crates/diagnostics/src/diagnostics.rs | 7 +++---- crates/editor/Cargo.toml | 1 - crates/editor/src/display_map.rs | 3 +-- crates/editor/src/display_map/block_map.rs | 3 +-- crates/editor/src/display_map/fold_map.rs | 3 +-- crates/editor/src/display_map/tab_map.rs | 8 +++----- crates/editor/src/display_map/wrap_map.rs | 3 +-- crates/editor/src/editor.rs | 5 ++--- crates/editor/src/editor_tests.rs | 3 +-- crates/editor/src/element.rs | 3 +-- crates/editor/src/items.rs | 3 +-- crates/editor/src/movement.rs | 4 +--- crates/editor/src/multi_buffer.rs | 8 ++++---- crates/editor/src/multi_buffer/anchor.rs | 2 +- crates/editor/src/selections_collection.rs | 3 +-- crates/git/Cargo.toml | 1 - crates/git/src/diff.rs | 4 +--- crates/go_to_line/Cargo.toml | 1 - crates/go_to_line/src/go_to_line.rs | 3 +-- crates/language/Cargo.toml | 1 - crates/language/src/buffer.rs | 3 +-- crates/language/src/buffer_tests.rs | 1 - crates/language/src/diagnostic_set.rs | 3 +-- crates/language/src/language.rs | 1 - crates/language/src/syntax_map.rs | 5 ++--- crates/project/Cargo.toml | 1 - crates/project/src/lsp_command.rs | 3 +-- crates/project/src/project.rs | 3 +-- crates/project/src/project_tests.rs | 3 +-- crates/project/src/worktree.rs | 3 +-- crates/rope/src/rope.rs | 13 +++++++------ crates/settings/Cargo.toml | 1 - crates/text/src/anchor.rs | 4 +--- crates/text/src/selection.rs | 5 +---- crates/text/src/text.rs | 5 +++-- crates/vim/Cargo.toml | 1 - crates/vim/src/normal.rs | 3 +-- crates/vim/src/test/neovim_backed_test_context.rs | 4 ++-- crates/vim/src/test/neovim_connection.rs | 3 +-- 43 files changed, 51 insertions(+), 102 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0b875441ca..5e960df642 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1084,7 +1084,6 @@ dependencies = [ "prometheus", "rand 0.8.5", "reqwest", - "rope", "rpc", "scrypt", "serde", @@ -1576,7 +1575,6 @@ dependencies = [ "language", "postage", "project", - "rope", "serde_json", "settings", "smallvec", @@ -1730,7 +1728,6 @@ dependencies = [ "postage", "project", "rand 0.8.5", - "rope", "rpc", "serde", "settings", @@ -2294,7 +2291,6 @@ dependencies = [ "lazy_static", "log", "parking_lot 0.11.2", - "rope", "smol", "sum_tree", "text", @@ -2342,7 +2338,6 @@ dependencies = [ "gpui", "menu", "postage", - "rope", "settings", "text", "workspace", @@ -2943,7 +2938,6 @@ dependencies = [ "postage", "rand 0.8.5", "regex", - "rope", "rpc", "serde", "serde_json", @@ -4123,7 +4117,6 @@ dependencies = [ "rand 0.8.5", "regex", "rocksdb", - "rope", "rpc", "serde", "serde_json", @@ -5148,7 +5141,6 @@ dependencies = [ "gpui", "json_comments", "postage", - "rope", "schemars", "serde", "serde_json", @@ -6639,7 +6631,6 @@ dependencies = [ "nvim-rs", "parking_lot 0.11.2", "project", - "rope", "search", "serde", "serde_json", diff --git a/crates/collab/Cargo.toml b/crates/collab/Cargo.toml index cf6b7f8b68..de41e8a1f3 100644 --- a/crates/collab/Cargo.toml +++ b/crates/collab/Cargo.toml @@ -16,8 +16,6 @@ required-features = ["seed-support"] collections = { path = "../collections" } rpc = { path = "../rpc" } util = { path = "../util" } -fs = { path = "../fs" } -rope = { path = "../rope" } anyhow = "1.0.40" async-trait = "0.1.50" async-tungstenite = "0.16" @@ -27,7 +25,6 @@ base64 = "0.13" clap = { version = "3.1", features = ["derive"], optional = true } envy = "0.4.2" futures = "0.3" -git = { path = "../git" } hyper = "0.14" lazy_static = "1.4" lipsum = { version = "0.8", optional = true } @@ -61,6 +58,8 @@ call = { path = "../call", features = ["test-support"] } client = { path = "../client", features = ["test-support"] } editor = { path = "../editor", features = ["test-support"] } language = { path = "../language", features = ["test-support"] } +fs = { path = "../fs", features = ["test-support"] } +git = { path = "../git", features = ["test-support"] } log = { version = "0.4.16", features = ["kv_unstable_serde"] } lsp = { path = "../lsp", features = ["test-support"] } project = { path = "../project", features = ["test-support"] } @@ -68,7 +67,6 @@ rpc = { path = "../rpc", features = ["test-support"] } settings = { path = "../settings", features = ["test-support"] } theme = { path = "../theme" } workspace = { path = "../workspace", features = ["test-support"] } -git = { path = "../git", features = ["test-support"] } ctor = "0.1" env_logger = "0.9" util = { path = "../util" } diff --git a/crates/collab/src/integration_tests.rs b/crates/collab/src/integration_tests.rs index bac5cc040e..8ab852810b 100644 --- a/crates/collab/src/integration_tests.rs +++ b/crates/collab/src/integration_tests.rs @@ -25,7 +25,7 @@ use gpui::{ }; use language::{ range_to_lsp, tree_sitter_rust, Diagnostic, DiagnosticEntry, FakeLspAdapter, Language, - LanguageConfig, LanguageRegistry, OffsetRangeExt, Rope, + LanguageConfig, LanguageRegistry, OffsetRangeExt, Rope, Point, }; use lsp::{self, FakeLanguageServer}; use parking_lot::Mutex; @@ -34,7 +34,6 @@ use project::{ ProjectStore, WorktreeId, }; use rand::prelude::*; -use rope::point::Point; use rpc::PeerId; use serde_json::json; use settings::{Formatter, Settings}; diff --git a/crates/diagnostics/Cargo.toml b/crates/diagnostics/Cargo.toml index c4b851917e..616f69117f 100644 --- a/crates/diagnostics/Cargo.toml +++ b/crates/diagnostics/Cargo.toml @@ -15,7 +15,6 @@ editor = { path = "../editor" } language = { path = "../language" } gpui = { path = "../gpui" } project = { path = "../project" } -rope = { path = "../rope" } settings = { path = "../settings" } theme = { path = "../theme" } util = { path = "../util" } diff --git a/crates/diagnostics/src/diagnostics.rs b/crates/diagnostics/src/diagnostics.rs index 608b333d0d..3111d7a9f1 100644 --- a/crates/diagnostics/src/diagnostics.rs +++ b/crates/diagnostics/src/diagnostics.rs @@ -14,10 +14,10 @@ use gpui::{ ViewHandle, WeakViewHandle, }; use language::{ - Anchor, Bias, Buffer, Diagnostic, DiagnosticEntry, DiagnosticSeverity, Selection, SelectionGoal, + Anchor, Bias, Buffer, Diagnostic, DiagnosticEntry, DiagnosticSeverity, Point, Selection, + SelectionGoal, }; use project::{DiagnosticSummary, Project, ProjectPath}; -use rope::point::Point; use serde_json::json; use settings::Settings; use smallvec::SmallVec; @@ -738,8 +738,7 @@ mod tests { DisplayPoint, }; use gpui::TestAppContext; - use language::{Diagnostic, DiagnosticEntry, DiagnosticSeverity}; - use rope::point_utf16::PointUtf16; + use language::{Diagnostic, DiagnosticEntry, DiagnosticSeverity, PointUtf16}; use serde_json::json; use unindent::Unindent as _; use workspace::AppState; diff --git a/crates/editor/Cargo.toml b/crates/editor/Cargo.toml index 4e0a10b70d..db634376d0 100644 --- a/crates/editor/Cargo.toml +++ b/crates/editor/Cargo.toml @@ -30,7 +30,6 @@ gpui = { path = "../gpui" } language = { path = "../language" } lsp = { path = "../lsp" } project = { path = "../project" } -rope = { path = "../rope" } rpc = { path = "../rpc" } settings = { path = "../settings" } snippet = { path = "../snippet" } diff --git a/crates/editor/src/display_map.rs b/crates/editor/src/display_map.rs index 91a3a30267..e32276df41 100644 --- a/crates/editor/src/display_map.rs +++ b/crates/editor/src/display_map.rs @@ -11,8 +11,7 @@ use gpui::{ fonts::{FontId, HighlightStyle}, Entity, ModelContext, ModelHandle, }; -use language::Subscription as BufferSubscription; -use rope::{offset_utf16::OffsetUtf16, point::Point}; +use language::{OffsetUtf16, Point, Subscription as BufferSubscription}; use settings::Settings; use std::{any::TypeId, fmt::Debug, num::NonZeroU32, ops::Range, sync::Arc}; use sum_tree::{Bias, TreeMap}; diff --git a/crates/editor/src/display_map/block_map.rs b/crates/editor/src/display_map/block_map.rs index f0f2720f1a..3ae259f335 100644 --- a/crates/editor/src/display_map/block_map.rs +++ b/crates/editor/src/display_map/block_map.rs @@ -5,9 +5,8 @@ use super::{ use crate::{Anchor, ExcerptRange, ToPoint as _}; use collections::{Bound, HashMap, HashSet}; use gpui::{ElementBox, RenderContext}; -use language::{BufferSnapshot, Chunk, Patch}; +use language::{BufferSnapshot, Chunk, Patch, Point}; use parking_lot::Mutex; -use rope::point::Point; use std::{ cell::RefCell, cmp::{self, Ordering}, diff --git a/crates/editor/src/display_map/fold_map.rs b/crates/editor/src/display_map/fold_map.rs index 5bd1670542..663de0f80c 100644 --- a/crates/editor/src/display_map/fold_map.rs +++ b/crates/editor/src/display_map/fold_map.rs @@ -5,9 +5,8 @@ use crate::{ }; use collections::BTreeMap; use gpui::fonts::HighlightStyle; -use language::{Chunk, Edit, TextSummary}; +use language::{Chunk, Edit, Point, TextSummary}; use parking_lot::Mutex; -use rope::point::Point; use std::{ any::TypeId, cmp::{self, Ordering}, diff --git a/crates/editor/src/display_map/tab_map.rs b/crates/editor/src/display_map/tab_map.rs index b7d8fac770..39bcdc4d9f 100644 --- a/crates/editor/src/display_map/tab_map.rs +++ b/crates/editor/src/display_map/tab_map.rs @@ -3,10 +3,8 @@ use super::{ TextHighlights, }; use crate::MultiBufferSnapshot; -use language::Chunk; +use language::{Chunk, Point}; use parking_lot::Mutex; -use rope; -use rope::point::Point; use std::{cmp, mem, num::NonZeroU32, ops::Range}; use sum_tree::Bias; @@ -372,7 +370,7 @@ pub struct TextSummary { impl<'a> From<&'a str> for TextSummary { fn from(text: &'a str) -> Self { - let sum = rope::TextSummary::from(text); + let sum = text::TextSummary::from(text); TextSummary { lines: sum.lines, @@ -524,7 +522,7 @@ mod tests { log::info!("FoldMap text: {:?}", folds_snapshot.text()); let (_, tabs_snapshot) = TabMap::new(folds_snapshot.clone(), tab_size); - let text = rope::Rope::from(tabs_snapshot.text().as_str()); + let text = text::Rope::from(tabs_snapshot.text().as_str()); log::info!( "TabMap text (tab size: {}): {:?}", tab_size, diff --git a/crates/editor/src/display_map/wrap_map.rs b/crates/editor/src/display_map/wrap_map.rs index 42156b905f..0b6713119d 100644 --- a/crates/editor/src/display_map/wrap_map.rs +++ b/crates/editor/src/display_map/wrap_map.rs @@ -8,9 +8,8 @@ use gpui::{ fonts::FontId, text_layout::LineWrapper, Entity, ModelContext, ModelHandle, MutableAppContext, Task, }; -use language::Chunk; +use language::{Chunk, Point}; use lazy_static::lazy_static; -use rope::point::Point; use smol::future::yield_now; use std::{cmp, collections::VecDeque, mem, ops::Range, time::Duration}; use sum_tree::{Bias, Cursor, SumTree}; diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index c8bb16ee00..a7acc9f609 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -43,8 +43,8 @@ pub use items::MAX_TAB_TITLE_LEN; pub use language::{char_kind, CharKind}; use language::{ AutoindentMode, BracketPair, Buffer, CodeAction, CodeLabel, Completion, Diagnostic, - DiagnosticSeverity, IndentKind, IndentSize, Language, OffsetRangeExt, Selection, SelectionGoal, - TransactionId, + DiagnosticSeverity, IndentKind, IndentSize, Language, OffsetRangeExt, OffsetUtf16, Point, + Selection, SelectionGoal, TransactionId, }; use link_go_to_definition::{hide_link_definition, LinkGoToDefinitionState}; pub use multi_buffer::{ @@ -54,7 +54,6 @@ pub use multi_buffer::{ use multi_buffer::{MultiBufferChunks, ToOffsetUtf16}; use ordered_float::OrderedFloat; use project::{FormatTrigger, LocationLink, Project, ProjectPath, ProjectTransaction}; -use rope::{offset_utf16::OffsetUtf16, point::Point}; use selections_collection::{resolve_multiple, MutableSelectionsCollection, SelectionsCollection}; use serde::{Deserialize, Serialize}; use settings::Settings; diff --git a/crates/editor/src/editor_tests.rs b/crates/editor/src/editor_tests.rs index 8b41990574..406969c8fe 100644 --- a/crates/editor/src/editor_tests.rs +++ b/crates/editor/src/editor_tests.rs @@ -13,9 +13,8 @@ use gpui::{ geometry::rect::RectF, platform::{WindowBounds, WindowOptions}, }; -use language::{FakeLspAdapter, LanguageConfig, LanguageRegistry}; +use language::{FakeLspAdapter, LanguageConfig, LanguageRegistry, Point}; use project::FakeFs; -use rope::point::Point; use settings::EditorSettings; use util::{ assert_set_eq, diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index f29eb52804..912cea8c5f 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -35,9 +35,8 @@ use gpui::{ WeakViewHandle, }; use json::json; -use language::{Bias, DiagnosticSeverity, Selection}; +use language::{Bias, DiagnosticSeverity, OffsetUtf16, Selection}; use project::ProjectPath; -use rope::offset_utf16::OffsetUtf16; use settings::{GitGutter, Settings}; use smallvec::SmallVec; use std::{ diff --git a/crates/editor/src/items.rs b/crates/editor/src/items.rs index 727ee1f094..e6a4eebffb 100644 --- a/crates/editor/src/items.rs +++ b/crates/editor/src/items.rs @@ -9,9 +9,8 @@ use gpui::{ elements::*, geometry::vector::vec2f, AppContext, Entity, ModelHandle, MutableAppContext, RenderContext, Subscription, Task, View, ViewContext, ViewHandle, }; -use language::{Bias, Buffer, File as _, OffsetRangeExt, SelectionGoal}; +use language::{Bias, Buffer, File as _, OffsetRangeExt, Point, SelectionGoal}; use project::{File, FormatTrigger, Project, ProjectEntryId, ProjectPath}; -use rope::point::Point; use rpc::proto::{self, update_view}; use settings::Settings; use smallvec::SmallVec; diff --git a/crates/editor/src/movement.rs b/crates/editor/src/movement.rs index e5dcf94841..40908d2bb3 100644 --- a/crates/editor/src/movement.rs +++ b/crates/editor/src/movement.rs @@ -1,7 +1,6 @@ -use rope::point::Point; - use super::{Bias, DisplayPoint, DisplaySnapshot, SelectionGoal, ToDisplayPoint}; use crate::{char_kind, CharKind, ToPoint}; +use language::Point; use std::ops::Range; pub fn left(map: &DisplaySnapshot, mut point: DisplayPoint) -> DisplayPoint { @@ -337,7 +336,6 @@ pub fn surrounding_word(map: &DisplaySnapshot, position: DisplayPoint) -> Range< mod tests { use super::*; use crate::{test::marked_display_snapshot, Buffer, DisplayMap, ExcerptRange, MultiBuffer}; - use rope::point::Point; use settings::Settings; #[gpui::test] diff --git a/crates/editor/src/multi_buffer.rs b/crates/editor/src/multi_buffer.rs index 23ee7df657..d9bb77f1eb 100644 --- a/crates/editor/src/multi_buffer.rs +++ b/crates/editor/src/multi_buffer.rs @@ -9,10 +9,10 @@ use gpui::{AppContext, Entity, ModelContext, ModelHandle, Task}; pub use language::Completion; use language::{ char_kind, AutoindentMode, Buffer, BufferChunks, BufferSnapshot, CharKind, Chunk, - DiagnosticEntry, Event, File, IndentSize, Language, OffsetRangeExt, Outline, OutlineItem, - Selection, ToOffset as _, ToOffsetUtf16 as _, ToPoint as _, ToPointUtf16 as _, TransactionId, + DiagnosticEntry, Event, File, IndentSize, Language, OffsetRangeExt, OffsetUtf16, Outline, + OutlineItem, Point, PointUtf16, Selection, TextDimension, ToOffset as _, ToOffsetUtf16 as _, + ToPoint as _, ToPointUtf16 as _, TransactionId, }; -use rope::{offset_utf16::OffsetUtf16, point::Point, point_utf16::PointUtf16, TextDimension}; use smallvec::SmallVec; use std::{ borrow::Cow, @@ -168,7 +168,7 @@ struct ExcerptChunks<'a> { } struct ExcerptBytes<'a> { - content_bytes: rope::Bytes<'a>, + content_bytes: text::Bytes<'a>, footer_height: usize, } diff --git a/crates/editor/src/multi_buffer/anchor.rs b/crates/editor/src/multi_buffer/anchor.rs index b30e4b5780..43723b95fc 100644 --- a/crates/editor/src/multi_buffer/anchor.rs +++ b/crates/editor/src/multi_buffer/anchor.rs @@ -1,5 +1,5 @@ use super::{ExcerptId, MultiBufferSnapshot, ToOffset, ToOffsetUtf16, ToPoint}; -use rope::{offset_utf16::OffsetUtf16, point::Point, TextDimension}; +use language::{OffsetUtf16, Point, TextDimension}; use std::{ cmp::Ordering, ops::{Range, Sub}, diff --git a/crates/editor/src/selections_collection.rs b/crates/editor/src/selections_collection.rs index ed983d22d9..999f410db5 100644 --- a/crates/editor/src/selections_collection.rs +++ b/crates/editor/src/selections_collection.rs @@ -8,8 +8,7 @@ use std::{ use collections::HashMap; use gpui::{AppContext, ModelHandle, MutableAppContext}; use itertools::Itertools; -use language::{Bias, Selection, SelectionGoal, ToPoint}; -use rope::{point::Point, TextDimension}; +use language::{Bias, Point, Selection, SelectionGoal, TextDimension, ToPoint}; use util::post_inc; use crate::{ diff --git a/crates/git/Cargo.toml b/crates/git/Cargo.toml index 1d15c2b123..66202a489a 100644 --- a/crates/git/Cargo.toml +++ b/crates/git/Cargo.toml @@ -9,7 +9,6 @@ path = "src/git.rs" [dependencies] anyhow = "1.0.38" clock = { path = "../clock" } -rope = { path = "../rope" } lazy_static = "1.4.0" sum_tree = { path = "../sum_tree" } text = { path = "../text" } diff --git a/crates/git/src/diff.rs b/crates/git/src/diff.rs index 7f3f6101ce..803607895a 100644 --- a/crates/git/src/diff.rs +++ b/crates/git/src/diff.rs @@ -1,8 +1,6 @@ use std::ops::Range; - -use rope::point::Point; use sum_tree::SumTree; -use text::{Anchor, BufferSnapshot, OffsetRangeExt}; +use text::{Anchor, BufferSnapshot, OffsetRangeExt, Point}; pub use git2 as libgit; use libgit::{DiffLineType as GitDiffLineType, DiffOptions as GitOptions, Patch as GitPatch}; diff --git a/crates/go_to_line/Cargo.toml b/crates/go_to_line/Cargo.toml index d69b1f239c..93ae96f93e 100644 --- a/crates/go_to_line/Cargo.toml +++ b/crates/go_to_line/Cargo.toml @@ -13,6 +13,5 @@ gpui = { path = "../gpui" } menu = { path = "../menu" } settings = { path = "../settings" } text = { path = "../text" } -rope = { path = "../rope" } workspace = { path = "../workspace" } postage = { version = "0.4", features = ["futures-traits"] } diff --git a/crates/go_to_line/src/go_to_line.rs b/crates/go_to_line/src/go_to_line.rs index 51ff87a943..3ca50cee42 100644 --- a/crates/go_to_line/src/go_to_line.rs +++ b/crates/go_to_line/src/go_to_line.rs @@ -4,9 +4,8 @@ use gpui::{ MutableAppContext, RenderContext, View, ViewContext, ViewHandle, }; use menu::{Cancel, Confirm}; -use rope::point::Point; use settings::Settings; -use text::Bias; +use text::{Bias, Point}; use workspace::Workspace; actions!(go_to_line, [Toggle]); diff --git a/crates/language/Cargo.toml b/crates/language/Cargo.toml index 54d2147929..96feadbfbc 100644 --- a/crates/language/Cargo.toml +++ b/crates/language/Cargo.toml @@ -29,7 +29,6 @@ fs = { path = "../fs" } git = { path = "../git" } gpui = { path = "../gpui" } lsp = { path = "../lsp" } -rope = { path = "../rope" } rpc = { path = "../rpc" } settings = { path = "../settings" } sum_tree = { path = "../sum_tree" } diff --git a/crates/language/src/buffer.rs b/crates/language/src/buffer.rs index a5cf24877c..274777b81c 100644 --- a/crates/language/src/buffer.rs +++ b/crates/language/src/buffer.rs @@ -17,7 +17,6 @@ use fs::LineEnding; use futures::FutureExt as _; use gpui::{fonts::HighlightStyle, AppContext, Entity, ModelContext, MutableAppContext, Task}; use parking_lot::Mutex; -use rope::point::Point; use settings::Settings; use similar::{ChangeTag, TextDiff}; use smol::future::yield_now; @@ -283,7 +282,7 @@ struct BufferChunkHighlights<'a> { pub struct BufferChunks<'a> { range: Range, - chunks: rope::Chunks<'a>, + chunks: text::Chunks<'a>, diagnostic_endpoints: Peekable>, error_depth: usize, warning_depth: usize, diff --git a/crates/language/src/buffer_tests.rs b/crates/language/src/buffer_tests.rs index 313c843b02..0f3ab50f4a 100644 --- a/crates/language/src/buffer_tests.rs +++ b/crates/language/src/buffer_tests.rs @@ -5,7 +5,6 @@ use fs::LineEnding; use gpui::{ModelHandle, MutableAppContext}; use proto::deserialize_operation; use rand::prelude::*; -use rope::point::Point; use settings::Settings; use std::{ cell::RefCell, diff --git a/crates/language/src/diagnostic_set.rs b/crates/language/src/diagnostic_set.rs index dfbc32149c..b52327cac0 100644 --- a/crates/language/src/diagnostic_set.rs +++ b/crates/language/src/diagnostic_set.rs @@ -1,13 +1,12 @@ use crate::Diagnostic; use collections::HashMap; -use rope::point_utf16::PointUtf16; use std::{ cmp::{Ordering, Reverse}, iter, ops::Range, }; use sum_tree::{self, Bias, SumTree}; -use text::{Anchor, FromAnchor, ToOffset}; +use text::{Anchor, FromAnchor, PointUtf16, ToOffset}; #[derive(Clone, Debug, Default)] pub struct DiagnosticSet { diff --git a/crates/language/src/language.rs b/crates/language/src/language.rs index 4f8615606c..bb75edbc32 100644 --- a/crates/language/src/language.rs +++ b/crates/language/src/language.rs @@ -22,7 +22,6 @@ use lazy_static::lazy_static; use parking_lot::{Mutex, RwLock}; use postage::watch; use regex::Regex; -use rope::point_utf16::PointUtf16; use serde::{de, Deserialize, Deserializer}; use serde_json::Value; use std::{ diff --git a/crates/language/src/syntax_map.rs b/crates/language/src/syntax_map.rs index 3992d41081..5dd9c483af 100644 --- a/crates/language/src/syntax_map.rs +++ b/crates/language/src/syntax_map.rs @@ -1,7 +1,6 @@ use crate::{Grammar, InjectionConfig, Language, LanguageRegistry}; use lazy_static::lazy_static; use parking_lot::Mutex; -use rope::point::Point; use std::{ borrow::Cow, cell::RefCell, @@ -11,7 +10,7 @@ use std::{ sync::Arc, }; use sum_tree::{Bias, SeekTarget, SumTree}; -use text::{Anchor, BufferSnapshot, OffsetRangeExt, Rope, ToOffset, ToPoint}; +use text::{Anchor, BufferSnapshot, OffsetRangeExt, Point, Rope, ToOffset, ToPoint}; use tree_sitter::{ Node, Parser, Query, QueryCapture, QueryCaptures, QueryCursor, QueryMatches, Tree, }; @@ -135,7 +134,7 @@ struct ChangeRegionSet(Vec); struct TextProvider<'a>(&'a Rope); -struct ByteChunks<'a>(rope::Chunks<'a>); +struct ByteChunks<'a>(text::Chunks<'a>); struct QueryCursorHandle(Option); diff --git a/crates/project/Cargo.toml b/crates/project/Cargo.toml index 7a41318b86..4e6dc09e4e 100644 --- a/crates/project/Cargo.toml +++ b/crates/project/Cargo.toml @@ -29,7 +29,6 @@ git = { path = "../git" } gpui = { path = "../gpui" } language = { path = "../language" } lsp = { path = "../lsp" } -rope = { path = "../rope" } rpc = { path = "../rpc" } settings = { path = "../settings" } sum_tree = { path = "../sum_tree" } diff --git a/crates/project/src/lsp_command.rs b/crates/project/src/lsp_command.rs index 42098d2e8b..37f6e76340 100644 --- a/crates/project/src/lsp_command.rs +++ b/crates/project/src/lsp_command.rs @@ -8,11 +8,10 @@ use gpui::{AppContext, AsyncAppContext, ModelHandle}; use language::{ point_from_lsp, point_to_lsp, proto::{deserialize_anchor, deserialize_version, serialize_anchor, serialize_version}, - range_from_lsp, Anchor, Bias, Buffer, CachedLspAdapter, ToPointUtf16, + range_from_lsp, Anchor, Bias, Buffer, CachedLspAdapter, PointUtf16, ToPointUtf16, }; use lsp::{DocumentHighlightKind, LanguageServer, ServerCapabilities}; use pulldown_cmark::{CodeBlockKind, Event, Options, Parser, Tag}; -use rope::point_utf16::PointUtf16; use std::{cmp::Reverse, ops::Range, path::Path, sync::Arc}; #[async_trait(?Send)] diff --git a/crates/project/src/project.rs b/crates/project/src/project.rs index de4d76ebc3..17e0d5fafe 100644 --- a/crates/project/src/project.rs +++ b/crates/project/src/project.rs @@ -25,7 +25,7 @@ use language::{ range_from_lsp, range_to_lsp, Anchor, Bias, Buffer, CachedLspAdapter, CharKind, CodeAction, CodeLabel, Completion, Diagnostic, DiagnosticEntry, DiagnosticSet, Event as BufferEvent, File as _, Language, LanguageRegistry, LanguageServerName, LocalFile, OffsetRangeExt, - Operation, Patch, TextBufferSnapshot, ToOffset, ToPointUtf16, Transaction, + Operation, Patch, PointUtf16, TextBufferSnapshot, ToOffset, ToPointUtf16, Transaction, }; use lsp::{ DiagnosticSeverity, DiagnosticTag, DocumentHighlightKind, LanguageServer, LanguageString, @@ -35,7 +35,6 @@ use lsp_command::*; use parking_lot::Mutex; use postage::watch; use rand::prelude::*; -use rope::point_utf16::PointUtf16; use search::SearchQuery; use serde::Serialize; use settings::{FormatOnSave, Formatter, Settings}; diff --git a/crates/project/src/project_tests.rs b/crates/project/src/project_tests.rs index 12da0a75db..a631051c58 100644 --- a/crates/project/src/project_tests.rs +++ b/crates/project/src/project_tests.rs @@ -5,10 +5,9 @@ use futures::{future, StreamExt}; use gpui::{executor::Deterministic, test::subscribe}; use language::{ tree_sitter_rust, tree_sitter_typescript, Diagnostic, FakeLspAdapter, LanguageConfig, - OffsetRangeExt, ToPoint, + OffsetRangeExt, Point, ToPoint, }; use lsp::Url; -use rope::point::Point; use serde_json::json; use std::{cell::RefCell, os::unix, rc::Rc, task::Poll}; use unindent::Unindent as _; diff --git a/crates/project/src/worktree.rs b/crates/project/src/worktree.rs index 0de647029d..f0e9aa7934 100644 --- a/crates/project/src/worktree.rs +++ b/crates/project/src/worktree.rs @@ -22,14 +22,13 @@ use gpui::{ }; use language::{ proto::{deserialize_version, serialize_line_ending, serialize_version}, - Buffer, DiagnosticEntry, Rope, + Buffer, DiagnosticEntry, PointUtf16, Rope, }; use parking_lot::Mutex; use postage::{ prelude::{Sink as _, Stream as _}, watch, }; -use rope::point_utf16::PointUtf16; use smol::channel::{self, Sender}; use std::{ diff --git a/crates/rope/src/rope.rs b/crates/rope/src/rope.rs index 39dc9dc049..8c357801e3 100644 --- a/crates/rope/src/rope.rs +++ b/crates/rope/src/rope.rs @@ -1,16 +1,17 @@ -pub mod offset_utf16; -pub mod point; -pub mod point_utf16; +mod offset_utf16; +mod point; +mod point_utf16; use arrayvec::ArrayString; use bromberg_sl2::{DigestString, HashMatrix}; -use offset_utf16::OffsetUtf16; -use point::Point; -use point_utf16::PointUtf16; use smallvec::SmallVec; use std::{cmp, fmt, io, mem, ops::Range, str}; use sum_tree::{Bias, Dimension, SumTree}; +pub use offset_utf16::OffsetUtf16; +pub use point::Point; +pub use point_utf16::PointUtf16; + #[cfg(test)] const CHUNK_BASE: usize = 6; diff --git a/crates/settings/Cargo.toml b/crates/settings/Cargo.toml index 1cc73fabc4..ad184ad313 100644 --- a/crates/settings/Cargo.toml +++ b/crates/settings/Cargo.toml @@ -19,7 +19,6 @@ anyhow = "1.0.38" futures = "0.3" theme = { path = "../theme" } util = { path = "../util" } -rope = { path = "../rope" } json_comments = "0.2" postage = { version = "0.4.1", features = ["futures-traits"] } schemars = "0.8" diff --git a/crates/text/src/anchor.rs b/crates/text/src/anchor.rs index 024c7e643b..68ec00056a 100644 --- a/crates/text/src/anchor.rs +++ b/crates/text/src/anchor.rs @@ -1,10 +1,8 @@ +use crate::{BufferSnapshot, Point, PointUtf16, TextDimension, ToOffset, ToPoint, ToPointUtf16}; use anyhow::Result; -use rope::{point::Point, point_utf16::PointUtf16, TextDimension}; use std::{cmp::Ordering, fmt::Debug, ops::Range}; use sum_tree::Bias; -use crate::{BufferSnapshot, ToOffset, ToPoint, ToPointUtf16}; - #[derive(Copy, Clone, Eq, PartialEq, Debug, Hash, Default)] pub struct Anchor { pub timestamp: clock::Local, diff --git a/crates/text/src/selection.rs b/crates/text/src/selection.rs index 881fc8c432..d4f55a043b 100644 --- a/crates/text/src/selection.rs +++ b/crates/text/src/selection.rs @@ -1,7 +1,4 @@ -use rope::TextDimension; - -use crate::{Anchor, BufferSnapshot}; - +use crate::{Anchor, BufferSnapshot, TextDimension}; use std::cmp::Ordering; use std::ops::Range; diff --git a/crates/text/src/text.rs b/crates/text/src/text.rs index 2196e870f2..72ae018a16 100644 --- a/crates/text/src/text.rs +++ b/crates/text/src/text.rs @@ -19,9 +19,10 @@ use locator::Locator; use operation_queue::OperationQueue; pub use patch::Patch; use postage::{barrier, oneshot, prelude::*}; -use rope::{offset_utf16::OffsetUtf16, point::Point, point_utf16::PointUtf16, TextDimension}; -pub use rope::{Chunks, Rope, TextSummary}; + +pub use rope::*; pub use selection::*; + use std::{ cmp::{self, Ordering, Reverse}, future::Future, diff --git a/crates/vim/Cargo.toml b/crates/vim/Cargo.toml index 85c9636c69..44f2a8cb16 100644 --- a/crates/vim/Cargo.toml +++ b/crates/vim/Cargo.toml @@ -27,7 +27,6 @@ command_palette = { path = "../command_palette" } editor = { path = "../editor" } gpui = { path = "../gpui" } language = { path = "../language" } -rope = { path = "../rope" } search = { path = "../search" } settings = { path = "../settings" } workspace = { path = "../workspace" } diff --git a/crates/vim/src/normal.rs b/crates/vim/src/normal.rs index 6741d8ac0b..894b77e6e8 100644 --- a/crates/vim/src/normal.rs +++ b/crates/vim/src/normal.rs @@ -15,8 +15,7 @@ use editor::{ display_map::ToDisplayPoint, Anchor, Autoscroll, Bias, ClipboardSelection, DisplayPoint, }; use gpui::{actions, MutableAppContext, ViewContext}; -use language::{AutoindentMode, SelectionGoal}; -use rope::point::Point; +use language::{AutoindentMode, Point, SelectionGoal}; use workspace::Workspace; use self::{ diff --git a/crates/vim/src/test/neovim_backed_test_context.rs b/crates/vim/src/test/neovim_backed_test_context.rs index bdac8fe158..e66099963b 100644 --- a/crates/vim/src/test/neovim_backed_test_context.rs +++ b/crates/vim/src/test/neovim_backed_test_context.rs @@ -2,7 +2,7 @@ use std::ops::{Deref, DerefMut}; use collections::{HashMap, HashSet}; use gpui::ContextHandle; -use language::OffsetRangeExt; +use language::{OffsetRangeExt, Point}; use util::test::marked_text_offsets; use super::{neovim_connection::NeovimConnection, NeovimBackedBindingTestContext, VimTestContext}; @@ -51,7 +51,7 @@ impl<'a> NeovimBackedTestContext<'a> { pub async fn set_shared_state(&mut self, marked_text: &str) -> ContextHandle { let context_handle = self.set_state(marked_text, Mode::Normal); - let selection = self.editor(|editor, cx| editor.selections.newest::(cx)); + let selection = self.editor(|editor, cx| editor.selections.newest::(cx)); let text = self.buffer_text(); self.neovim.set_state(selection, &text).await; diff --git a/crates/vim/src/test/neovim_connection.rs b/crates/vim/src/test/neovim_connection.rs index 60ac345323..e2522a76aa 100644 --- a/crates/vim/src/test/neovim_connection.rs +++ b/crates/vim/src/test/neovim_connection.rs @@ -9,8 +9,7 @@ use async_trait::async_trait; #[cfg(feature = "neovim")] use gpui::keymap::Keystroke; -use language::Selection; -use rope::point::Point; +use language::{Point, Selection}; #[cfg(feature = "neovim")] use lazy_static::lazy_static;