dgoldman created this revision. dgoldman added reviewers: sammccall, kadircet. Herald added subscribers: usaxena95, jfb, arphaman. dgoldman requested review of this revision. Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov. Herald added a project: clang-tools-extra.
Treat them just like we do for properties - as a `property` semantic token although ideally we could differentiate the two. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D101785 Files: clang-tools-extra/clangd/FindTarget.cpp clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp =================================================================== --- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp +++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp @@ -687,6 +687,18 @@ @implementation $Class[[Foo]]($Namespace_decl[[Bar]]) @end )cpp", + R"cpp( + // ObjC: Properties and Ivars. + @interface $Class_decl[[Foo]] + @property(nonatomic, assign) int $Field_decl[[someProperty]]; + @end + @implementation $Class_decl[[Foo]] + - (int)$Method_decl[[doSomething]] { + self.$Field[[someProperty]] = self.$Field[[someProperty]] + 1; + self->$Field[[_someProperty]] = $Field[[_someProperty]] + 1; + } + @end + )cpp", // Member imported from dependent base R"cpp( template <typename> struct $Class_decl[[Base]] { Index: clang-tools-extra/clangd/FindTarget.cpp =================================================================== --- clang-tools-extra/clangd/FindTarget.cpp +++ clang-tools-extra/clangd/FindTarget.cpp @@ -780,6 +780,13 @@ explicitReferenceTargets(DynTypedNode::create(*E), {}, Resolver)}); } + void VisitObjCIvarRefExpr(const ObjCIvarRefExpr *OIRE) { + Refs.push_back(ReferenceLoc{NestedNameSpecifierLoc(), + OIRE->getLocation(), + /*IsDecl=*/false, + {OIRE->getDecl()}}); + } + void VisitObjCMessageExpr(const ObjCMessageExpr *E) { // The name may have several tokens, we can only report the first. Refs.push_back(ReferenceLoc{NestedNameSpecifierLoc(),
Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp =================================================================== --- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp +++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp @@ -687,6 +687,18 @@ @implementation $Class[[Foo]]($Namespace_decl[[Bar]]) @end )cpp", + R"cpp( + // ObjC: Properties and Ivars. + @interface $Class_decl[[Foo]] + @property(nonatomic, assign) int $Field_decl[[someProperty]]; + @end + @implementation $Class_decl[[Foo]] + - (int)$Method_decl[[doSomething]] { + self.$Field[[someProperty]] = self.$Field[[someProperty]] + 1; + self->$Field[[_someProperty]] = $Field[[_someProperty]] + 1; + } + @end + )cpp", // Member imported from dependent base R"cpp( template <typename> struct $Class_decl[[Base]] { Index: clang-tools-extra/clangd/FindTarget.cpp =================================================================== --- clang-tools-extra/clangd/FindTarget.cpp +++ clang-tools-extra/clangd/FindTarget.cpp @@ -780,6 +780,13 @@ explicitReferenceTargets(DynTypedNode::create(*E), {}, Resolver)}); } + void VisitObjCIvarRefExpr(const ObjCIvarRefExpr *OIRE) { + Refs.push_back(ReferenceLoc{NestedNameSpecifierLoc(), + OIRE->getLocation(), + /*IsDecl=*/false, + {OIRE->getDecl()}}); + } + void VisitObjCMessageExpr(const ObjCMessageExpr *E) { // The name may have several tokens, we can only report the first. Refs.push_back(ReferenceLoc{NestedNameSpecifierLoc(),
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits