@@ -68,6 +68,7 @@ static void printCursorInfo(sourcekitd_variant_t Info, StringRef Filename,
6868static void printNameTranslationInfo (sourcekitd_variant_t Info, llvm::raw_ostream &OS);
6969static void printRangeInfo (sourcekitd_variant_t Info, StringRef Filename,
7070 llvm::raw_ostream &OS);
71+ static void printExpressionType (sourcekitd_variant_t Info, llvm::raw_ostream &OS);
7172static void printDocInfo (sourcekitd_variant_t Info, StringRef Filename);
7273static void printInterfaceGen (sourcekitd_variant_t Info, bool CheckASCII);
7374static void printSemanticInfo ();
@@ -614,6 +615,11 @@ static int handleTestInvocation(TestOptions Opts, TestOptions &InitOpts) {
614615 break ;
615616 }
616617
618+ case SourceKitRequest::CollectExpresstionType: {
619+ sourcekitd_request_dictionary_set_uid (Req, KeyRequest, RequestCollectExpressionType);
620+ break ;
621+ }
622+
617623#define SEMANTIC_REFACTORING (KIND, NAME, ID ) case SourceKitRequest::KIND: \
618624 { \
619625 sourcekitd_request_dictionary_set_uid (Req, KeyRequest, RequestSemanticRefactoring); \
@@ -1057,6 +1063,10 @@ static bool handleResponse(sourcekitd_response_t Resp, const TestOptions &Opts,
10571063 printRangeInfo (Info, SourceFile, llvm::outs ());
10581064 break ;
10591065
1066+ case SourceKitRequest::CollectExpresstionType:
1067+ printExpressionType (Info, llvm::outs ());
1068+ break ;
1069+
10601070 case SourceKitRequest::DocInfo:
10611071 printDocInfo (Info, SourceFile);
10621072 break ;
@@ -1525,6 +1535,25 @@ static void printRangeInfo(sourcekitd_variant_t Info, StringRef FilenameIn,
15251535 if (Typename)
15261536 OS << " <type>" <<Typename << " </type>\n " ;
15271537}
1538+
1539+ static void printExpressionType (sourcekitd_variant_t Info, llvm::raw_ostream &OS) {
1540+ auto *TypeBuffer = sourcekitd_variant_dictionary_get_string (Info, KeyTypeBuffer);
1541+ sourcekitd_variant_t ExprList = sourcekitd_variant_dictionary_get_value (Info,
1542+ KeyExpressionTypeList);
1543+ unsigned Count = sourcekitd_variant_array_get_count (ExprList);
1544+ for (unsigned i = 0 ; i != Count; ++i) {
1545+ sourcekitd_variant_t Item = sourcekitd_variant_array_get_value (ExprList, i);
1546+ unsigned Offset = sourcekitd_variant_dictionary_get_int64 (Item, KeyExpressionOffset);
1547+ unsigned Length = sourcekitd_variant_dictionary_get_int64 (Item, KeyExpressionLength);
1548+ StringRef PrintedType (TypeBuffer + sourcekitd_variant_dictionary_get_int64 (Item,
1549+ KeyTypeOffset), sourcekitd_variant_dictionary_get_int64 (Item, KeyTypeLength));
1550+ OS << " (" << Offset << " , " << Offset + Length << " ): " << PrintedType << " \n " ;
1551+ }
1552+ if (!Count) {
1553+ OS << " cannot find expression types in the file\n " ;
1554+ }
1555+ }
1556+
15281557static void printFoundInterface (sourcekitd_variant_t Info,
15291558 llvm::raw_ostream &OS) {
15301559 const char *Name = sourcekitd_variant_dictionary_get_string (Info,
0 commit comments