3
3
//!
4
4
//! It can be viewed as a dual for `AnalysisChange`.
5
5
6
- use ra_db:: RelativePathBuf ;
7
- use ra_text_edit:: TextEdit ;
8
-
9
- use crate :: { FileId , FilePosition , SourceRootId , TextSize } ;
6
+ use ra_db:: { FileId , FilePosition , RelativePathBuf , SourceRootId } ;
7
+ use ra_text_edit:: { TextEdit , TextSize } ;
10
8
11
9
#[ derive( Debug ) ]
12
10
pub struct SourceChange {
11
+ /// For display in the undo log in the editor
13
12
pub label : String ,
14
13
pub source_file_edits : Vec < SourceFileEdit > ,
15
14
pub file_system_edits : Vec < FileSystemEdit > ,
@@ -19,7 +18,7 @@ pub struct SourceChange {
19
18
impl SourceChange {
20
19
/// Creates a new SourceChange with the given label
21
20
/// from the edits.
22
- pub ( crate ) fn from_edits < L : Into < String > > (
21
+ pub fn from_edits < L : Into < String > > (
23
22
label : L ,
24
23
source_file_edits : Vec < SourceFileEdit > ,
25
24
file_system_edits : Vec < FileSystemEdit > ,
@@ -34,7 +33,7 @@ impl SourceChange {
34
33
35
34
/// Creates a new SourceChange with the given label,
36
35
/// containing only the given `SourceFileEdits`.
37
- pub ( crate ) fn source_file_edits < L : Into < String > > ( label : L , edits : Vec < SourceFileEdit > ) -> Self {
36
+ pub fn source_file_edits < L : Into < String > > ( label : L , edits : Vec < SourceFileEdit > ) -> Self {
38
37
let label = label. into ( ) ;
39
38
assert ! ( label. starts_with( char :: is_uppercase) ) ;
40
39
SourceChange {
@@ -58,13 +57,13 @@ impl SourceChange {
58
57
59
58
/// Creates a new SourceChange with the given label,
60
59
/// containing only a single `SourceFileEdit`.
61
- pub ( crate ) fn source_file_edit < L : Into < String > > ( label : L , edit : SourceFileEdit ) -> Self {
60
+ pub fn source_file_edit < L : Into < String > > ( label : L , edit : SourceFileEdit ) -> Self {
62
61
SourceChange :: source_file_edits ( label, vec ! [ edit] )
63
62
}
64
63
65
64
/// Creates a new SourceChange with the given label
66
65
/// from the given `FileId` and `TextEdit`
67
- pub ( crate ) fn source_file_edit_from < L : Into < String > > (
66
+ pub fn source_file_edit_from < L : Into < String > > (
68
67
label : L ,
69
68
file_id : FileId ,
70
69
edit : TextEdit ,
@@ -74,18 +73,18 @@ impl SourceChange {
74
73
75
74
/// Creates a new SourceChange with the given label
76
75
/// from the given `FileId` and `TextEdit`
77
- pub ( crate ) fn file_system_edit < L : Into < String > > ( label : L , edit : FileSystemEdit ) -> Self {
76
+ pub fn file_system_edit < L : Into < String > > ( label : L , edit : FileSystemEdit ) -> Self {
78
77
SourceChange :: file_system_edits ( label, vec ! [ edit] )
79
78
}
80
79
81
80
/// Sets the cursor position to the given `FilePosition`
82
- pub ( crate ) fn with_cursor ( mut self , cursor_position : FilePosition ) -> Self {
81
+ pub fn with_cursor ( mut self , cursor_position : FilePosition ) -> Self {
83
82
self . cursor_position = Some ( cursor_position) ;
84
83
self
85
84
}
86
85
87
86
/// Sets the cursor position to the given `FilePosition`
88
- pub ( crate ) fn with_cursor_opt ( mut self , cursor_position : Option < FilePosition > ) -> Self {
87
+ pub fn with_cursor_opt ( mut self , cursor_position : Option < FilePosition > ) -> Self {
89
88
self . cursor_position = cursor_position;
90
89
self
91
90
}
@@ -103,14 +102,14 @@ pub enum FileSystemEdit {
103
102
MoveFile { src : FileId , dst_source_root : SourceRootId , dst_path : RelativePathBuf } ,
104
103
}
105
104
106
- pub ( crate ) struct SingleFileChange {
105
+ pub struct SingleFileChange {
107
106
pub label : String ,
108
107
pub edit : TextEdit ,
109
108
pub cursor_position : Option < TextSize > ,
110
109
}
111
110
112
111
impl SingleFileChange {
113
- pub ( crate ) fn into_source_change ( self , file_id : FileId ) -> SourceChange {
112
+ pub fn into_source_change ( self , file_id : FileId ) -> SourceChange {
114
113
SourceChange {
115
114
label : self . label ,
116
115
source_file_edits : vec ! [ SourceFileEdit { file_id, edit: self . edit } ] ,
0 commit comments