blob: e30c6171fcd91829a0c82529174c11de839b9635 [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 ///
Krasimir Georgiev4b159222017-02-21 10:54:50 +0000213 /// \p StartColumn specifies the column in which the comment will start after
214 /// formatting.
Daniel Jasper7d42f3f2017-01-31 11:25:01 +0000215 BreakableComment(const FormatToken &Token, unsigned StartColumn,
Daniel Jasper7d42f3f2017-01-31 11:25:01 +0000216 bool InPPDirective, encoding::Encoding Encoding,
217 const FormatStyle &Style);
Krasimir Georgiev91834222017-01-25 13:58:58 +0000218
219public:
220 unsigned getLineCount() const override;
221 Split getSplit(unsigned LineIndex, unsigned TailOffset,
222 unsigned ColumnLimit) const override;
223 void compressWhitespace(unsigned LineIndex, unsigned TailOffset, Split Split,
224 WhitespaceManager &Whitespaces) override;
225
226protected:
227 virtual unsigned getContentStartColumn(unsigned LineIndex,
228 unsigned TailOffset) const = 0;
229
230 // Returns a split that divides Text into a left and right parts, such that
231 // the left part is suitable for reflowing after PreviousEndColumn.
232 Split getReflowSplit(StringRef Text, StringRef ReflowPrefix,
233 unsigned PreviousEndColumn, unsigned ColumnLimit) const;
234
235 // Returns the token containing the line at LineIndex.
236 const FormatToken &tokenAt(unsigned LineIndex) const;
237
238 // Checks if the content of line LineIndex may be reflown with the previous
239 // line.
Krasimir Georgiev00c5c722017-02-02 15:32:19 +0000240 virtual bool mayReflow(unsigned LineIndex,
241 llvm::Regex &CommentPragmasRegex) const = 0;
Krasimir Georgiev91834222017-01-25 13:58:58 +0000242
243 // Contains the original text of the lines of the block comment.
244 //
245 // In case of a block comments, excludes the leading /* in the first line and
246 // trailing */ in the last line. In case of line comments, excludes the
247 // leading // and spaces.
248 SmallVector<StringRef, 16> Lines;
249
250 // Contains the text of the lines excluding all leading and trailing
251 // whitespace between the lines. Note that the decoration (if present) is also
252 // not considered part of the text.
253 SmallVector<StringRef, 16> Content;
254
255 // Tokens[i] contains a reference to the token containing Lines[i] if the
256 // whitespace range before that token is managed by this block.
257 // Otherwise, Tokens[i] is a null pointer.
258 SmallVector<FormatToken *, 16> Tokens;
259
260 // ContentColumn[i] is the target column at which Content[i] should be.
261 // Note that this excludes a leading "* " or "*" in case of block comments
262 // where all lines have a "*" prefix, or the leading "// " or "//" in case of
263 // line comments.
264 //
265 // In block comments, the first line's target column is always positive. The
266 // remaining lines' target columns are relative to the first line to allow
267 // correct indentation of comments in \c WhitespaceManager. Thus they can be
268 // negative as well (in case the first line needs to be unindented more than
269 // there's actual whitespace in another line).
270 SmallVector<int, 16> ContentColumn;
271
272 // The intended start column of the first line of text from this section.
273 unsigned StartColumn;
274
Krasimir Georgiev91834222017-01-25 13:58:58 +0000275 // The prefix to use in front a line that has been reflown up.
276 // For example, when reflowing the second line after the first here:
277 // // comment 1
278 // // comment 2
279 // we expect:
280 // // comment 1 comment 2
281 // and not:
282 // // comment 1comment 2
283 StringRef ReflowPrefix = " ";
284};
285
286class BreakableBlockComment : public BreakableComment {
287public:
Daniel Jasper7d42f3f2017-01-31 11:25:01 +0000288 BreakableBlockComment(const FormatToken &Token, unsigned StartColumn,
289 unsigned OriginalStartColumn, bool FirstInLine,
290 bool InPPDirective, encoding::Encoding Encoding,
291 const FormatStyle &Style);
Manuel Klimek9043c742013-05-27 15:23:34 +0000292
Krasimir Georgiev91834222017-01-25 13:58:58 +0000293 unsigned getLineLengthAfterSplit(unsigned LineIndex,
294 unsigned TailOffset,
Craig Topperfb6b25b2014-03-15 04:29:04 +0000295 StringRef::size_type Length) const override;
Craig Topperfb6b25b2014-03-15 04:29:04 +0000296 void insertBreak(unsigned LineIndex, unsigned TailOffset, Split Split,
297 WhitespaceManager &Whitespaces) override;
Krasimir Georgiev91834222017-01-25 13:58:58 +0000298 Split getSplitBefore(unsigned LineIndex, unsigned PreviousEndColumn,
Krasimir Georgiev00c5c722017-02-02 15:32:19 +0000299 unsigned ColumnLimit,
300 llvm::Regex &CommentPragmasRegex) const override;
Krasimir Georgiev91834222017-01-25 13:58:58 +0000301 unsigned getLineLengthAfterSplitBefore(unsigned LineIndex,
302 unsigned TailOffset,
303 unsigned PreviousEndColumn,
304 unsigned ColumnLimit,
305 Split SplitBefore) const override;
306 void replaceWhitespaceBefore(unsigned LineIndex, unsigned PreviousEndColumn,
307 unsigned ColumnLimit,
308 Split SplitBefore,
Craig Topperfb6b25b2014-03-15 04:29:04 +0000309 WhitespaceManager &Whitespaces) override;
Krasimir Georgiev00c5c722017-02-02 15:32:19 +0000310 bool mayReflow(unsigned LineIndex,
311 llvm::Regex &CommentPragmasRegex) const override;
Alexander Kornienkocb45bc12013-04-15 14:28:00 +0000312
313private:
Krasimir Georgiev91834222017-01-25 13:58:58 +0000314 // Rearranges the whitespace between Lines[LineIndex-1] and Lines[LineIndex].
Manuel Klimek9043c742013-05-27 15:23:34 +0000315 //
Krasimir Georgiev91834222017-01-25 13:58:58 +0000316 // Updates Content[LineIndex-1] and Content[LineIndex] by stripping off
317 // leading and trailing whitespace.
318 //
319 // Sets ContentColumn to the intended column in which the text at
Manuel Klimek9043c742013-05-27 15:23:34 +0000320 // Lines[LineIndex] starts (note that the decoration, if present, is not
321 // considered part of the text).
Alexander Kornienkoebb43ca2013-09-05 14:08:34 +0000322 void adjustWhitespace(unsigned LineIndex, int IndentDelta);
Alexander Kornienko9e90b622013-04-17 17:34:05 +0000323
Krasimir Georgiev91834222017-01-25 13:58:58 +0000324 // Computes the end column if the full Content from LineIndex gets reflown
325 // after PreviousEndColumn.
326 unsigned getReflownColumn(StringRef Content,
327 unsigned LineIndex,
328 unsigned PreviousEndColumn) const;
Alexander Kornienko9e90b622013-04-17 17:34:05 +0000329
Krasimir Georgiev91834222017-01-25 13:58:58 +0000330 unsigned getContentStartColumn(unsigned LineIndex,
331 unsigned TailOffset) const override;
Manuel Klimek9043c742013-05-27 15:23:34 +0000332
333 // The column at which the text of a broken line should start.
334 // Note that an optional decoration would go before that column.
335 // IndentAtLineBreak is a uniform position for all lines in a block comment,
336 // regardless of their relative position.
337 // FIXME: Revisit the decision to do this; the main reason was to support
338 // patterns like
339 // /**************//**
340 // * Comment
341 // We could also support such patterns by special casing the first line
342 // instead.
343 unsigned IndentAtLineBreak;
344
Alexander Kornienko614d96a2013-07-08 14:12:07 +0000345 // This is to distinguish between the case when the last line was empty and
346 // the case when it started with a decoration ("*" or "* ").
347 bool LastLineNeedsDecoration;
348
Manuel Klimek9043c742013-05-27 15:23:34 +0000349 // Either "* " if all lines begin with a "*", or empty.
350 StringRef Decoration;
Krasimir Georgievbb99a362017-02-16 12:39:31 +0000351
352 // If this block comment has decorations, this is the column of the start of
353 // the decorations.
354 unsigned DecorationColumn;
Alexander Kornienkocb45bc12013-04-15 14:28:00 +0000355};
356
Krasimir Georgiev91834222017-01-25 13:58:58 +0000357class BreakableLineCommentSection : public BreakableComment {
358public:
Daniel Jasper7d42f3f2017-01-31 11:25:01 +0000359 BreakableLineCommentSection(const FormatToken &Token, unsigned StartColumn,
Krasimir Georgiev91834222017-01-25 13:58:58 +0000360 unsigned OriginalStartColumn, bool FirstInLine,
361 bool InPPDirective, encoding::Encoding Encoding,
362 const FormatStyle &Style);
363
364 unsigned getLineLengthAfterSplit(unsigned LineIndex,
365 unsigned TailOffset,
366 StringRef::size_type Length) const override;
367 void insertBreak(unsigned LineIndex, unsigned TailOffset, Split Split,
368 WhitespaceManager &Whitespaces) override;
369 Split getSplitBefore(unsigned LineIndex, unsigned PreviousEndColumn,
Krasimir Georgiev00c5c722017-02-02 15:32:19 +0000370 unsigned ColumnLimit,
371 llvm::Regex &CommentPragmasRegex) const override;
Krasimir Georgiev91834222017-01-25 13:58:58 +0000372 unsigned getLineLengthAfterSplitBefore(unsigned LineIndex, unsigned TailOffset,
373 unsigned PreviousEndColumn,
374 unsigned ColumnLimit,
375 Split SplitBefore) const override;
376 void replaceWhitespaceBefore(unsigned LineIndex, unsigned PreviousEndColumn,
377 unsigned ColumnLimit, Split SplitBefore,
378 WhitespaceManager &Whitespaces) override;
379 void updateNextToken(LineState& State) const override;
Krasimir Georgiev00c5c722017-02-02 15:32:19 +0000380 bool mayReflow(unsigned LineIndex,
381 llvm::Regex &CommentPragmasRegex) const override;
Krasimir Georgiev91834222017-01-25 13:58:58 +0000382
383private:
384 unsigned getContentStartColumn(unsigned LineIndex,
385 unsigned TailOffset) const override;
386
Krasimir Georgiev2091a3a2017-02-08 14:45:19 +0000387 // OriginalPrefix[i] contains the original prefix of line i, including
388 // trailing whitespace before the start of the content. The indentation
389 // preceding the prefix is not included.
390 // For example, if the line is:
391 // // content
392 // then the original prefix is "// ".
393 SmallVector<StringRef, 16> OriginalPrefix;
394
Krasimir Georgiev91834222017-01-25 13:58:58 +0000395 // Prefix[i] contains the intended leading "//" with trailing spaces to
396 // account for the indentation of content within the comment at line i after
397 // formatting. It can be different than the original prefix when the original
398 // line starts like this:
399 // //content
400 // Then the original prefix is "//", but the prefix is "// ".
401 SmallVector<StringRef, 16> Prefix;
402
403 SmallVector<unsigned, 16> OriginalContentColumn;
404
405 /// \brief The token to which the last line of this breakable token belongs
406 /// to; nullptr if that token is the initial token.
407 ///
408 /// The distinction is because if the token of the last line of this breakable
409 /// token is distinct from the initial token, this breakable token owns the
410 /// whitespace before the token of the last line, and the whitespace manager
411 /// must be able to modify it.
412 FormatToken *LastLineTok = nullptr;
413};
Alexander Kornienkocb45bc12013-04-15 14:28:00 +0000414} // namespace format
415} // namespace clang
416
Benjamin Kramer2f5db8b2014-08-13 16:25:19 +0000417#endif