@@ -268,6 +268,44 @@ def __init__( self, location: Location, chunks, text = '', kind = None ):
268268 self .kind = kind
269269
270270
271+ class DeleteChunk :
272+ def __init__ ( self , filepath ):
273+ self .filepath = filepath
274+ self .kind = 'delete'
275+
276+ def ToYcmdProtocol ( self ):
277+ return {
278+ 'filepath' : self .filepath ,
279+ 'kind' : self .kind
280+ }
281+
282+
283+ class CreateChunk :
284+ def __init__ ( self , filepath ):
285+ self .filepath = filepath
286+ self .kind = 'create'
287+
288+ def ToYcmdProtocol ( self ):
289+ return {
290+ 'filepath' : self .filepath ,
291+ 'kind' : self .kind
292+ }
293+
294+
295+ class RenameChunk :
296+ def __init__ ( self , old_filepath , new_filepath ):
297+ self .old_filepath = old_filepath
298+ self .new_filepath = new_filepath
299+ self .kind = 'rename'
300+
301+ def ToYcmdProtocol ( self ):
302+ return {
303+ 'new_filepath' : self .new_filepath ,
304+ 'old_filepath' : self .old_filepath ,
305+ 'kind' : self .kind
306+ }
307+
308+
271309class FixItChunk :
272310 """An individual replacement within a FixIt (aka Refactor)"""
273311
@@ -276,6 +314,12 @@ def __init__( self, replacement_text: str, range: Range ):
276314 self .replacement_text = replacement_text
277315 self .range = range
278316
317+ def ToYcmdProtocol ( self ):
318+ return {
319+ 'replacement_text' : self .replacement_text ,
320+ 'range' : BuildRangeData ( self .range ),
321+ }
322+
279323
280324def BuildDiagnosticData ( diagnostic ):
281325 kind = ( diagnostic .kind_ .name if hasattr ( diagnostic .kind_ , 'name' )
@@ -314,12 +358,6 @@ def BuildFixItResponse( fixits ):
314358 can be used to apply arbitrary changes to arbitrary files and is suitable for
315359 both quick fix and refactor operations"""
316360
317- def BuildFixitChunkData ( chunk ):
318- return {
319- 'replacement_text' : chunk .replacement_text ,
320- 'range' : BuildRangeData ( chunk .range ),
321- }
322-
323361 def BuildFixItData ( fixit ):
324362 if hasattr ( fixit , 'resolve' ):
325363 result = {
@@ -331,7 +369,7 @@ def BuildFixItData( fixit ):
331369 else :
332370 result = {
333371 'location' : BuildLocationData ( fixit .location ),
334- 'chunks' : [ BuildFixitChunkData ( x ) for x in fixit .chunks ],
372+ 'chunks' : [ x . ToYcmdProtocol ( ) for x in fixit .chunks ],
335373 'text' : fixit .text ,
336374 'kind' : fixit .kind ,
337375 'resolve' : False
0 commit comments