This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Enable modules to contribute tweaks.
ClosedPublic

Authored by kadircet on Mar 12 2021, 5:55 AM.

Details

Summary

First patch to enable diagnostic fix generation through modules. The
workflow will look like:

  • ASTWorker letting modules know about diagnostics while building AST,

modules can read clang::Diagnostic and mutate clangd::Diagnostic through
that hook.

  • Modules can implement and expose tweaks to fix diagnostics or act as

general refactorings.

  • Tweak::Selection will contain information about the diagnostic

associated with the codeAction request to enable modules to fail their
diagnostic fixing tweakson prepare if need be.

Diff Detail

Event Timeline

kadircet created this revision.Mar 12 2021, 5:55 AM
kadircet requested review of this revision.Mar 12 2021, 5:55 AM
sammccall accepted this revision.Mar 15 2021, 11:32 AM

Should we have a test somewhere that tweaks defined in modules actually work?

clang-tools-extra/clangd/FeatureModule.h
98

nit: can you move the forward declaration up the top? Makes the (sort-of) dep clearer, and is less fragile re scopes when moving code around.

clang-tools-extra/clangd/refactor/Tweak.cpp
55

nit: the early return seems more confusing to me here than conditionally adding...

clang-tools-extra/clangd/refactor/Tweak.h
132

forward decl: and here

132

nit: move the modules to the end of the list?

This revision is now accepted and ready to land.Mar 15 2021, 11:32 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 15 2021, 11:32 AM
kadircet updated this revision to Diff 332552.Mar 23 2021, 1:14 AM
kadircet marked 4 inline comments as done.
  • Add test
  • Move forward declarations out of signatures
  • Move FeatureModuleSets to the last parameter in prepareTweaks
This revision was landed with ongoing or failed builds.Apr 13 2021, 8:50 AM
This revision was automatically updated to reflect the committed changes.