[PATCH] D53934: [clangd] Improve code completion for ObjC methods

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 8 06:02:35 PST 2018

sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Thanks for fixing this!

Comment at: unittests/clangd/CodeCompleteTests.cpp:2195
+TEST(CompletionTest, ObjectiveCMethodNoArguments) {
+  std::string Context = R"objc(
+    @interface Foo
"Context" is an odd name for this.

Comment at: unittests/clangd/CodeCompleteTests.cpp:2202
+  auto A = completions(Context, {}, {}, "Foo.m").Completions.front();
+  EXPECT_EQ(A.Name, "value");
this will crash if there aren't any completions, and do something unpredictable if there are multiple.
either grab the completions and then `ASSERT_THAT(completions, ElementsAre(_))` or write a getOnlyCompletion() helper that does the needed logging.
(Note an assertion on size isn't as good, as it only prints the size on failure)

  rCTE Clang Tools Extra


More information about the cfe-commits mailing list