[PATCH] D83501: [clangd][ObjC] Improve xrefs for protocols and classes
David Goldman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 10 08:27:50 PDT 2020
dgoldman updated this revision to Diff 277054.
dgoldman marked 2 inline comments as done.
dgoldman added a comment.
Add support for categories + fix tests
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D83501/new/
https://reviews.llvm.org/D83501
Files:
clang-tools-extra/clangd/XRefs.cpp
clang-tools-extra/clangd/unittests/XRefsTests.cpp
Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -676,7 +676,7 @@
};
)cpp",
- R"objc(//objc
+ R"objc(
@protocol $decl[[Dog]];
@protocol $def[[Dog]]
- (void)bark;
@@ -686,14 +686,25 @@
}
)objc",
- R"objc(//objc
+ R"objc(
+ @interface Cat
+ @end
+ @interface $decl[[Ca^t]] (Extension)
+ - (void)meow;
+ @end
+ @implementation $def[[Cat]] (Extension)
+ - (void)meow {}
+ @end
+ )objc",
+
+ R"objc(
@class $decl[[Foo]];
Fo^o * getFoo() {
return 0;
}
)objc",
- R"objc(//objc
+ R"objc(
@class Foo;
@interface $decl[[Foo]]
@end
@@ -702,7 +713,7 @@
}
)objc",
- R"objc(//objc
+ R"objc(
@class Foo;
@interface $decl[[Foo]]
@end
@@ -726,14 +737,10 @@
TestTU TU;
TU.Code = std::string(T.code());
- std::string ObjcPrefix = "//objc";
- if (strncmp(Test, ObjcPrefix.c_str(), ObjcPrefix.size()) == 0) {
- TU.Filename = "TestTU.m";
- }
-
// FIXME: Auto-completion in a template requires disabling delayed template
// parsing.
TU.ExtraArgs.push_back("-fno-delayed-template-parsing");
+ TU.ExtraArgs.push_back("-xobjective-c++");
auto AST = TU.build();
auto Results = locateSymbolAt(AST, T.point());
Index: clang-tools-extra/clangd/XRefs.cpp
===================================================================
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -82,6 +82,8 @@
return PD->getDefinition();
if (const auto *ID = dyn_cast<ObjCInterfaceDecl>(D))
return ID->getImplementation();
+ if (const auto *CD = dyn_cast<ObjCCategoryDecl>(D))
+ return CD->getImplementation();
// Only a single declaration is allowed.
if (isa<ValueDecl>(D) || isa<TemplateTypeParmDecl>(D) ||
isa<TemplateTemplateParmDecl>(D)) // except cases above
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83501.277054.patch
Type: text/x-patch
Size: 2204 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200710/22156717/attachment.bin>
More information about the cfe-commits
mailing list