This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Simplify semantic highlighting visitor
ClosedPublic

Authored by ilya-biryukov on Sep 9 2019, 1:36 AM.

Details

Summary
  • Functions to compute highlighting kinds for things are separated from the ones that add highlighting tokens. This keeps each of them more focused on what they're doing: getting locations and figuring out the kind of the entity, correspondingly.
  • Less special cases in visitor for various nodes.

This change is an NFC.

Diff Detail

Repository
rL LLVM

Event Timeline

ilya-biryukov created this revision.Sep 9 2019, 1:36 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 9 2019, 1:36 AM
hokein added a comment.Sep 9 2019, 7:26 AM

Thanks!

Unfortunately, the patch is a bit large, containing refactoring changes and functionality changes, is it possible to split it into (two) smaller patches?

  • Turn into NFC, do not highlight lambdas differently
ilya-biryukov edited the summary of this revision. (Show Details)Sep 9 2019, 8:38 AM

Unfortunately, the patch is a bit large, containing refactoring changes and functionality changes, is it possible to split it into (two) smaller patches?

Done. There should be no functional changes now.

thanks, looks good, just a few nits.

clang-tools-extra/clangd/SemanticHighlighting.cpp
34 ↗(On Diff #219363)

nit: I think the check is redundant, getAsIdentifierInfo() will return nullptr if !Name.isIdentifier().

37 ↗(On Diff #219363)

nit: !II->getName().empty()

169 ↗(On Diff #219363)

how about moving out this method (and kindForDecl) of the class, they seem to not depend on any fields of the class?

212 ↗(On Diff #219363)

nit: auto

260 ↗(On Diff #219363)

maybe

if (auto K = kindForDecl(D))
   addToken(Loc, *K);
ilya-biryukov marked 6 inline comments as done.
  • Address comments
clang-tools-extra/clangd/SemanticHighlighting.cpp
169 ↗(On Diff #219363)

Makes sense. Done.

@hokein, do you want to do another round or is this good to go?

hokein accepted this revision.Sep 16 2019, 1:31 AM
This revision is now accepted and ready to land.Sep 16 2019, 1:31 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptSep 16 2019, 9:14 AM