blob: 3f83cfe9013717322ae025af360cfa2bc6bd6842 [file] [log] [blame]
Alexander Kornienkocb45bc12013-04-15 14:28:00 +00001//===--- BreakableToken.h - Format C++ code -------------------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9///
10/// \file
Krasimir Georgiev91834222017-01-25 13:58:58 +000011/// \brief Declares BreakableToken, BreakableStringLiteral, BreakableComment,
12/// BreakableBlockComment and BreakableLineCommentSection classes, that contain
13/// token type-specific logic to break long lines in tokens and reflow content
14/// between tokens.
Alexander Kornienkocb45bc12013-04-15 14:28:00 +000015///
16//===----------------------------------------------------------------------===//
17
Benjamin Kramer2f5db8b2014-08-13 16:25:19 +000018#ifndef LLVM_CLANG_LIB_FORMAT_BREAKABLETOKEN_H
19#define LLVM_CLANG_LIB_FORMAT_BREAKABLETOKEN_H
Alexander Kornienkocb45bc12013-04-15 14:28:00 +000020
Alexander Kornienkoffcc0102013-06-05 14:09:10 +000021#include "Encoding.h"
Alexander Kornienkocb45bc12013-04-15 14:28:00 +000022#include "TokenAnnotator.h"
23#include "WhitespaceManager.h"
Krasimir Georgiev00c5c722017-02-02 15:32:19 +000024#include "llvm/Support/Regex.h"
Alexander Kornienkocb45bc12013-04-15 14:28:00 +000025#include <utility>
26
27namespace clang {
28namespace format {
29
Krasimir Georgiev91834222017-01-25 13:58:58 +000030/// \brief Checks if \p Token switches formatting, like /* clang-format off */.
31/// \p Token must be a comment.
32bool switchesFormatting(const FormatToken &Token);
33
Manuel Klimek9043c742013-05-27 15:23:34 +000034struct FormatStyle;
35
36/// \brief Base class for strategies on how to break tokens.
37///
Krasimir Georgiev91834222017-01-25 13:58:58 +000038/// This is organised around the concept of a \c Split, which is a whitespace
39/// range that signifies a position of the content of a token where a
40/// reformatting might be done. Operating with splits is divided into 3
41/// operations:
42/// - getSplit, for finding a split starting at a position,
43/// - getLineLengthAfterSplit, for calculating the size in columns of the rest
44/// of the content after a split has been used for breaking, and
45/// - insertBreak, for executing the split using a whitespace manager.
46///
47/// There is a pair of operations that are used to compress a long whitespace
48/// range with a single space if that will bring the line lenght under the
49/// column limit:
50/// - getLineLengthAfterCompression, for calculating the size in columns of the
51/// line after a whitespace range has been compressed, and
52/// - compressWhitespace, for executing the whitespace compression using a
53/// whitespace manager; note that the compressed whitespace may be in the
54/// middle of the original line and of the reformatted line.
55///
56/// For tokens where the whitespace before each line needs to be also
57/// reformatted, for example for tokens supporting reflow, there are analogous
58/// operations that might be executed before the main line breaking occurs:
59/// - getSplitBefore, for finding a split such that the content preceding it
60/// needs to be specially reflown,
61/// - getLineLengthAfterSplitBefore, for calculating the line length in columns
62/// of the remainder of the content after the beginning of the content has
63/// been reformatted, and
64/// - replaceWhitespaceBefore, for executing the reflow using a whitespace
65/// manager.
66///
Manuel Klimek9043c742013-05-27 15:23:34 +000067/// FIXME: The interface seems set in stone, so we might want to just pull the
68/// strategy into the class, instead of controlling it from the outside.
Alexander Kornienkocb45bc12013-04-15 14:28:00 +000069class BreakableToken {
70public:
Alexander Kornienkodd7ece52013-06-07 16:02:52 +000071 /// \brief Contains starting character index and length of split.
Manuel Klimek9043c742013-05-27 15:23:34 +000072 typedef std::pair<StringRef::size_type, unsigned> Split;
73
Angel Garcia Gomez637d1e62015-10-20 13:23:58 +000074 virtual ~BreakableToken() {}
Manuel Klimek9043c742013-05-27 15:23:34 +000075
76 /// \brief Returns the number of lines in this token in the original code.
Alexander Kornienkocb45bc12013-04-15 14:28:00 +000077 virtual unsigned getLineCount() const = 0;
Manuel Klimek9043c742013-05-27 15:23:34 +000078
Alexander Kornienkodd7ece52013-06-07 16:02:52 +000079 /// \brief Returns the number of columns required to format the piece of line
Krasimir Georgiev91834222017-01-25 13:58:58 +000080 /// at \p LineIndex, from byte offset \p TailOffset with length \p Length.
Manuel Klimek9043c742013-05-27 15:23:34 +000081 ///
Krasimir Georgiev91834222017-01-25 13:58:58 +000082 /// Note that previous breaks are not taken into account. \p TailOffset is
83 /// always specified from the start of the (original) line.
Alexander Kornienkodd7ece52013-06-07 16:02:52 +000084 /// \p Length can be set to StringRef::npos, which means "to the end of line".
85 virtual unsigned
Krasimir Georgiev91834222017-01-25 13:58:58 +000086 getLineLengthAfterSplit(unsigned LineIndex, unsigned TailOffset,
Daniel Jasper3ac9b9e2013-07-08 14:34:09 +000087 StringRef::size_type Length) const = 0;
Alexander Kornienkocb45bc12013-04-15 14:28:00 +000088
Manuel Klimek9043c742013-05-27 15:23:34 +000089 /// \brief Returns a range (offset, length) at which to break the line at
90 /// \p LineIndex, if previously broken at \p TailOffset. If possible, do not
91 /// violate \p ColumnLimit.
Alexander Kornienkocb45bc12013-04-15 14:28:00 +000092 virtual Split getSplit(unsigned LineIndex, unsigned TailOffset,
Alexander Kornienko9e90b622013-04-17 17:34:05 +000093 unsigned ColumnLimit) const = 0;
Manuel Klimek9043c742013-05-27 15:23:34 +000094
95 /// \brief Emits the previously retrieved \p Split via \p Whitespaces.
Alexander Kornienkocb45bc12013-04-15 14:28:00 +000096 virtual void insertBreak(unsigned LineIndex, unsigned TailOffset, Split Split,
Alexander Kornienkocb45bc12013-04-15 14:28:00 +000097 WhitespaceManager &Whitespaces) = 0;
Manuel Klimek9043c742013-05-27 15:23:34 +000098
Krasimir Georgiev91834222017-01-25 13:58:58 +000099 /// \brief Returns the number of columns required to format the piece of line
100 /// at \p LineIndex, from byte offset \p TailOffset after the whitespace range
101 /// \p Split has been compressed into a single space.
102 unsigned getLineLengthAfterCompression(unsigned RemainingTokenColumns,
103 Split Split) const;
104
Alexander Kornienko875395f2013-11-12 17:50:13 +0000105 /// \brief Replaces the whitespace range described by \p Split with a single
106 /// space.
Krasimir Georgiev91834222017-01-25 13:58:58 +0000107 virtual void compressWhitespace(unsigned LineIndex, unsigned TailOffset,
108 Split Split,
109 WhitespaceManager &Whitespaces) = 0;
110
111 /// \brief Returns a whitespace range (offset, length) of the content at
112 /// \p LineIndex such that the content preceding this range needs to be
113 /// reformatted before any breaks are made to this line.
114 ///
115 /// \p PreviousEndColumn is the end column of the previous line after
116 /// formatting.
117 ///
118 /// A result having offset == StringRef::npos means that no piece of the line
119 /// needs to be reformatted before any breaks are made.
120 virtual Split getSplitBefore(unsigned LineIndex,
121 unsigned PreviousEndColumn,
Krasimir Georgiev00c5c722017-02-02 15:32:19 +0000122 unsigned ColumnLimit,
123 llvm::Regex& CommentPragmasRegex) const {
Krasimir Georgiev91834222017-01-25 13:58:58 +0000124 return Split(StringRef::npos, 0);
125 }
126
127 /// \brief Returns the number of columns required to format the piece of line
128 /// at \p LineIndex after the content preceding the whitespace range specified
129 /// \p SplitBefore has been reformatted, but before any breaks are made to
130 /// this line.
131 virtual unsigned getLineLengthAfterSplitBefore(unsigned LineIndex,
132 unsigned TailOffset,
133 unsigned PreviousEndColumn,
134 unsigned ColumnLimit,
135 Split SplitBefore) const {
136 return getLineLengthAfterSplit(LineIndex, TailOffset, StringRef::npos);
137 }
Alexander Kornienko875395f2013-11-12 17:50:13 +0000138
Manuel Klimek9043c742013-05-27 15:23:34 +0000139 /// \brief Replaces the whitespace between \p LineIndex-1 and \p LineIndex.
Krasimir Georgiev91834222017-01-25 13:58:58 +0000140 /// Performs a reformatting of the content at \p LineIndex preceding the
141 /// whitespace range \p SplitBefore.
Manuel Klimek9043c742013-05-27 15:23:34 +0000142 virtual void replaceWhitespaceBefore(unsigned LineIndex,
Krasimir Georgiev91834222017-01-25 13:58:58 +0000143 unsigned PreviousEndColumn,
144 unsigned ColumnLimit,
145 Split SplitBefore,
Manuel Klimek9043c742013-05-27 15:23:34 +0000146 WhitespaceManager &Whitespaces) {}
147
Krasimir Georgiev91834222017-01-25 13:58:58 +0000148 /// \brief Updates the next token of \p State to the next token after this
149 /// one. This can be used when this token manages a set of underlying tokens
150 /// as a unit and is responsible for the formatting of the them.
151 virtual void updateNextToken(LineState &State) const {}
152
Alexander Kornienko9e90b622013-04-17 17:34:05 +0000153protected:
Daniel Jasper7d42f3f2017-01-31 11:25:01 +0000154 BreakableToken(const FormatToken &Tok, bool InPPDirective,
155 encoding::Encoding Encoding, const FormatStyle &Style)
156 : Tok(Tok), InPPDirective(InPPDirective), Encoding(Encoding),
157 Style(Style) {}
Manuel Klimek9043c742013-05-27 15:23:34 +0000158
Alexander Kornienko9e90b622013-04-17 17:34:05 +0000159 const FormatToken &Tok;
Alexander Kornienkobe633902013-06-14 11:46:10 +0000160 const bool InPPDirective;
161 const encoding::Encoding Encoding;
Alexander Kornienkoebb43ca2013-09-05 14:08:34 +0000162 const FormatStyle &Style;
Alexander Kornienkocb45bc12013-04-15 14:28:00 +0000163};
164
Manuel Klimek9043c742013-05-27 15:23:34 +0000165/// \brief Base class for single line tokens that can be broken.
166///
167/// \c getSplit() needs to be implemented by child classes.
168class BreakableSingleLineToken : public BreakableToken {
Alexander Kornienkocb45bc12013-04-15 14:28:00 +0000169public:
Craig Topperfb6b25b2014-03-15 04:29:04 +0000170 unsigned getLineCount() const override;
171 unsigned getLineLengthAfterSplit(unsigned LineIndex, unsigned TailOffset,
172 StringRef::size_type Length) const override;
Alexander Kornienko9e90b622013-04-17 17:34:05 +0000173
174protected:
Daniel Jasper7d42f3f2017-01-31 11:25:01 +0000175 BreakableSingleLineToken(const FormatToken &Tok, unsigned StartColumn,
176 StringRef Prefix, StringRef Postfix,
177 bool InPPDirective, encoding::Encoding Encoding,
Alexander Kornienkoebb43ca2013-09-05 14:08:34 +0000178 const FormatStyle &Style);
Alexander Kornienko9e90b622013-04-17 17:34:05 +0000179
Manuel Klimek9043c742013-05-27 15:23:34 +0000180 // The column in which the token starts.
181 unsigned StartColumn;
182 // The prefix a line needs after a break in the token.
183 StringRef Prefix;
184 // The postfix a line needs before introducing a break.
185 StringRef Postfix;
186 // The token text excluding the prefix and postfix.
187 StringRef Line;
Alexander Kornienko9e90b622013-04-17 17:34:05 +0000188};
189
Manuel Klimek9043c742013-05-27 15:23:34 +0000190class BreakableStringLiteral : public BreakableSingleLineToken {
Alexander Kornienkocb45bc12013-04-15 14:28:00 +0000191public:
Manuel Klimek9043c742013-05-27 15:23:34 +0000192 /// \brief Creates a breakable token for a single line string literal.
193 ///
194 /// \p StartColumn specifies the column in which the token will start
195 /// after formatting.
Daniel Jasper7d42f3f2017-01-31 11:25:01 +0000196 BreakableStringLiteral(const FormatToken &Tok, unsigned StartColumn,
197 StringRef Prefix, StringRef Postfix,
198 bool InPPDirective, encoding::Encoding Encoding,
199 const FormatStyle &Style);
Alexander Kornienkocb45bc12013-04-15 14:28:00 +0000200
Craig Topperfb6b25b2014-03-15 04:29:04 +0000201 Split getSplit(unsigned LineIndex, unsigned TailOffset,
202 unsigned ColumnLimit) const override;
203 void insertBreak(unsigned LineIndex, unsigned TailOffset, Split Split,
204 WhitespaceManager &Whitespaces) override;
Krasimir Georgiev91834222017-01-25 13:58:58 +0000205 void compressWhitespace(unsigned LineIndex, unsigned TailOffset, Split Split,
206 WhitespaceManager &Whitespaces) override {}
Manuel Klimek9043c742013-05-27 15:23:34 +0000207};
Alexander Kornienkocb45bc12013-04-15 14:28:00 +0000208
Krasimir Georgiev91834222017-01-25 13:58:58 +0000209class BreakableComment : public BreakableToken {
210protected:
211 /// \brief Creates a breakable token for a comment.
Manuel Klimek9043c742013-05-27 15:23:34 +0000212 ///
213 /// \p StartColumn specifies the column in which the comment will start
214 /// after formatting, while \p OriginalStartColumn specifies in which
215 /// column the comment started before formatting.
216 /// If the comment starts a line after formatting, set \p FirstInLine to true.
Daniel Jasper7d42f3f2017-01-31 11:25:01 +0000217 BreakableComment(const FormatToken &Token, unsigned StartColumn,
218 unsigned OriginalStartColumn, bool FirstInLine,
219 bool InPPDirective, encoding::Encoding Encoding,
220 const FormatStyle &Style);
Krasimir Georgiev91834222017-01-25 13:58:58 +0000221
222public:
223 unsigned getLineCount() const override;
224 Split getSplit(unsigned LineIndex, unsigned TailOffset,
225 unsigned ColumnLimit) const override;
226 void compressWhitespace(unsigned LineIndex, unsigned TailOffset, Split Split,
227 WhitespaceManager &Whitespaces) override;
228
229protected:
230 virtual unsigned getContentStartColumn(unsigned LineIndex,
231 unsigned TailOffset) const = 0;
232
233 // Returns a split that divides Text into a left and right parts, such that
234 // the left part is suitable for reflowing after PreviousEndColumn.
235 Split getReflowSplit(StringRef Text, StringRef ReflowPrefix,
236 unsigned PreviousEndColumn, unsigned ColumnLimit) const;
237
238 // Returns the token containing the line at LineIndex.
239 const FormatToken &tokenAt(unsigned LineIndex) const;
240
241 // Checks if the content of line LineIndex may be reflown with the previous
242 // line.
Krasimir Georgiev00c5c722017-02-02 15:32:19 +0000243 virtual bool mayReflow(unsigned LineIndex,
244 llvm::Regex &CommentPragmasRegex) const = 0;
Krasimir Georgiev91834222017-01-25 13:58:58 +0000245
246 // Contains the original text of the lines of the block comment.
247 //
248 // In case of a block comments, excludes the leading /* in the first line and
249 // trailing */ in the last line. In case of line comments, excludes the
250 // leading // and spaces.
251 SmallVector<StringRef, 16> Lines;
252
253 // Contains the text of the lines excluding all leading and trailing
254 // whitespace between the lines. Note that the decoration (if present) is also
255 // not considered part of the text.
256 SmallVector<StringRef, 16> Content;
257
258 // Tokens[i] contains a reference to the token containing Lines[i] if the
259 // whitespace range before that token is managed by this block.
260 // Otherwise, Tokens[i] is a null pointer.
261 SmallVector<FormatToken *, 16> Tokens;
262
263 // ContentColumn[i] is the target column at which Content[i] should be.
264 // Note that this excludes a leading "* " or "*" in case of block comments
265 // where all lines have a "*" prefix, or the leading "// " or "//" in case of
266 // line comments.
267 //
268 // In block comments, the first line's target column is always positive. The
269 // remaining lines' target columns are relative to the first line to allow
270 // correct indentation of comments in \c WhitespaceManager. Thus they can be
271 // negative as well (in case the first line needs to be unindented more than
272 // there's actual whitespace in another line).
273 SmallVector<int, 16> ContentColumn;
274
275 // The intended start column of the first line of text from this section.
276 unsigned StartColumn;
277
278 // The original start column of the first line of text from this section.
279 unsigned OriginalStartColumn;
280
281 // Whether the first token of this section is the first token in its unwrapped
282 // line.
283 bool FirstInLine;
284
Krasimir Georgiev91834222017-01-25 13:58:58 +0000285 // The prefix to use in front a line that has been reflown up.
286 // For example, when reflowing the second line after the first here:
287 // // comment 1
288 // // comment 2
289 // we expect:
290 // // comment 1 comment 2
291 // and not:
292 // // comment 1comment 2
293 StringRef ReflowPrefix = " ";
294};
295
296class BreakableBlockComment : public BreakableComment {
297public:
Daniel Jasper7d42f3f2017-01-31 11:25:01 +0000298 BreakableBlockComment(const FormatToken &Token, unsigned StartColumn,
299 unsigned OriginalStartColumn, bool FirstInLine,
300 bool InPPDirective, encoding::Encoding Encoding,
301 const FormatStyle &Style);
Manuel Klimek9043c742013-05-27 15:23:34 +0000302
Krasimir Georgiev91834222017-01-25 13:58:58 +0000303 unsigned getLineLengthAfterSplit(unsigned LineIndex,
304 unsigned TailOffset,
Craig Topperfb6b25b2014-03-15 04:29:04 +0000305 StringRef::size_type Length) const override;
Craig Topperfb6b25b2014-03-15 04:29:04 +0000306 void insertBreak(unsigned LineIndex, unsigned TailOffset, Split Split,
307 WhitespaceManager &Whitespaces) override;
Krasimir Georgiev91834222017-01-25 13:58:58 +0000308 Split getSplitBefore(unsigned LineIndex, unsigned PreviousEndColumn,
Krasimir Georgiev00c5c722017-02-02 15:32:19 +0000309 unsigned ColumnLimit,
310 llvm::Regex &CommentPragmasRegex) const override;
Krasimir Georgiev91834222017-01-25 13:58:58 +0000311 unsigned getLineLengthAfterSplitBefore(unsigned LineIndex,
312 unsigned TailOffset,
313 unsigned PreviousEndColumn,
314 unsigned ColumnLimit,
315 Split SplitBefore) const override;
316 void replaceWhitespaceBefore(unsigned LineIndex, unsigned PreviousEndColumn,
317 unsigned ColumnLimit,
318 Split SplitBefore,
Craig Topperfb6b25b2014-03-15 04:29:04 +0000319 WhitespaceManager &Whitespaces) override;
Krasimir Georgiev00c5c722017-02-02 15:32:19 +0000320 bool mayReflow(unsigned LineIndex,
321 llvm::Regex &CommentPragmasRegex) const override;
Alexander Kornienkocb45bc12013-04-15 14:28:00 +0000322
323private:
Krasimir Georgiev91834222017-01-25 13:58:58 +0000324 // Rearranges the whitespace between Lines[LineIndex-1] and Lines[LineIndex].
Manuel Klimek9043c742013-05-27 15:23:34 +0000325 //
Krasimir Georgiev91834222017-01-25 13:58:58 +0000326 // Updates Content[LineIndex-1] and Content[LineIndex] by stripping off
327 // leading and trailing whitespace.
328 //
329 // Sets ContentColumn to the intended column in which the text at
Manuel Klimek9043c742013-05-27 15:23:34 +0000330 // Lines[LineIndex] starts (note that the decoration, if present, is not
331 // considered part of the text).
Alexander Kornienkoebb43ca2013-09-05 14:08:34 +0000332 void adjustWhitespace(unsigned LineIndex, int IndentDelta);
Alexander Kornienko9e90b622013-04-17 17:34:05 +0000333
Krasimir Georgiev91834222017-01-25 13:58:58 +0000334 // Computes the end column if the full Content from LineIndex gets reflown
335 // after PreviousEndColumn.
336 unsigned getReflownColumn(StringRef Content,
337 unsigned LineIndex,
338 unsigned PreviousEndColumn) const;
Alexander Kornienko9e90b622013-04-17 17:34:05 +0000339
Krasimir Georgiev91834222017-01-25 13:58:58 +0000340 unsigned getContentStartColumn(unsigned LineIndex,
341 unsigned TailOffset) const override;
Manuel Klimek9043c742013-05-27 15:23:34 +0000342
343 // The column at which the text of a broken line should start.
344 // Note that an optional decoration would go before that column.
345 // IndentAtLineBreak is a uniform position for all lines in a block comment,
346 // regardless of their relative position.
347 // FIXME: Revisit the decision to do this; the main reason was to support
348 // patterns like
349 // /**************//**
350 // * Comment
351 // We could also support such patterns by special casing the first line
352 // instead.
353 unsigned IndentAtLineBreak;
354
Alexander Kornienko614d96a2013-07-08 14:12:07 +0000355 // This is to distinguish between the case when the last line was empty and
356 // the case when it started with a decoration ("*" or "* ").
357 bool LastLineNeedsDecoration;
358
Manuel Klimek9043c742013-05-27 15:23:34 +0000359 // Either "* " if all lines begin with a "*", or empty.
360 StringRef Decoration;
Krasimir Georgievbb99a362017-02-16 12:39:31 +0000361
362 // If this block comment has decorations, this is the column of the start of
363 // the decorations.
364 unsigned DecorationColumn;
Alexander Kornienkocb45bc12013-04-15 14:28:00 +0000365};
366
Krasimir Georgiev91834222017-01-25 13:58:58 +0000367class BreakableLineCommentSection : public BreakableComment {
368public:
Daniel Jasper7d42f3f2017-01-31 11:25:01 +0000369 BreakableLineCommentSection(const FormatToken &Token, unsigned StartColumn,
Krasimir Georgiev91834222017-01-25 13:58:58 +0000370 unsigned OriginalStartColumn, bool FirstInLine,
371 bool InPPDirective, encoding::Encoding Encoding,
372 const FormatStyle &Style);
373
374 unsigned getLineLengthAfterSplit(unsigned LineIndex,
375 unsigned TailOffset,
376 StringRef::size_type Length) const override;
377 void insertBreak(unsigned LineIndex, unsigned TailOffset, Split Split,
378 WhitespaceManager &Whitespaces) override;
379 Split getSplitBefore(unsigned LineIndex, unsigned PreviousEndColumn,
Krasimir Georgiev00c5c722017-02-02 15:32:19 +0000380 unsigned ColumnLimit,
381 llvm::Regex &CommentPragmasRegex) const override;
Krasimir Georgiev91834222017-01-25 13:58:58 +0000382 unsigned getLineLengthAfterSplitBefore(unsigned LineIndex, unsigned TailOffset,
383 unsigned PreviousEndColumn,
384 unsigned ColumnLimit,
385 Split SplitBefore) const override;
386 void replaceWhitespaceBefore(unsigned LineIndex, unsigned PreviousEndColumn,
387 unsigned ColumnLimit, Split SplitBefore,
388 WhitespaceManager &Whitespaces) override;
389 void updateNextToken(LineState& State) const override;
Krasimir Georgiev00c5c722017-02-02 15:32:19 +0000390 bool mayReflow(unsigned LineIndex,
391 llvm::Regex &CommentPragmasRegex) const override;
Krasimir Georgiev91834222017-01-25 13:58:58 +0000392
393private:
394 unsigned getContentStartColumn(unsigned LineIndex,
395 unsigned TailOffset) const override;
396
Krasimir Georgiev2091a3a2017-02-08 14:45:19 +0000397 // OriginalPrefix[i] contains the original prefix of line i, including
398 // trailing whitespace before the start of the content. The indentation
399 // preceding the prefix is not included.
400 // For example, if the line is:
401 // // content
402 // then the original prefix is "// ".
403 SmallVector<StringRef, 16> OriginalPrefix;
404
Krasimir Georgiev91834222017-01-25 13:58:58 +0000405 // Prefix[i] contains the intended leading "//" with trailing spaces to
406 // account for the indentation of content within the comment at line i after
407 // formatting. It can be different than the original prefix when the original
408 // line starts like this:
409 // //content
410 // Then the original prefix is "//", but the prefix is "// ".
411 SmallVector<StringRef, 16> Prefix;
412
413 SmallVector<unsigned, 16> OriginalContentColumn;
414
415 /// \brief The token to which the last line of this breakable token belongs
416 /// to; nullptr if that token is the initial token.
417 ///
418 /// The distinction is because if the token of the last line of this breakable
419 /// token is distinct from the initial token, this breakable token owns the
420 /// whitespace before the token of the last line, and the whitespace manager
421 /// must be able to modify it.
422 FormatToken *LastLineTok = nullptr;
423};
Alexander Kornienkocb45bc12013-04-15 14:28:00 +0000424} // namespace format
425} // namespace clang
426
Benjamin Kramer2f5db8b2014-08-13 16:25:19 +0000427#endif