@@ -1136,6 +1136,87 @@ int x = foo^
11361136 Contains (AllOf (named (" foo" ), doc (" This comment should be retained!" ))));
11371137}
11381138
1139+ TEST (CompletionTest, CommentsOnMembersFromHeader) {
1140+ MockFS FS;
1141+ MockCompilationDatabase CDB;
1142+
1143+ auto Opts = ClangdServer::optsForTest ();
1144+ Opts.BuildDynamicSymbolIndex = true ;
1145+
1146+ ClangdServer Server (CDB, FS, Opts);
1147+
1148+ FS.Files [testPath (" foo.h" )] = R"cpp(
1149+ struct alpha {
1150+ /// This is a member field.
1151+ int gamma;
1152+
1153+ /// This is a member function.
1154+ int delta();
1155+ };
1156+ )cpp" ;
1157+
1158+ auto File = testPath (" foo.cpp" );
1159+ Annotations Test (R"cpp(
1160+ #include "foo.h"
1161+ alpha a;
1162+ int x = a.^
1163+ )cpp" );
1164+ runAddDocument (Server, File, Test.code ());
1165+ auto CompletionList =
1166+ llvm::cantFail (runCodeComplete (Server, File, Test.point (), {}));
1167+
1168+ EXPECT_THAT (CompletionList.Completions ,
1169+ Contains (AllOf (named (" gamma" ), doc (" This is a member field." ))));
1170+ EXPECT_THAT (
1171+ CompletionList.Completions ,
1172+ Contains (AllOf (named (" delta" ), doc (" This is a member function." ))));
1173+ }
1174+
1175+ TEST (CompletionTest, CommentsOnMembersFromHeaderOverloadBundling) {
1176+ using testing::AnyOf;
1177+ MockFS FS;
1178+ MockCompilationDatabase CDB;
1179+
1180+ auto Opts = ClangdServer::optsForTest ();
1181+ Opts.BuildDynamicSymbolIndex = true ;
1182+
1183+ ClangdServer Server (CDB, FS, Opts);
1184+
1185+ FS.Files [testPath (" foo.h" )] = R"cpp(
1186+ struct alpha {
1187+ /// bool overload.
1188+ int delta(bool b);
1189+
1190+ /// int overload.
1191+ int delta(int i);
1192+
1193+ void epsilon(long l);
1194+
1195+ /// This one has a comment.
1196+ void epsilon(int i);
1197+ };
1198+ )cpp" ;
1199+
1200+ auto File = testPath (" foo.cpp" );
1201+ Annotations Test (R"cpp(
1202+ #include "foo.h"
1203+ alpha a;
1204+ int x = a.^
1205+ )cpp" );
1206+ runAddDocument (Server, File, Test.code ());
1207+ clangd::CodeCompleteOptions CCOpts;
1208+ CCOpts.BundleOverloads = true ;
1209+ auto CompletionList =
1210+ llvm::cantFail (runCodeComplete (Server, File, Test.point (), CCOpts));
1211+
1212+ EXPECT_THAT (
1213+ CompletionList.Completions ,
1214+ Contains (AllOf (named (" epsilon" ), doc (" This one has a comment." ))));
1215+ EXPECT_THAT (CompletionList.Completions ,
1216+ Contains (AllOf (named (" delta" ), AnyOf (doc (" bool overload." ),
1217+ doc (" int overload." )))));
1218+ }
1219+
11391220TEST (CompletionTest, GlobalCompletionFiltering) {
11401221
11411222 Symbol Class = cls (" XYZ" );
0 commit comments