editor_addition_map.rs

  1#![allow(unused)]
  2// TODO kb
  3
  4use std::ops::{Add, AddAssign, Range, Sub};
  5
  6use crate::MultiBufferSnapshot;
  7
  8use super::{
  9    suggestion_map::{SuggestionEdit, SuggestionPoint, SuggestionSnapshot},
 10    TextHighlights,
 11};
 12use gpui::fonts::HighlightStyle;
 13use language::{Chunk, Edit, Point, TextSummary};
 14use rand::Rng;
 15use sum_tree::Bias;
 16
 17pub struct EditorAdditionMap;
 18
 19#[derive(Clone)]
 20pub struct EditorAdditionSnapshot {
 21    // TODO kb merge these two together
 22    pub suggestion_snapshot: SuggestionSnapshot,
 23    pub version: usize,
 24}
 25
 26pub type EditorAdditionEdit = Edit<EditorAdditionOffset>;
 27
 28#[derive(Copy, Clone, Debug, Default, Eq, Ord, PartialOrd, PartialEq)]
 29pub struct EditorAdditionOffset(pub usize);
 30
 31impl Add for EditorAdditionOffset {
 32    type Output = Self;
 33
 34    fn add(self, rhs: Self) -> Self::Output {
 35        Self(self.0 + rhs.0)
 36    }
 37}
 38
 39impl Sub for EditorAdditionOffset {
 40    type Output = Self;
 41
 42    fn sub(self, rhs: Self) -> Self::Output {
 43        Self(self.0 - rhs.0)
 44    }
 45}
 46
 47impl AddAssign for EditorAdditionOffset {
 48    fn add_assign(&mut self, rhs: Self) {
 49        self.0 += rhs.0;
 50    }
 51}
 52
 53#[derive(Copy, Clone, Debug, Default, Eq, Ord, PartialOrd, PartialEq)]
 54pub struct EditorAdditionPoint(pub Point);
 55
 56#[derive(Clone)]
 57pub struct EditorAdditionBufferRows<'a> {
 58    _z: &'a std::marker::PhantomData<()>,
 59}
 60
 61#[derive(Clone)]
 62pub struct EditorAdditionChunks<'a> {
 63    _z: &'a std::marker::PhantomData<()>,
 64}
 65
 66impl<'a> Iterator for EditorAdditionChunks<'a> {
 67    type Item = Chunk<'a>;
 68
 69    fn next(&mut self) -> Option<Self::Item> {
 70        todo!("TODO kb")
 71    }
 72}
 73
 74impl<'a> Iterator for EditorAdditionBufferRows<'a> {
 75    type Item = Option<u32>;
 76
 77    fn next(&mut self) -> Option<Self::Item> {
 78        todo!("TODO kb")
 79    }
 80}
 81
 82impl EditorAdditionPoint {
 83    pub fn new(row: u32, column: u32) -> Self {
 84        Self(Point::new(row, column))
 85    }
 86
 87    pub fn row(self) -> u32 {
 88        self.0.row
 89    }
 90
 91    pub fn column(self) -> u32 {
 92        self.0.column
 93    }
 94}
 95
 96impl EditorAdditionMap {
 97    pub fn new(suggestion_snapshot: SuggestionSnapshot) -> (Self, EditorAdditionSnapshot) {
 98        todo!("TODO kb")
 99    }
100
101    pub fn sync(
102        &self,
103        suggestion_snapshot: SuggestionSnapshot,
104        suggestion_edits: Vec<SuggestionEdit>,
105    ) -> (EditorAdditionSnapshot, Vec<EditorAdditionEdit>) {
106        todo!("TODO kb")
107    }
108
109    pub fn randomly_mutate(
110        &self,
111        rng: &mut impl Rng,
112    ) -> (EditorAdditionSnapshot, Vec<EditorAdditionEdit>) {
113        todo!("TODO kb")
114    }
115}
116
117impl EditorAdditionSnapshot {
118    pub fn buffer_snapshot(&self) -> &MultiBufferSnapshot {
119        todo!("TODO kb")
120    }
121
122    pub fn to_point(&self, offset: EditorAdditionOffset) -> EditorAdditionPoint {
123        todo!("TODO kb")
124    }
125
126    pub fn max_point(&self) -> EditorAdditionPoint {
127        todo!("TODO kb")
128    }
129
130    pub fn to_offset(&self, point: EditorAdditionPoint) -> EditorAdditionOffset {
131        todo!("TODO kb")
132    }
133
134    pub fn chars_at(&self, start: EditorAdditionPoint) -> impl '_ + Iterator<Item = char> {
135        Vec::new().into_iter()
136    }
137
138    pub fn to_suggestion_point(&self, point: EditorAdditionPoint, bias: Bias) -> SuggestionPoint {
139        todo!("TODO kb")
140    }
141
142    pub fn to_editor_addition_point(&self, point: SuggestionPoint) -> EditorAdditionPoint {
143        todo!("TODO kb")
144    }
145
146    pub fn clip_point(&self, point: EditorAdditionPoint, bias: Bias) -> EditorAdditionPoint {
147        todo!("TODO kb")
148    }
149
150    pub fn text_summary_for_range(&self, range: Range<EditorAdditionPoint>) -> TextSummary {
151        todo!("TODO kb")
152    }
153
154    pub fn buffer_rows<'a>(&'a self, row: u32) -> EditorAdditionBufferRows<'a> {
155        todo!("TODO kb")
156    }
157
158    pub fn line_len(&self, row: u32) -> u32 {
159        todo!("TODO kb")
160    }
161
162    pub fn chunks<'a>(
163        &'a self,
164        range: Range<EditorAdditionOffset>,
165        language_aware: bool,
166        text_highlights: Option<&'a TextHighlights>,
167        suggestion_highlight: Option<HighlightStyle>,
168    ) -> EditorAdditionChunks<'a> {
169        todo!("TODO kb")
170    }
171
172    #[cfg(test)]
173    pub fn text(&self) -> String {
174        todo!("TODO kb")
175    }
176}