15 #ifndef LLVM_CLANG_REWRITE_CORE_REWRITER_H
16 #define LLVM_CLANG_REWRITE_CORE_REWRITER_H
34 std::map<FileID, RewriteBuffer> RewriteBuffers;
57 : SourceMgr(&SM), LangOpts(&LO) {}
58 explicit Rewriter() : SourceMgr(nullptr), LangOpts(nullptr) {}
76 RewriteOptions opts = RewriteOptions())
const;
78 RewriteOptions opts = RewriteOptions())
const;
95 bool InsertAfter =
true,
bool indentNewLines =
false);
121 RewriteOptions opts = RewriteOptions());
171 std::map<FileID, RewriteBuffer>::const_iterator I =
172 RewriteBuffers.find(FID);
173 return I == RewriteBuffers.end() ?
nullptr : &I->second;
bool IncreaseIndentation(CharSourceRange range, SourceLocation parentIndent)
Increase indentation for the lines between the given source range. To determine what the indentation ...
SourceLocation getBegin() const
SourceManager & getSourceMgr() const
static CharSourceRange getTokenRange(SourceRange R)
const RewriteBuffer * getRewriteBufferFor(FileID FID) const
bool RemoveText(SourceLocation Start, unsigned Length, RewriteOptions opts=RewriteOptions())
RemoveText - Remove the specified text region.
RewriteBuffer & getEditBuffer(FileID FID)
std::map< FileID, RewriteBuffer >::const_iterator const_buffer_iterator
bool ReplaceText(SourceLocation Start, unsigned OrigLength, StringRef NewStr)
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Rewriter(SourceManager &SM, const LangOptions &LO)
buffer_iterator buffer_end()
Represents a character-granular source range.
bool RemoveText(SourceRange range, RewriteOptions opts=RewriteOptions())
Remove the specified text region.
bool IncreaseIndentation(SourceRange range, SourceLocation parentIndent)
bool overwriteChangedFiles()
void setSourceMgr(SourceManager &SM, const LangOptions &LO)
Encodes a location in the source. The SourceManager can decode this to get at the full include stack...
bool InsertTextAfter(SourceLocation Loc, StringRef Str)
bool ReplaceText(SourceRange range, StringRef NewStr)
bool InsertText(SourceLocation Loc, StringRef Str, bool InsertAfter=true, bool indentNewLines=false)
const_buffer_iterator buffer_begin() const
bool RemoveLineIfEmpty
If true and removing some text leaves a blank line also remove the empty line (false by default)...
SourceLocation getBegin() const
bool InsertTextBefore(SourceLocation Loc, StringRef Str)
int getRangeSize(SourceRange Range, RewriteOptions opts=RewriteOptions()) const
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
const_buffer_iterator buffer_end() const
bool RemoveText(CharSourceRange range, RewriteOptions opts=RewriteOptions())
Remove the specified text region.
std::string getRewrittenText(SourceRange Range) const
bool IncludeInsertsAtBeginOfRange
Given a source range, true to include previous inserts at the beginning of the range as part of the r...
std::map< FileID, RewriteBuffer >::iterator buffer_iterator
const LangOptions & getLangOpts() const
buffer_iterator buffer_begin()
Defines the clang::SourceLocation class and associated facilities.
static bool isRewritable(SourceLocation Loc)
A trivial tuple used to represent a source range.
bool InsertTextAfterToken(SourceLocation Loc, StringRef Str)
Insert the specified string after the token in the specified location.
This class handles loading and caching of source files into memory.
bool IncludeInsertsAtEndOfRange
Given a source range, true to include previous inserts at the end of the range as part of the range i...