clang: include/clang/Edit/Commit.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9#ifndef LLVM_CLANG_EDIT_COMMIT_H
10#define LLVM_CLANG_EDIT_COMMIT_H
11
15#include "llvm/ADT/SmallVector.h"
16#include "llvm/ADT/StringRef.h"
17#include "llvm/Support/Allocator.h"
18
20
24
26
28
30public:
36
50
51private:
56
57 bool IsCommitable = true;
59
60 llvm::BumpPtrAllocator StrAlloc;
61
62public:
66 : SourceMgr(SM), LangOpts(LangOpts), PPRec(PPRec) {}
67
69
71 bool beforePreviousInsertions = false);
72
74 bool beforePreviousInsertions = false) {
75 return insert(loc, text, true, beforePreviousInsertions);
76 }
77
79 return insert(loc, text, false,
80 true);
81 }
82
84 bool afterToken = false,
85 bool beforePreviousInsertions = false);
87
89
93 StringRef replacementText);
94
96 bool afterToken = false,
97 bool beforePreviousInsertions = false) {
99 afterToken, beforePreviousInsertions);
100 }
101
105
109
113
118
120
123
124private:
126 FileOffset Offs, StringRef text, bool beforePreviousInsertions);
128 FileOffset RangeOffs, unsigned RangeLen,
129 bool beforePreviousInsertions);
131
137 bool canReplaceText(SourceLocation loc, StringRef text,
139
140 void commitInsert(FileOffset offset, StringRef text,
141 bool beforePreviousInsertions);
143
148};
149
150}
151
152}
153
154#endif
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines the clang::SourceLocation class and associated facilities.
Represents a character-granular source range.
static CharSourceRange getTokenRange(SourceRange R)
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Records preprocessor conditional directive regions and allows querying in which region source locatio...
Encodes a location in the source.
This class handles loading and caching of source files into memory.
A trivial tuple used to represent a source range.
bool replaceWithInner(CharSourceRange range, CharSourceRange innerRange)
bool remove(SourceRange TokenRange)
Definition Commit.h:106
bool insertWrap(StringRef before, CharSourceRange range, StringRef after)
bool insertFromRange(SourceLocation loc, CharSourceRange range, bool afterToken=false, bool beforePreviousInsertions=false)
bool insert(SourceLocation loc, StringRef text, bool afterToken=false, bool beforePreviousInsertions=false)
Commit(EditedSource &Editor)
Commit(const SourceManager &SM, const LangOptions &LangOpts, const PPConditionalDirectiveRecord *PPRec=nullptr)
Definition Commit.h:64
bool isCommitable() const
Definition Commit.h:68
bool insertAfterToken(SourceLocation loc, StringRef text, bool beforePreviousInsertions=false)
Definition Commit.h:73
edit_iterator edit_begin() const
Definition Commit.h:121
EditKind
Definition Commit.h:31
@ Act_Remove
Definition Commit.h:34
@ Act_InsertFromRange
Definition Commit.h:33
@ Act_Insert
Definition Commit.h:32
SmallVectorImpl< Edit >::const_iterator edit_iterator
Definition Commit.h:119
bool remove(CharSourceRange range)
bool insertBefore(SourceLocation loc, StringRef text)
Definition Commit.h:78
bool insertWrap(StringRef before, SourceRange TokenRange, StringRef after)
Definition Commit.h:102
bool replace(SourceRange TokenRange, StringRef text)
Definition Commit.h:110
bool insertFromRange(SourceLocation loc, SourceRange TokenRange, bool afterToken=false, bool beforePreviousInsertions=false)
Definition Commit.h:95
bool replaceWithInner(SourceRange TokenRange, SourceRange TokenInnerRange)
Definition Commit.h:114
bool replace(CharSourceRange range, StringRef text)
edit_iterator edit_end() const
Definition Commit.h:122
bool replaceText(SourceLocation loc, StringRef text, StringRef replacementText)
The JSON file list parser is used to communicate input to InstallAPI.
float __ovld __cnfn length(float)
Return the length of vector p, i.e., sqrt(p.x2 + p.y 2 + ...)
bool BeforePrev
Definition Commit.h:44
SourceLocation getFileLocation(SourceManager &SM) const
FileOffset Offset
Definition Commit.h:41
StringRef Text
Definition Commit.h:39
unsigned Length
Definition Commit.h:43
CharSourceRange getFileRange(SourceManager &SM) const
FileOffset InsertFromRangeOffs
Definition Commit.h:42
SourceLocation OrigLoc
Definition Commit.h:40
EditKind Kind
Definition Commit.h:38
CharSourceRange getInsertFromRange(SourceManager &SM) const