clang API Documentation
A text replacement. More...
#include <Replacement.h>
Public Member Functions | |
| Replacement () | |
| Creates an invalid (not applicable) replacement. | |
| Replacement (StringRef FilePath, unsigned Offset, unsigned Length, StringRef ReplacementText) | |
| Creates a replacement of the range [Offset, Offset+Length) in FilePath with ReplacementText. | |
| Replacement (const SourceManager &Sources, SourceLocation Start, unsigned Length, StringRef ReplacementText) | |
| Creates a Replacement of the range [Start, Start+Length) with ReplacementText. | |
| Replacement (const SourceManager &Sources, const CharSourceRange &Range, StringRef ReplacementText) | |
| Creates a Replacement of the given range with ReplacementText. | |
| template<typename Node > | |
| Replacement (const SourceManager &Sources, const Node &NodeToReplace, StringRef ReplacementText) | |
| Creates a Replacement of the node with ReplacementText. | |
| bool | isApplicable () const |
| Returns whether this replacement can be applied to a file. | |
| bool | apply (Rewriter &Rewrite) const |
| Applies the replacement on the Rewriter. | |
| std::string | toString () const |
| Returns a human readable string representation. | |
| StringRef | getFilePath () const |
| Accessors. | |
| unsigned | getOffset () const |
| unsigned | getLength () const |
| StringRef | getReplacementText () const |
A text replacement.
Represents a SourceManager independent replacement of a range of text in a specific file.
Definition at line 69 of file Replacement.h.
Creates an invalid (not applicable) replacement.
Definition at line 31 of file Replacement.cpp.
| clang::tooling::Replacement::Replacement | ( | StringRef | FilePath, |
| unsigned | Offset, | ||
| unsigned | Length, | ||
| StringRef | ReplacementText | ||
| ) |
Creates a replacement of the range [Offset, Offset+Length) in FilePath with ReplacementText.
| FilePath | A source file accessible via a SourceManager. |
| Offset | The byte offset of the start of the range in the file. |
| Length | The length of the range in bytes. |
Definition at line 34 of file Replacement.cpp.
| clang::tooling::Replacement::Replacement | ( | const SourceManager & | Sources, |
| SourceLocation | Start, | ||
| unsigned | Length, | ||
| StringRef | ReplacementText | ||
| ) |
Creates a Replacement of the range [Start, Start+Length) with ReplacementText.
Definition at line 39 of file Replacement.cpp.
| clang::tooling::Replacement::Replacement | ( | const SourceManager & | Sources, |
| const CharSourceRange & | Range, | ||
| StringRef | ReplacementText | ||
| ) |
Creates a Replacement of the given range with ReplacementText.
Definition at line 44 of file Replacement.cpp.
| clang::tooling::Replacement::Replacement | ( | const SourceManager & | Sources, |
| const Node & | NodeToReplace, | ||
| StringRef | ReplacementText | ||
| ) |
Creates a Replacement of the node with ReplacementText.
Definition at line 219 of file Replacement.h.
References clang::CharSourceRange::getTokenRange().
| bool clang::tooling::Replacement::apply | ( | Rewriter & | Rewrite | ) | const |
Applies the replacement on the Rewriter.
Definition at line 54 of file Replacement.cpp.
References clang::SrcMgr::C_User, clang::SourceManager::createFileID(), clang::FileManager::getFile(), clang::SourceManager::getFileID(), clang::SourceManager::getFileManager(), clang::tooling::Range::getLength(), clang::SourceManager::getLocForStartOfFile(), clang::tooling::Range::getOffset(), clang::Rewriter::getSourceMgr(), clang::SourceLocation::isValid(), clang::Rewriter::ReplaceText(), SM, and clang::SourceManager::translateFileLineCol().
| StringRef clang::tooling::Replacement::getFilePath | ( | ) | const [inline] |
Accessors.
Definition at line 104 of file Replacement.h.
Referenced by clang::tooling::operator<(), and clang::tooling::operator==().
| unsigned clang::tooling::Replacement::getLength | ( | ) | const [inline] |
Definition at line 106 of file Replacement.h.
References clang::tooling::Range::getLength().
Referenced by clang::tooling::deduplicate(), clang::tooling::operator<(), and clang::tooling::operator==().
| unsigned clang::tooling::Replacement::getOffset | ( | ) | const [inline] |
Definition at line 105 of file Replacement.h.
References clang::tooling::Range::getOffset().
Referenced by clang::tooling::deduplicate(), clang::tooling::operator<(), and clang::tooling::operator==().
| StringRef clang::tooling::Replacement::getReplacementText | ( | ) | const [inline] |
Definition at line 107 of file Replacement.h.
Referenced by clang::tooling::deduplicate(), clang::tooling::operator<(), and clang::tooling::operator==().
Returns whether this replacement can be applied to a file.
Only replacements that are in a valid file can be applied.
Definition at line 50 of file Replacement.cpp.
References clang::tooling::InvalidLocation.
| std::string clang::tooling::Replacement::toString | ( | ) | const |
Returns a human readable string representation.
Definition at line 79 of file Replacement.cpp.
References clang::tooling::Range::getLength(), and clang::tooling::Range::getOffset().