[PATCH] D152720: [clangd][ObjC] Support ObjC class rename from implementation decls
David Goldman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 12 09:11:27 PDT 2023
dgoldman created this revision.
dgoldman added a reviewer: kadircet.
Herald added a subscriber: arphaman.
Herald added a project: All.
dgoldman requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D152720
Files:
clang-tools-extra/clangd/FindTarget.cpp
clang-tools-extra/clangd/unittests/RenameTests.cpp
Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -840,6 +840,16 @@
foo('x');
}
)cpp",
+
+ // ObjC class.
+ R"cpp(
+ @interface [[Fo^o]]
+ @end
+ @implementation [[F^oo]]
+ @end
+
+ void func([[Foo]] *f) {}
+ )cpp",
};
llvm::StringRef NewName = "NewName";
for (llvm::StringRef T : Tests) {
@@ -1468,7 +1478,7 @@
TEST(CrossFileRenameTests, WithUpToDateIndex) {
MockCompilationDatabase CDB;
- CDB.ExtraClangFlags = {"-xc++"};
+ CDB.ExtraClangFlags = {"-xobjective-c++"};
// rename is runnning on all "^" points in FooH, and "[[]]" ranges are the
// expected rename occurrences.
struct Case {
@@ -1677,6 +1687,20 @@
}
)cpp",
},
+ {
+ // Objective-C classes.
+ R"cpp(
+ @interface [[Fo^o]]
+ @end
+ )cpp",
+ R"cpp(
+ #include "foo.h"
+ @implementation [[F^oo]]
+ @end
+
+ void func([[Foo]] *f) {}
+ )cpp",
+ },
};
trace::TestTracer Tracer;
Index: clang-tools-extra/clangd/FindTarget.cpp
===================================================================
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -707,6 +707,14 @@
/*IsDecl=*/true,
{OCID->getCategoryDecl()}});
}
+
+ void VisitObjCImplementationDecl(const ObjCImplementationDecl *OIMD) {
+ if (const auto *CI = OIMD->getClassInterface())
+ Refs.push_back(ReferenceLoc{NestedNameSpecifierLoc(),
+ OIMD->getLocation(),
+ /*IsDecl=*/true,
+ {CI}});
+ }
};
Visitor V{Resolver};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152720.530537.patch
Type: text/x-patch
Size: 1987 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230612/aa9eafd4/attachment.bin>
More information about the cfe-commits
mailing list