@@ -1024,6 +1024,51 @@ static int doTypeContextInfo(const CompilerInvocation &InitInvok,
1024
1024
});
1025
1025
}
1026
1026
1027
+ static int printConformingMethodList (
1028
+ CancellableResult<ConformingMethodListResults> CancellableResult) {
1029
+ return printResult<ConformingMethodListResults>(
1030
+ CancellableResult, [](ConformingMethodListResults &Results) {
1031
+ auto Result = Results.Result ;
1032
+ if (!Result) {
1033
+ return 0 ;
1034
+ }
1035
+ llvm::outs () << " -----BEGIN CONFORMING METHOD LIST-----\n " ;
1036
+
1037
+ llvm::outs () << " - TypeName: " ;
1038
+ Result->ExprType .print (llvm::outs ());
1039
+ llvm::outs () << " \n " ;
1040
+
1041
+ llvm::outs () << " - Members: " ;
1042
+ if (Result->Members .empty ())
1043
+ llvm::outs () << " []" ;
1044
+ llvm::outs () << " \n " ;
1045
+ for (auto VD : Result->Members ) {
1046
+ auto funcTy = cast<FuncDecl>(VD)->getMethodInterfaceType ();
1047
+ funcTy = Result->ExprType ->getTypeOfMember (
1048
+ Result->DC ->getParentModule (), VD, funcTy);
1049
+ auto resultTy = funcTy->castTo <FunctionType>()->getResult ();
1050
+
1051
+ llvm::outs () << " - Name: " ;
1052
+ VD->getName ().print (llvm::outs ());
1053
+ llvm::outs () << " \n " ;
1054
+
1055
+ llvm::outs () << " TypeName: " ;
1056
+ resultTy.print (llvm::outs ());
1057
+ llvm::outs () << " \n " ;
1058
+
1059
+ StringRef BriefDoc = VD->getBriefComment ();
1060
+ if (!BriefDoc.empty ()) {
1061
+ llvm::outs () << " DocBrief: \" " ;
1062
+ llvm::outs () << VD->getBriefComment ();
1063
+ llvm::outs () << " \"\n " ;
1064
+ }
1065
+ }
1066
+
1067
+ llvm::outs () << " -----END CONFORMING METHOD LIST-----\n " ;
1068
+ return 0 ;
1069
+ });
1070
+ }
1071
+
1027
1072
static int
1028
1073
doConformingMethodList (const CompilerInvocation &InitInvok,
1029
1074
StringRef SourceFilename, StringRef SecondSourceFileName,
@@ -1034,18 +1079,20 @@ doConformingMethodList(const CompilerInvocation &InitInvok,
1034
1079
for (auto &name : expectedTypeNames)
1035
1080
typeNames.push_back (name.c_str ());
1036
1081
1037
- // Create a CodeCompletionConsumer.
1038
- std::unique_ptr<ide::ConformingMethodListConsumer> Consumer (
1039
- new ide::PrintingConformingMethodListConsumer (llvm::outs ()));
1040
-
1041
- // Create a factory for code completion callbacks that will feed the
1042
- // Consumer.
1043
- std::unique_ptr<CodeCompletionCallbacksFactory> callbacksFactory (
1044
- ide::makeConformingMethodListCallbacksFactory (typeNames, *Consumer));
1045
-
1046
- return doCodeCompletionImpl (callbacksFactory.get (), InitInvok, SourceFilename,
1047
- SecondSourceFileName, CodeCompletionToken,
1048
- CodeCompletionDiagnostics);
1082
+ return performWithCompletionLikeOperationParams (
1083
+ InitInvok, SourceFilename, SecondSourceFileName, CodeCompletionToken,
1084
+ CodeCompletionDiagnostics,
1085
+ [&](CompletionLikeOperationParams Params) -> bool {
1086
+ CompletionInstance CompletionInst;
1087
+ int ExitCode = 2 ;
1088
+ CompletionInst.conformingMethodList (
1089
+ Params.Invocation , Params.Args , Params.FileSystem ,
1090
+ Params.CompletionBuffer , Params.Offset , Params.DiagC , typeNames,
1091
+ [&](CancellableResult<ConformingMethodListResults> Result) {
1092
+ ExitCode = printConformingMethodList (Result);
1093
+ });
1094
+ return ExitCode;
1095
+ });
1049
1096
}
1050
1097
1051
1098
static int doCodeCompletion (const CompilerInvocation &InitInvok,
0 commit comments