16 #ifndef LLVM_CLANG_LIB_FORMAT_WHITESPACEMANAGER_H
17 #define LLVM_CLANG_LIB_FORMAT_WHITESPACEMANAGER_H
42 : SourceMgr(SourceMgr), Style(Style), UseCRLF(UseCRLF) {}
50 unsigned IndentLevel,
unsigned Spaces,
51 unsigned StartOfTokenColumn,
52 bool InPPDirective =
false);
75 unsigned ReplaceChars,
76 StringRef PreviousPostfix,
77 StringRef CurrentPrefix,
bool InPPDirective,
78 unsigned Newlines,
unsigned IndentLevel,
92 bool operator()(
const Change &C1,
const Change &C2)
const;
109 Change(
bool CreateReplacement,
const SourceRange &OriginalWhitespaceRange,
110 unsigned IndentLevel,
int Spaces,
unsigned StartOfTokenColumn,
111 unsigned NewlinesBefore, StringRef PreviousLinePostfix,
113 bool ContinuesPPDirective);
115 bool CreateReplacement;
119 unsigned StartOfTokenColumn;
120 unsigned NewlinesBefore;
121 std::string PreviousLinePostfix;
122 std::string CurrentLinePrefix;
128 bool ContinuesPPDirective;
133 unsigned IndentLevel;
145 bool IsTrailingComment;
146 unsigned TokenLength;
147 unsigned PreviousEndOfTokenColumn;
148 unsigned EscapedNewlineColumn;
158 const Change *StartOfBlockComment;
159 int IndentationOffset;
165 void calculateLineBreakInformation();
168 void alignConsecutiveAssignments();
173 void alignConsecutiveAssignments(
unsigned Start,
unsigned End,
177 void alignTrailingComments();
181 void alignTrailingComments(
unsigned Start,
unsigned End,
unsigned Column);
184 void alignEscapedNewlines();
188 void alignEscapedNewlines(
unsigned Start,
unsigned End,
unsigned Column);
191 void generateChanges();
194 void storeReplacement(
const SourceRange &Range, StringRef Text);
195 void appendNewlineText(std::string &Text,
unsigned Newlines);
196 void appendNewlineText(std::string &Text,
unsigned Newlines,
197 unsigned PreviousEndOfTokenColumn,
198 unsigned EscapedNewlineColumn);
199 void appendIndentText(std::string &Text,
unsigned IndentLevel,
200 unsigned Spaces,
unsigned WhitespaceStartColumn);
205 const FormatStyle &Style;
Defines the SourceManager interface.
This file implements a token annotator, i.e. creates AnnotatedTokens out of FormatTokens with require...
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
A trivial tuple used to represent a source range.
This class handles loading and caching of source files into memory.