clang: include/clang/Rewrite/Core/Rewriter.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14#ifndef LLVM_CLANG_REWRITE_CORE_REWRITER_H

15#define LLVM_CLANG_REWRITE_CORE_REWRITER_H

16

19#include "llvm/ADT/RewriteBuffer.h"

20#include "llvm/ADT/StringRef.h"

21#include

22#include

23

25

28

29

30

31

35 std::map<FileID, llvm::RewriteBuffer> RewriteBuffers;

36

37public:

39

40

42

43

44

46

47

48

49

50

51

52

53

54

55

56

57

58

59

61

63 };

64

65 using buffer_iterator = std::map<FileID, llvm::RewriteBuffer>::iterator;

67 std::map<FileID, llvm::RewriteBuffer>::const_iterator;

68

71 : SourceMgr(&SM), LangOpts(&LO) {}

72

74 SourceMgr = &SM;

75 LangOpts = &LO;

76 }

77

80

81

82

86

87

88

90 RewriteOptions opts = RewriteOptions()) const;

92 RewriteOptions opts = RewriteOptions()) const;

93

94

95

96

97

98

100

101

102

103

104

105

109

110

111

112

113

114

115

117 bool InsertAfter = true, bool indentNewLines = false);

118

119

120

121

122

123

127

128

129

131

132

133

134

135

136

140

141

143 RewriteOptions opts = RewriteOptions());

144

145

150

151

155

156

157

158

160 StringRef NewStr);

161

162

163

164

168

169

170

171

175

176

177

178

180

181

182

183

184

190

191

192

193

194

196

197

198

200 std::map<FileID, llvm::RewriteBuffer>::const_iterator I =

201 RewriteBuffers.find(FID);

202 return I == RewriteBuffers.end() ? nullptr : &I->second;

203 }

204

205

210

211

212

213

214

215

217

218private:

220};

221

222}

223

224#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)

An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...

Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...

bool InsertTextBefore(SourceLocation Loc, StringRef Str)

InsertText - Insert the specified string at the specified location in the original buffer.

Definition Rewriter.h:137

std::map< FileID, llvm::RewriteBuffer >::iterator buffer_iterator

Definition Rewriter.h:65

int getRangeSize(SourceRange Range, RewriteOptions opts=RewriteOptions()) const

getRangeSize - Return the size in bytes of the specified range if they are in the same file.

void setSourceMgr(SourceManager &SM, const LangOptions &LO)

Definition Rewriter.h:73

std::string getRewrittenText(SourceRange Range) const

getRewrittenText - Return the rewritten form of the text in the specified range.

Definition Rewriter.h:106

const_buffer_iterator buffer_begin() const

Definition Rewriter.h:208

std::map< FileID, llvm::RewriteBuffer >::const_iterator const_buffer_iterator

Definition Rewriter.h:66

bool ReplaceText(CharSourceRange range, StringRef NewStr)

ReplaceText - This method replaces a range of characters in the input buffer with a new string.

Definition Rewriter.h:165

bool InsertText(SourceLocation Loc, StringRef Str, bool InsertAfter=true, bool indentNewLines=false)

InsertText - Insert the specified string at the specified location in the original buffer.

bool RemoveText(SourceLocation Start, unsigned Length, RewriteOptions opts=RewriteOptions())

RemoveText - Remove the specified text region.

const_buffer_iterator buffer_end() const

Definition Rewriter.h:209

bool IncreaseIndentation(SourceRange range, SourceLocation parentIndent)

Definition Rewriter.h:186

bool RemoveText(SourceRange range, RewriteOptions opts=RewriteOptions())

Remove the specified text region.

Definition Rewriter.h:152

static bool isRewritable(SourceLocation Loc)

isRewritable - Return true if this location is a raw file location, which is rewritable.

Definition Rewriter.h:83

buffer_iterator buffer_end()

Definition Rewriter.h:207

SourceManager & getSourceMgr() const

Definition Rewriter.h:78

const LangOptions & getLangOpts() const

Definition Rewriter.h:79

Rewriter(SourceManager &SM, const LangOptions &LO)

Definition Rewriter.h:70

buffer_iterator buffer_begin()

Definition Rewriter.h:206

bool ReplaceText(SourceRange range, StringRef NewStr)

ReplaceText - This method replaces a range of characters in the input buffer with a new string.

Definition Rewriter.h:172

bool RemoveText(CharSourceRange range, RewriteOptions opts=RewriteOptions())

Remove the specified text region.

Definition Rewriter.h:146

const llvm::RewriteBuffer * getRewriteBufferFor(FileID FID) const

getRewriteBufferFor - Return the rewrite buffer for the specified FileID.

Definition Rewriter.h:199

bool InsertTextAfter(SourceLocation Loc, StringRef Str)

InsertTextAfter - Insert the specified string at the specified location in the original buffer.

Definition Rewriter.h:124

std::string getRewrittenText(CharSourceRange Range) const

getRewrittenText - Return the rewritten form of the text in the specified range.

bool IncreaseIndentation(CharSourceRange range, SourceLocation parentIndent)

Increase indentation for the lines between the given source range.

bool InsertTextAfterToken(SourceLocation Loc, StringRef Str)

Insert the specified string after the token in the specified location.

llvm::RewriteBuffer & getEditBuffer(FileID FID)

getEditBuffer - This is like getRewriteBufferFor, but always returns a buffer, and allows you to writ...

bool overwriteChangedFiles()

overwriteChangedFiles - Save all changed files to disk.

bool ReplaceText(SourceLocation Start, unsigned OrigLength, StringRef NewStr)

ReplaceText - This method replaces a range of characters in the input buffer with a new string.

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.

The JSON file list parser is used to communicate input to InstallAPI.

nullptr

This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...

RewriteOptions()

Definition Rewriter.h:62

bool IncludeInsertsAtBeginOfRange

Given a source range, true to include previous inserts at the beginning of the range as part of the r...

Definition Rewriter.h:41

bool IncludeInsertsAtEndOfRange

Given a source range, true to include previous inserts at the end of the range as part of the range i...

Definition Rewriter.h:45

bool RemoveLineIfEmpty

If true and removing some text leaves a blank line also remove the empty line (false by default).

Definition Rewriter.h:60