Page MenuHomePhabricator

[clangd] Add support for generating #import edits
Needs ReviewPublic

Authored by dgoldman on Jun 27 2022, 12:41 PM.

Details

Reviewers
kadircet
Summary

And make use of this from CodeComplete and IncludeFixer, although currently they are both restricted only to #include symbols.

Diff Detail

Event Timeline

dgoldman created this revision.Jun 27 2022, 12:41 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 27 2022, 12:41 PM
dgoldman requested review of this revision.Jun 27 2022, 12:41 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJun 27 2022, 12:41 PM
dgoldman updated this revision to Diff 479343.Thu, Dec 1, 10:09 AM

Run clang-format

dgoldman retitled this revision from [clangd] Support #import insertions to [clangd] Add support for generating #import edits.Thu, Dec 1, 10:10 AM
dgoldman edited the summary of this revision. (Show Details)

we should have tests in clang/unittests/Tooling/HeaderIncludesTest.cpp and the commit itself should be tagged as [clang][Tooling] rather than [clangd].

clang-tools-extra/clangd/Headers.h
250

again it's better to have an enum here.

clang-tools-extra/clangd/IncludeFixer.cpp
252

again can we rather pass the directive enum around?

clang/include/clang/Tooling/Inclusions/HeaderIncludes.h
74

rather than a boolean flag, can you introduce an enum IncludeDirective { Include, Import }; and default it to Include here?

83

we also need to preserve includedirective here now. as the behaviour of insert is to return none iff it's exactly the same spelling. so if there's a #include "foo.h" and we want to insert #import "foo.h" it shouldn't fail.