This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Don't highlight ObjC `id` and `instancetype`
ClosedPublic

Authored by dgoldman on Aug 23 2021, 7:32 AM.

Details

Summary

Even though they're implemented via typedefs, we typically
want to treat them like keywords (default editor behavior).

Diff Detail

Event Timeline

dgoldman created this revision.Aug 23 2021, 7:32 AM
dgoldman requested review of this revision.Aug 23 2021, 7:32 AM

thanks, it looks good as a contained fix. but it feels like we probably don't want these to be treated as decls in other places too (e.g. can we really provide any useful goto/hover on those id or instancetype decls?) maybe we should update ASTVisitors in FindTarget to not report these at all. WDYT?

thanks, it looks good as a contained fix. but it feels like we probably don't want these to be treated as decls in other places too (e.g. can we really provide any useful goto/hover on those id or instancetype decls?) maybe we should update ASTVisitors in FindTarget to not report these at all. WDYT?

That's a good point - I guess it could be marginally useful?

Hovering over instancetype you'll see typedef id instancetype and can be brought via goto definition to objc.h which defines typedef struct objc_object *id;. Hovering over id you see typedef id id (which is quite confusing) and go-to definition brings you to objc.h as well. In theory the hover information should show you A pointer to an instance of a class. (comment from objc.h), seems to have worked previously, not sure why it doesn't atm. References doesn't appear to work and you'd really never want to use it if it did - there'd be way too many.

Hmm, it sounds like you want them to be treated one way during semantic highlighting and another during other features, which is fine but somewhat confusing. (e.g. we want to surface hover/goto on these identifiers, but we're making them less visible by encouraging editors to highlight them as keywords).

dgoldman updated this revision to Diff 370609.Sep 3 2021, 9:40 AM

Swap to ignore in FindTarget

Hmm, it sounds like you want them to be treated one way during semantic highlighting and another during other features, which is fine but somewhat confusing. (e.g. we want to surface hover/goto on these identifiers, but we're making them less visible by encouraging editors to highlight them as keywords).

I went ahead and just ignored them in FindTarget (LMK if that's right) - I think you're right that it's unlikely to provide any real value so we might as well not support it.

thanks, this looks great! just a question about the extra handling

clang-tools-extra/clangd/FindTarget.cpp
100

i think comment needs updating. rather than mentioning the editor, can we just talk about "these should be treated as keywords rather than decls" ?

187

why do we need this despite bailing out in the visitor?

dgoldman updated this revision to Diff 371103.Sep 7 2021, 9:18 AM

Update comment + remove un-needed code

dgoldman marked 2 inline comments as done.Sep 7 2021, 9:18 AM
dgoldman added inline comments.
clang-tools-extra/clangd/FindTarget.cpp
187

Removed, not necessary

dgoldman marked an inline comment as done.Sep 13 2021, 8:25 AM

Friendly ping, PTAL

kadircet accepted this revision.Sep 14 2021, 12:32 AM

sorry, I thought I've already LGTM'd it in previous iteration. Thanks!

This revision is now accepted and ready to land.Sep 14 2021, 12:32 AM