Re-export basic text types from text and language crates

Also avoid production dependencies on fs and rope in collab
This commit is contained in:
Max Brunsfeld
2022-10-12 15:48:19 -07:00
parent fedec68d39
commit 6cdf4e98fc
43 changed files with 51 additions and 102 deletions
+1 -2
View File
@@ -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};
+1 -2
View File
@@ -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},
+1 -2
View File
@@ -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},
+3 -5
View File
@@ -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,
+1 -2
View File
@@ -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};
+2 -3
View File
@@ -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;
+1 -2
View File
@@ -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,
+1 -2
View File
@@ -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::{
+1 -2
View File
@@ -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;
+1 -3
View File
@@ -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]
+4 -4
View File
@@ -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,
}
+1 -1
View File
@@ -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},
+1 -2
View File
@@ -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::{