@@ -15,6 +15,8 @@ import refactor.discover.UsageCollector;
15
15
import refactor .discover .UsageContext ;
16
16
import refactor .refactor .CanRefactorContext ;
17
17
import refactor .refactor .RefactorContext ;
18
+ import refactor .rename .CanRenameContext ;
19
+ import refactor .rename .RenameContext ;
18
20
import tokentree .TokenTree ;
19
21
20
22
using haxeLanguageServer .helper .PathHelper ;
@@ -23,8 +25,8 @@ class RefactorCache {
23
25
final context : Context ;
24
26
25
27
public final cache : IFileCache ;
26
- public final converter : Haxe3DisplayOffsetConverter ;
27
28
public final typer : LanguageServerTyper ;
29
+ public final converter : Haxe3DisplayOffsetConverter ;
28
30
public final usageCollector : UsageCollector ;
29
31
public final nameMap : NameMap ;
30
32
public final fileList : FileList ;
@@ -35,8 +37,8 @@ class RefactorCache {
35
37
this .context = context ;
36
38
37
39
cache = new MemCache ();
38
- typer = new LanguageServerTyper (context );
39
40
converter = new Haxe3DisplayOffsetConverter ();
41
+ typer = new LanguageServerTyper (context );
40
42
usageCollector = new UsageCollector ();
41
43
nameMap = new NameMap ();
42
44
fileList = new FileList ();
@@ -151,6 +153,52 @@ class RefactorCache {
151
153
};
152
154
}
153
155
156
+ public function makeCanRenameContext (doc : HaxeDocument , filePath : FsPath , position : Position ): CanRenameContext {
157
+ return {
158
+ nameMap : nameMap ,
159
+ fileList : fileList ,
160
+ typeList : typeList ,
161
+ what : {
162
+ fileName : filePath .toString (),
163
+ toName : " " ,
164
+ pos : converter .characterOffsetToByteOffset (doc .content , doc .offsetAt (position ))
165
+ },
166
+ verboseLog : function (text : String , ? pos : PosInfos ) {
167
+ #if debug
168
+ trace (' [canRename] $text ' );
169
+ #end
170
+ },
171
+
172
+ typer : typer ,
173
+ fileReader : readFile ,
174
+ converter : converter .byteOffsetToCharacterOffset ,
175
+ };
176
+ }
177
+
178
+ public function makeRenameContext (doc : HaxeDocument , filePath : FsPath , position : Position , newName : String , editList : EditList ): RenameContext {
179
+ return {
180
+ nameMap : nameMap ,
181
+ fileList : fileList ,
182
+ typeList : typeList ,
183
+ what : {
184
+ fileName : filePath .toString (),
185
+ toName : newName ,
186
+ pos : converter .characterOffsetToByteOffset (doc .content , doc .offsetAt (position ))
187
+ },
188
+ forRealExecute : true ,
189
+ docFactory : (filePath : String ) -> new EditDoc (new FsPath (filePath ), editList , context , converter ),
190
+ verboseLog : function (text : String , ? pos : PosInfos ) {
191
+ #if debug
192
+ trace (' [rename] $text ' );
193
+ #end
194
+ },
195
+
196
+ typer : typer ,
197
+ fileReader : readFile ,
198
+ converter : converter .byteOffsetToCharacterOffset ,
199
+ };
200
+ }
201
+
154
202
public function makeCanRefactorContext (doc : Null <HaxeDocument >, range : Range ): Null <CanRefactorContext > {
155
203
if (doc == null ) {
156
204
return null ;
0 commit comments