Improve support for Objective-C protocols for types/type locs
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
clang-tools-extra/clangd/FindTarget.cpp | ||
---|---|---|
435–441 | Let me know if I'm missing something here, not exactly sure what the old comment meant - is there a problem since this ObjCObjectType can refer to multiple protocols? | |
819 | Let me know if you have something else in mind to handle the ObjC case here | |
917 | Doesn't look like that's needed, but if we wanted to decorate the type parameters in ObjCObjectTypeLoc with typeParameter would that just go in SemanticHighlighting.cpp? |
Friendly ping, not sure if there's something in here and https://reviews.llvm.org/D99975 that I'm missing to properly support the one decl/type loc to multiple references here
LG apart from a few nits & reverting the whitespace changes to unrelated tests.
clang-tools-extra/clangd/FindTarget.cpp | ||
---|---|---|
435–441 | Here's the way the AST should ideally look like (and what this comment is wishing for): ObjCObjectTypeLoc C<Foo> - ObjCInterfaceTypeLoc C - ObjCProtocolLoc Foo // doesn't actually exist And targetDecl() would work on the two children, but not the parent. But there's no AST node for protocols. A piece of cleverness in this patch is getting go-to-definition to work on protocols by saying "if the cursor is on ObjCObjectType itself, then it must be on a protocol rather than the base (otherwise it'd be on the ObjCInterfaceType child)". But it's a hack, as evidenced by the fact that operations that work on the *range* [[C<Foo>]] will still see the target as <Foo> (literally any of nothing, C, C+Foo would be better). Nevertheless I think it's probably a net win. Can you leave a comment here like // There's no child node for just a protocol, so make all the protocols targets. // But not the base type, which *does* have a child ObjCInterfaceTypeLoc. // This structure is a hack, but it works well for go-to-definition. | |
825 | this doesn't seem right: we now have a list, the Visit() call may have added things to the list, we need to adjust *all* the added things. // Add qualifier for the newly-added refs. for (unsigned I = InitialSize; I < Refs.size(); ++I) { // adjust Refs[I] } | |
917 | That's not something we want to do - ObjCObjectTypeLoc has type arguments, not parameters. e.g. in the function call foo(42) we don't decorate 42 as a parameter, we decorate it as an integer. | |
clang-tools-extra/clangd/unittests/FindTargetTests.cpp | ||
960–971 | can you add a second protocol so we can see the boundaries of this approach? (I think C<[[Foo]], Bar> should resolve to both @protocol Foo and @protocol Bar) | |
1046–1047 | there are a ton of whitespace changes in this patch, because the version at HEAD isn't clang-format clean :-( Feel free to format it first in a separate commit, but I'd prefer not to reformat all the tests mixed in with other changes. |
clang-tools-extra/clangd/unittests/FindTargetTests.cpp | ||
---|---|---|
1046–1047 | Will do if it hasn't been done already |
Let me know if I'm missing something here, not exactly sure what the old comment meant - is there a problem since this ObjCObjectType can refer to multiple protocols?