clang-tools
11.0.0
|
#include <Headers.h>
Public Member Functions | |
IncludeInserter (StringRef FileName, StringRef Code, const format::FormatStyle &Style, StringRef BuildDir, HeaderSearch *HeaderSearchInfo) | |
void | addExisting (const Inclusion &Inc) |
bool | shouldInsertInclude (PathRef DeclaringHeader, const HeaderFile &InsertedHeader) const |
Checks whether to add an #include of the header into File . More... | |
llvm::Optional< std::string > | calculateIncludePath (const HeaderFile &InsertedHeader, llvm::StringRef IncludingFile) const |
Determines the preferred way to #include a file, taking into account the search path. More... | |
llvm::Optional< TextEdit > | insert (llvm::StringRef VerbatimHeader) const |
Calculates an edit that inserts VerbatimHeader into code. More... | |
|
inline |
void clang::clangd::IncludeInserter::addExisting | ( | const Inclusion & | Inc | ) |
Definition at line 207 of file Headers.cpp.
References clang::clangd::Inclusion::Resolved, and clang::clangd::Inclusion::Written.
llvm::Optional< std::string > clang::clangd::IncludeInserter::calculateIncludePath | ( | const HeaderFile & | InsertedHeader, |
llvm::StringRef | IncludingFile | ||
) | const |
Determines the preferred way to #include a file, taking into account the search path.
Usually this will prefer a shorter representation like 'Foo/Bar.h' over a longer one like 'Baz/include/Foo/Bar.h'.
InsertedHeader | The preferred header to be inserted. |
IncludingFile | is the absolute path of the file that InsertedHeader will be inserted. |
Definition at line 229 of file Headers.cpp.
References clang::clangd::HeaderFile::File, clang::clangd::None, clang::clangd::HeaderFile::valid(), and clang::clangd::HeaderFile::Verbatim.
llvm::Optional< TextEdit > clang::clangd::IncludeInserter::insert | ( | llvm::StringRef | VerbatimHeader | ) | const |
Calculates an edit that inserts VerbatimHeader
into code.
If the header is already included, this returns None.
Definition at line 259 of file Headers.cpp.
References clang::clangd::None, and clang::clangd::replacementToEdit().
bool clang::clangd::IncludeInserter::shouldInsertInclude | ( | PathRef | DeclaringHeader, |
const HeaderFile & | InsertedHeader | ||
) | const |
Checks whether to add an #include of the header into File
.
FIXME(ioeric): we might not want to insert an absolute include path if the path is not shortened.
An #include will not be added if:
DeclaringHeader
or InsertedHeader
is already (directly) in Inclusions
(including those included via different paths).DeclaringHeader
or InsertedHeader
is the same as File
.DeclaringHeader | is path of the original header corresponding to InsertedHeader e.g. the header that declares a symbol. |
InsertedHeader | The preferred header to be inserted. This could be the same as DeclaringHeader but must be provided. |
Definition at line 215 of file Headers.cpp.
References clang::clangd::HeaderFile::File, FileName, clang::clangd::HeaderFile::valid(), and clang::clangd::HeaderFile::Verbatim.