@@ -45,6 +45,7 @@ using ::testing::UnorderedElementsAre;
4545// Helpers for matching call hierarchy data structures.
4646MATCHER_P (withName, N, " " ) { return arg.name == N; }
4747MATCHER_P (withDetail, N, " " ) { return arg.detail == N; }
48+ MATCHER_P (withFile, N, " " ) { return arg.uri .file () == N; }
4849MATCHER_P (withSelectionRange, R, " " ) { return arg.selectionRange == R; }
4950
5051template <class ItemMatcher >
@@ -387,10 +388,17 @@ TEST(CallHierarchy, MultiFileCpp) {
387388 bool IsDeclaration) {
388389 std::vector<CallHierarchyItem> Items =
389390 prepareCallHierarchy (AST, Pos, TUPath);
390- ASSERT_THAT (Items, ElementsAre (withName (" caller3" )));
391+ ASSERT_THAT (
392+ Items,
393+ ElementsAre (AllOf (
394+ withName (" caller3" ),
395+ withFile (testPath (IsDeclaration ? " caller3.hh" : " caller3.cc" )))));
391396 auto OutgoingLevel1 = outgoingCalls (Items[0 ], Index.get ());
392397 ASSERT_THAT (
393398 OutgoingLevel1,
399+ // fromRanges are interpreted in the context of Items[0]'s file.
400+ // If that's the header, we can't get ranges from the implementation
401+ // file!
394402 ElementsAre (
395403 AllOf (to (AllOf (withName (" caller1" ), withDetail (" nsa::caller1" ))),
396404 IsDeclaration ? oFromRanges ()
0 commit comments