clang API Documentation
#include <FixItRewriter.h>
Public Types | |
typedef Rewriter::buffer_iterator | iterator |
Public Member Functions | |
FixItRewriter (DiagnosticsEngine &Diags, SourceManager &SourceMgr, const LangOptions &LangOpts, FixItOptions *FixItOpts) | |
Initialize a new fix-it rewriter. | |
~FixItRewriter () | |
Destroy the fix-it rewriter. | |
bool | IsModified (FileID ID) const |
Check whether there are modifications for a given file. | |
iterator | buffer_begin () |
iterator | buffer_end () |
bool | WriteFixedFile (FileID ID, raw_ostream &OS) |
Write a single modified source file. | |
bool | WriteFixedFiles (std::vector< std::pair< std::string, std::string > > *RewrittenFiles=nullptr) |
Write the modified source files. | |
bool | IncludeInDiagnosticCounts () const override |
void | HandleDiagnostic (DiagnosticsEngine::Level DiagLevel, const Diagnostic &Info) override |
void | Diag (SourceLocation Loc, unsigned DiagID) |
Emit a diagnostic via the adapted diagnostic client. |
Definition at line 56 of file FixItRewriter.h.
Definition at line 82 of file FixItRewriter.h.
FixItRewriter::FixItRewriter | ( | DiagnosticsEngine & | Diags, |
SourceManager & | SourceMgr, | ||
const LangOptions & | LangOpts, | ||
FixItOptions * | FixItOpts | ||
) |
Initialize a new fix-it rewriter.
Definition at line 30 of file FixItRewriter.cpp.
References clang::DiagnosticsEngine::getClient(), clang::DiagnosticsEngine::setClient(), and clang::DiagnosticsEngine::takeClient().
Destroy the fix-it rewriter.
Definition at line 44 of file FixItRewriter.cpp.
References clang::DiagnosticsEngine::setClient().
iterator clang::FixItRewriter::buffer_begin | ( | ) | [inline] |
Definition at line 97 of file FixItRewriter.h.
References clang::Rewriter::buffer_begin().
Referenced by WriteFixedFiles().
iterator clang::FixItRewriter::buffer_end | ( | ) | [inline] |
Definition at line 98 of file FixItRewriter.h.
References clang::Rewriter::buffer_end().
Referenced by WriteFixedFiles().
void FixItRewriter::Diag | ( | SourceLocation | Loc, |
unsigned | DiagID | ||
) |
Emit a diagnostic via the adapted diagnostic client.
Definition at line 186 of file FixItRewriter.cpp.
References clang::DiagnosticsEngine::Clear(), clang::DiagnosticsEngine::Report(), and clang::DiagnosticsEngine::setClient().
Referenced by HandleDiagnostic(), and WriteFixedFiles().
void FixItRewriter::HandleDiagnostic | ( | DiagnosticsEngine::Level | DiagLevel, |
const Diagnostic & | Info | ||
) | [override, virtual] |
HandleDiagnostic - Handle this diagnostic, reporting it to the user or capturing it to a log as needed.
Reimplemented from clang::DiagnosticConsumer.
Definition at line 115 of file FixItRewriter.cpp.
References clang::FixItHint::BeforePreviousInsertions, clang::FixItHint::CodeToInsert, clang::edit::EditedSource::commit(), Diag(), clang::DiagnosticsEngine::Error, clang::FixItOptions::FixOnlyWarnings, clang::CharSourceRange::getBegin(), clang::CharSourceRange::getEnd(), clang::Diagnostic::getFixItHint(), clang::Diagnostic::getLocation(), clang::Diagnostic::getNumFixItHints(), clang::DiagnosticConsumer::HandleDiagnostic(), clang::edit::Commit::insert(), clang::FixItHint::InsertFromRange, clang::edit::Commit::insertFromRange(), clang::edit::Commit::isCommitable(), clang::CharSourceRange::isTokenRange(), clang::CharSourceRange::isValid(), clang::LangAS::Last, clang::DiagnosticsEngine::Note, clang::edit::Commit::remove(), clang::FixItHint::RemoveRange, clang::edit::Commit::replace(), and clang::FixItOptions::Silent.
bool FixItRewriter::IncludeInDiagnosticCounts | ( | ) | const [override, virtual] |
IncludeInDiagnosticCounts - This method (whose default implementation returns true) indicates whether the diagnostics handled by this DiagnosticConsumer should be included in the number of diagnostics reported by DiagnosticsEngine.
Reimplemented from clang::DiagnosticConsumer.
Definition at line 111 of file FixItRewriter.cpp.
References clang::DiagnosticConsumer::IncludeInDiagnosticCounts().
bool clang::FixItRewriter::IsModified | ( | FileID | ID | ) | const [inline] |
Check whether there are modifications for a given file.
Definition at line 92 of file FixItRewriter.h.
References clang::Rewriter::getRewriteBufferFor().
bool FixItRewriter::WriteFixedFile | ( | FileID | ID, |
raw_ostream & | OS | ||
) |
Write a single modified source file.
Definition at line 48 of file FixItRewriter.cpp.
References clang::Rewriter::getRewriteBufferFor(), and clang::RewriteBuffer::write().
bool FixItRewriter::WriteFixedFiles | ( | std::vector< std::pair< std::string, std::string > > * | RewrittenFiles = nullptr | ) |
Write the modified source files.
Definition at line 74 of file FixItRewriter.cpp.
References clang::edit::EditedSource::applyRewrites(), buffer_begin(), buffer_end(), Diag(), clang::FixItOptions::FixWhatYouCan, clang::SourceManager::getFileEntryForID(), clang::FileEntry::getName(), clang::Rewriter::getSourceMgr(), clang::DiagnosticsEngine::Report(), clang::FixItOptions::RewriteFilename(), and clang::RewriteBuffer::write().