File indexing completed on 2026-05-10 08:37:12
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019 #ifndef LLVM_CLANG_TOOLING_FIXIT_H
0020 #define LLVM_CLANG_TOOLING_FIXIT_H
0021
0022 #include "clang/AST/ASTContext.h"
0023
0024 namespace clang {
0025 namespace tooling {
0026 namespace fixit {
0027
0028 namespace internal {
0029 StringRef getText(CharSourceRange Range, const ASTContext &Context);
0030
0031
0032 inline CharSourceRange getSourceRange(const SourceRange &Range) {
0033 return CharSourceRange::getTokenRange(Range);
0034 }
0035
0036
0037 inline CharSourceRange getSourceRange(const SourceLocation &Loc) {
0038 return CharSourceRange::getTokenRange(Loc, Loc);
0039 }
0040
0041
0042
0043 template <typename T> CharSourceRange getSourceRange(const T &Node) {
0044 return CharSourceRange::getTokenRange(Node.getSourceRange());
0045 }
0046 }
0047
0048
0049 template <typename T>
0050 StringRef getText(const T &Node, const ASTContext &Context) {
0051 return internal::getText(internal::getSourceRange(Node), Context);
0052 }
0053
0054
0055
0056 template <typename T> FixItHint createRemoval(const T &Node) {
0057 return FixItHint::CreateRemoval(internal::getSourceRange(Node));
0058 }
0059
0060
0061 template <typename D, typename S>
0062 FixItHint createReplacement(const D &Destination, const S &Source,
0063 const ASTContext &Context) {
0064 return FixItHint::CreateReplacement(internal::getSourceRange(Destination),
0065 getText(Source, Context));
0066 }
0067
0068
0069 template <typename D>
0070 FixItHint createReplacement(const D &Destination, StringRef Source) {
0071 return FixItHint::CreateReplacement(internal::getSourceRange(Destination),
0072 Source);
0073 }
0074
0075 }
0076 }
0077 }
0078
0079 #endif