@@ -489,6 +489,23 @@ static int handleTestInvocation(ArrayRef<const char *> Args,
489
489
return 0 ;
490
490
}
491
491
492
+ static void setRefactoringFields (sourcekitd_object_t &Req, TestOptions Opts,
493
+ sourcekitd_uid_t RefactoringKind,
494
+ llvm::MemoryBuffer *SourceBuf) {
495
+ if (Opts.Offset && !Opts.Line && !Opts.Col ) {
496
+ auto LineCol = resolveToLineCol (Opts.Offset , SourceBuf);
497
+ Opts.Line = LineCol.first ;
498
+ Opts.Col = LineCol.second ;
499
+ }
500
+ sourcekitd_request_dictionary_set_uid (Req, KeyRequest,
501
+ RequestSemanticRefactoring);
502
+ sourcekitd_request_dictionary_set_uid (Req, KeyActionUID, RefactoringKind);
503
+ sourcekitd_request_dictionary_set_string (Req, KeyName, Opts.Name .c_str ());
504
+ sourcekitd_request_dictionary_set_int64 (Req, KeyLine, Opts.Line );
505
+ sourcekitd_request_dictionary_set_int64 (Req, KeyColumn, Opts.Col );
506
+ sourcekitd_request_dictionary_set_int64 (Req, KeyLength, Opts.Length );
507
+ }
508
+
492
509
static int handleTestInvocation (TestOptions Opts, TestOptions &InitOpts) {
493
510
if (!Opts.JsonRequestPath .empty ())
494
511
return handleJsonRequestPath (Opts.JsonRequestPath , Opts);
@@ -721,16 +738,10 @@ static int handleTestInvocation(TestOptions Opts, TestOptions &InitOpts) {
721
738
break ;
722
739
}
723
740
724
- #define SEMANTIC_REFACTORING (KIND, NAME, ID ) case SourceKitRequest::KIND: \
725
- { \
726
- sourcekitd_request_dictionary_set_uid (Req, KeyRequest, RequestSemanticRefactoring); \
727
- sourcekitd_request_dictionary_set_uid (Req, KeyActionUID, KindRefactoring##KIND); \
728
- sourcekitd_request_dictionary_set_string (Req, KeyName, Opts.Name .c_str ()); \
729
- sourcekitd_request_dictionary_set_int64 (Req, KeyLine, Opts.Line ); \
730
- sourcekitd_request_dictionary_set_int64 (Req, KeyColumn, Opts.Col ); \
731
- sourcekitd_request_dictionary_set_int64 (Req, KeyLength, Opts.Length ); \
732
- break ; \
733
- }
741
+ #define SEMANTIC_REFACTORING (KIND, NAME, ID ) \
742
+ case SourceKitRequest::KIND: \
743
+ setRefactoringFields (Req, Opts, KindRefactoring##KIND, SourceBuf.get ()); \
744
+ break ;
734
745
#include " swift/IDE/RefactoringKinds.def"
735
746
736
747
case SourceKitRequest::MarkupToXML: {
0 commit comments