Skip to content

[clangd] Update XRefs to support overriden ObjC methods #127109

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Feb 19, 2025
Prev Previous commit
Next Next commit
Run clang-format
DavidGoldman committed Feb 13, 2025
commit 65f19b760067233f75d5e8a66a8deb8419e1b47f
25 changes: 13 additions & 12 deletions clang-tools-extra/clangd/unittests/XRefsTests.cpp
Original file line number Diff line number Diff line change
@@ -426,9 +426,10 @@ TEST(LocateSymbol, FindOverridesObjC) {
TestTU TU = TestTU::withCode(Code.code());
TU.ExtraArgs.push_back("-xobjective-c++");
auto AST = TU.build();
EXPECT_THAT(locateSymbolAt(AST, Code.point(), TU.index().get()),
UnorderedElementsAre(sym("foo", Code.range("1"), std::nullopt),
sym("foo", Code.range("2"), Code.range("2"))));
EXPECT_THAT(
locateSymbolAt(AST, Code.point(), TU.index().get()),
UnorderedElementsAre(sym("foo", Code.range("1"), std::nullopt),
sym("foo", Code.range("2"), Code.range("2"))));
}

TEST(LocateSymbol, WithIndexPreferredLocation) {
@@ -1878,15 +1879,15 @@ TEST(FindImplementations, InheritanceObjC) {
TU.ExtraArgs.push_back("-xobjective-c++");
auto AST = TU.build();
auto Index = TU.index();
EXPECT_THAT(
findImplementations(AST, Code.point("base"), Index.get()),
UnorderedElementsAre(sym("Child", Code.range("ChildDecl"), Code.range("ChildDef"))));
EXPECT_THAT(
findImplementations(AST, Code.point("foo"), Index.get()),
UnorderedElementsAre(sym("foo", Code.range("fooDecl"), Code.range("fooDef"))));
EXPECT_THAT(
findImplementations(AST, Code.point("protocol"), Index.get()),
UnorderedElementsAre(sym("protocol", Code.range("protocolDef"), Code.range("protocolDef"))));
EXPECT_THAT(findImplementations(AST, Code.point("base"), Index.get()),
UnorderedElementsAre(sym("Child", Code.range("ChildDecl"),
Code.range("ChildDef"))));
EXPECT_THAT(findImplementations(AST, Code.point("foo"), Index.get()),
UnorderedElementsAre(
sym("foo", Code.range("fooDecl"), Code.range("fooDef"))));
EXPECT_THAT(findImplementations(AST, Code.point("protocol"), Index.get()),
UnorderedElementsAre(sym("protocol", Code.range("protocolDef"),
Code.range("protocolDef"))));
}

TEST(FindImplementations, CaptureDefinition) {