@@ -160,10 +160,7 @@ static sourcekitd_response_t reportDocInfo(llvm::MemoryBuffer *InputBuf,
160
160
StringRef ModuleName,
161
161
ArrayRef<const char *> Args);
162
162
163
- static void reportCursorInfo (StringRef Filename,
164
- int64_t Offset,
165
- ArrayRef<const char *> Args,
166
- ResponseReceiver Rec);
163
+ static void reportCursorInfo (const CursorInfo &Info, ResponseReceiver Rec);
167
164
168
165
static void findRelatedIdents (StringRef Filename,
169
166
int64_t Offset,
@@ -707,7 +704,10 @@ handleSemanticRequest(RequestDict Req,
707
704
int64_t Offset;
708
705
if (Req.getInt64 (KeyOffset, Offset, /* isOptional=*/ false ))
709
706
return Rec (createErrorRequestInvalid (" missing 'key.offset'" ));
710
- return reportCursorInfo (*SourceFile, Offset, Args, Rec);
707
+ LangSupport &Lang = getGlobalContext ().getSwiftLangSupport ();
708
+ return Lang.getCursorInfo (
709
+ *SourceFile, Offset, Args,
710
+ [Rec](const CursorInfo &Info) { reportCursorInfo (Info, Rec); });
711
711
}
712
712
713
713
if (ReqUID == RequestRelatedIdents) {
@@ -1249,65 +1249,60 @@ bool SKDocConsumer::handleDiagnostic(const DiagnosticEntryInfo &Info) {
1249
1249
// ReportCursorInfo
1250
1250
// ===----------------------------------------------------------------------===//
1251
1251
1252
- static void reportCursorInfo (StringRef Filename,
1253
- int64_t Offset,
1254
- ArrayRef<const char *> Args,
1255
- ResponseReceiver Rec) {
1256
- LangSupport &Lang = getGlobalContext ().getSwiftLangSupport ();
1257
- Lang.getCursorInfo (Filename, Offset, Args, [Rec](const CursorInfo &Info) {
1258
- if (Info.IsCancelled )
1259
- return Rec (createErrorRequestCancelled ());
1252
+ static void reportCursorInfo (const CursorInfo &Info, ResponseReceiver Rec) {
1260
1253
1261
- ResponseBuilder RespBuilder;
1262
- if (Info.Kind .isInvalid ())
1263
- return Rec (RespBuilder.createResponse ());
1254
+ if (Info.IsCancelled )
1255
+ return Rec (createErrorRequestCancelled ());
1264
1256
1265
- auto Elem = RespBuilder.getDictionary ();
1266
- Elem.set (KeyKind, Info.Kind );
1267
- Elem.set (KeyName, Info.Name );
1268
- if (!Info.USR .empty ())
1269
- Elem.set (KeyUSR, Info.USR );
1270
- if (!Info.TypeName .empty ())
1271
- Elem.set (KeyTypeName, Info.TypeName );
1272
- if (!Info.DocComment .empty ())
1273
- Elem.set (KeyDocFullAsXML, Info.DocComment );
1274
- if (!Info.AnnotatedDeclaration .empty ())
1275
- Elem.set (KeyAnnotatedDecl, Info.AnnotatedDeclaration );
1276
- if (!Info.FullyAnnotatedDeclaration .empty ())
1277
- Elem.set (KeyFullyAnnotatedDecl, Info.FullyAnnotatedDeclaration );
1278
- if (!Info.ModuleName .empty ())
1279
- Elem.set (KeyModuleName, Info.ModuleName );
1280
- if (!Info.GroupName .empty ())
1281
- Elem.set (KeyGroupName, Info.GroupName );
1282
- if (!Info.ModuleInterfaceName .empty ())
1283
- Elem.set (KeyModuleInterfaceName, Info.ModuleInterfaceName );
1284
- if (Info.DeclarationLoc .hasValue ()) {
1285
- Elem.set (KeyOffset, Info.DeclarationLoc .getValue ().first );
1286
- Elem.set (KeyLength, Info.DeclarationLoc .getValue ().second );
1287
- if (!Info.Filename .empty ())
1288
- Elem.set (KeyFilePath, Info.Filename );
1289
- }
1290
- if (!Info.OverrideUSRs .empty ()) {
1291
- auto Overrides = Elem.setArray (KeyOverrides);
1292
- for (auto USR : Info.OverrideUSRs ) {
1293
- auto Override = Overrides.appendDictionary ();
1294
- Override.set (KeyUSR, USR);
1295
- }
1257
+ ResponseBuilder RespBuilder;
1258
+ if (Info.Kind .isInvalid ())
1259
+ return Rec (RespBuilder.createResponse ());
1260
+
1261
+ auto Elem = RespBuilder.getDictionary ();
1262
+ Elem.set (KeyKind, Info.Kind );
1263
+ Elem.set (KeyName, Info.Name );
1264
+ if (!Info.USR .empty ())
1265
+ Elem.set (KeyUSR, Info.USR );
1266
+ if (!Info.TypeName .empty ())
1267
+ Elem.set (KeyTypeName, Info.TypeName );
1268
+ if (!Info.DocComment .empty ())
1269
+ Elem.set (KeyDocFullAsXML, Info.DocComment );
1270
+ if (!Info.AnnotatedDeclaration .empty ())
1271
+ Elem.set (KeyAnnotatedDecl, Info.AnnotatedDeclaration );
1272
+ if (!Info.FullyAnnotatedDeclaration .empty ())
1273
+ Elem.set (KeyFullyAnnotatedDecl, Info.FullyAnnotatedDeclaration );
1274
+ if (!Info.ModuleName .empty ())
1275
+ Elem.set (KeyModuleName, Info.ModuleName );
1276
+ if (!Info.GroupName .empty ())
1277
+ Elem.set (KeyGroupName, Info.GroupName );
1278
+ if (!Info.ModuleInterfaceName .empty ())
1279
+ Elem.set (KeyModuleInterfaceName, Info.ModuleInterfaceName );
1280
+ if (Info.DeclarationLoc .hasValue ()) {
1281
+ Elem.set (KeyOffset, Info.DeclarationLoc .getValue ().first );
1282
+ Elem.set (KeyLength, Info.DeclarationLoc .getValue ().second );
1283
+ if (!Info.Filename .empty ())
1284
+ Elem.set (KeyFilePath, Info.Filename );
1285
+ }
1286
+ if (!Info.OverrideUSRs .empty ()) {
1287
+ auto Overrides = Elem.setArray (KeyOverrides);
1288
+ for (auto USR : Info.OverrideUSRs ) {
1289
+ auto Override = Overrides.appendDictionary ();
1290
+ Override.set (KeyUSR, USR);
1296
1291
}
1297
- if (!Info. AnnotatedRelatedDeclarations . empty ()) {
1298
- auto RelDecls = Elem. setArray (KeyRelatedDecls);
1299
- for ( auto AnnotDecl : Info. AnnotatedRelatedDeclarations ) {
1300
- auto RelDecl = RelDecls. appendDictionary ();
1301
- RelDecl. set (KeyAnnotatedDecl, AnnotDecl );
1302
- }
1292
+ }
1293
+ if (!Info. AnnotatedRelatedDeclarations . empty ()) {
1294
+ auto RelDecls = Elem. setArray (KeyRelatedDecls);
1295
+ for ( auto AnnotDecl : Info. AnnotatedRelatedDeclarations ) {
1296
+ auto RelDecl = RelDecls. appendDictionary ( );
1297
+ RelDecl. set (KeyAnnotatedDecl, AnnotDecl);
1303
1298
}
1304
- if (Info.IsSystem )
1305
- Elem.setBool (KeyIsSystem, true );
1306
- if (!Info.TypeInterface .empty ())
1307
- Elem.set (KeyTypeInterface, Info.TypeInterface );
1299
+ }
1300
+ if (Info.IsSystem )
1301
+ Elem.setBool (KeyIsSystem, true );
1302
+ if (!Info.TypeInterface .empty ())
1303
+ Elem.set (KeyTypeInterface, Info.TypeInterface );
1308
1304
1309
- return Rec (RespBuilder.createResponse ());
1310
- });
1305
+ return Rec (RespBuilder.createResponse ());
1311
1306
}
1312
1307
1313
1308
// ===----------------------------------------------------------------------===//
0 commit comments