clang
3.7.0
|
#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. More... | |
~FixItRewriter () override | |
Destroy the fix-it rewriter. More... | |
bool | IsModified (FileID ID) const |
Check whether there are modifications for a given file. More... | |
iterator | buffer_begin () |
iterator | buffer_end () |
bool | WriteFixedFile (FileID ID, raw_ostream &OS) |
Write a single modified source file. More... | |
bool | WriteFixedFiles (std::vector< std::pair< std::string, std::string > > *RewrittenFiles=nullptr) |
Write the modified source files. More... | |
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. More... | |
![]() | |
DiagnosticConsumer () | |
unsigned | getNumErrors () const |
unsigned | getNumWarnings () const |
virtual void | clear () |
virtual | ~DiagnosticConsumer () |
virtual void | BeginSourceFile (const LangOptions &LangOpts, const Preprocessor *PP=nullptr) |
Callback to inform the diagnostic client that processing of a source file is beginning. More... | |
virtual void | EndSourceFile () |
Callback to inform the diagnostic client that processing of a source file has ended. More... | |
virtual void | finish () |
Callback to inform the diagnostic client that processing of all source files has ended. More... | |
Additional Inherited Members | |
![]() | |
unsigned | NumWarnings |
Number of warnings reported. More... | |
unsigned | NumErrors |
Number of errors reported. More... | |
Definition at line 60 of file FixItRewriter.h.
Definition at line 86 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().
|
override |
Destroy the fix-it rewriter.
Definition at line 44 of file FixItRewriter.cpp.
References clang::DiagnosticsEngine::setClient().
|
inline |
Definition at line 101 of file FixItRewriter.h.
References clang::Rewriter::buffer_begin().
Referenced by WriteFixedFiles().
|
inline |
Definition at line 102 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 193 of file FixItRewriter.cpp.
References clang::DiagnosticsEngine::Clear(), clang::DiagnosticsEngine::Report(), and clang::DiagnosticsEngine::setClient().
Referenced by HandleDiagnostic(), and WriteFixedFiles().
|
overridevirtual |
HandleDiagnostic - Handle this diagnostic, reporting it to the user or capturing it to a log as needed.
Reimplemented from clang::DiagnosticConsumer.
Definition at line 122 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.
|
overridevirtual |
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 118 of file FixItRewriter.cpp.
References clang::DiagnosticConsumer::IncludeInDiagnosticCounts().
Check whether there are modifications for a given file.
Definition at line 96 of file FixItRewriter.h.
References clang::Rewriter::getRewriteBufferFor().
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::FixItOptions::InPlace, clang::Rewriter::overwriteChangedFiles(), clang::DiagnosticsEngine::Report(), clang::FixItOptions::RewriteFilename(), and clang::RewriteBuffer::write().