blob: f4dd01b64c39cb98a6518187635f2dcb2e1733bc [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,
Krasimir Georgiev17725d82017-03-08 08:55:12 +000093 unsigned ColumnLimit,
94 llvm::Regex &CommentPragmasRegex) const = 0;
Manuel Klimek9043c742013-05-27 15:23:34 +000095
96 /// \brief Emits the previously retrieved \p Split via \p Whitespaces.
Alexander Kornienkocb45bc12013-04-15 14:28:00 +000097 virtual void insertBreak(unsigned LineIndex, unsigned TailOffset, Split Split,
Alexander Kornienkocb45bc12013-04-15 14:28:00 +000098 WhitespaceManager &Whitespaces) = 0;
Manuel Klimek9043c742013-05-27 15:23:34 +000099
Krasimir Georgiev91834222017-01-25 13:58:58 +0000100 /// \brief Returns the number of columns required to format the piece of line
101 /// at \p LineIndex, from byte offset \p TailOffset after the whitespace range
102 /// \p Split has been compressed into a single space.
103 unsigned getLineLengthAfterCompression(unsigned RemainingTokenColumns,
104 Split Split) const;
105
Alexander Kornienko875395f2013-11-12 17:50:13 +0000106 /// \brief Replaces the whitespace range described by \p Split with a single
107 /// space.
Krasimir Georgiev91834222017-01-25 13:58:58 +0000108 virtual void compressWhitespace(unsigned LineIndex, unsigned TailOffset,
109 Split Split,
110 WhitespaceManager &Whitespaces) = 0;
111
112 /// \brief Returns a whitespace range (offset, length) of the content at
113 /// \p LineIndex such that the content preceding this range needs to be
114 /// reformatted before any breaks are made to this line.
115 ///
116 /// \p PreviousEndColumn is the end column of the previous line after
117 /// formatting.
118 ///
119 /// A result having offset == StringRef::npos means that no piece of the line
120 /// needs to be reformatted before any breaks are made.
121 virtual Split getSplitBefore(unsigned LineIndex,
122 unsigned PreviousEndColumn,
Krasimir Georgiev00c5c722017-02-02 15:32:19 +0000123 unsigned ColumnLimit,
124 llvm::Regex& CommentPragmasRegex) const {
Krasimir Georgiev91834222017-01-25 13:58:58 +0000125 return Split(StringRef::npos, 0);
126 }
127
128 /// \brief Returns the number of columns required to format the piece of line
129 /// at \p LineIndex after the content preceding the whitespace range specified
130 /// \p SplitBefore has been reformatted, but before any breaks are made to
131 /// this line.
132 virtual unsigned getLineLengthAfterSplitBefore(unsigned LineIndex,
133 unsigned TailOffset,
134 unsigned PreviousEndColumn,
135 unsigned ColumnLimit,
136 Split SplitBefore) const {
137 return getLineLengthAfterSplit(LineIndex, TailOffset, StringRef::npos);
138 }
Alexander Kornienko875395f2013-11-12 17:50:13 +0000139
Manuel Klimek9043c742013-05-27 15:23:34 +0000140 /// \brief Replaces the whitespace between \p LineIndex-1 and \p LineIndex.
Krasimir Georgiev91834222017-01-25 13:58:58 +0000141 /// Performs a reformatting of the content at \p LineIndex preceding the
142 /// whitespace range \p SplitBefore.
Manuel Klimek9043c742013-05-27 15:23:34 +0000143 virtual void replaceWhitespaceBefore(unsigned LineIndex,
Krasimir Georgiev91834222017-01-25 13:58:58 +0000144 unsigned PreviousEndColumn,
145 unsigned ColumnLimit,
146 Split SplitBefore,
Manuel Klimek9043c742013-05-27 15:23:34 +0000147 WhitespaceManager &Whitespaces) {}
148
Krasimir Georgiev91834222017-01-25 13:58:58 +0000149 /// \brief Updates the next token of \p State to the next token after this
150 /// one. This can be used when this token manages a set of underlying tokens
151 /// as a unit and is responsible for the formatting of the them.
152 virtual void updateNextToken(LineState &State) const {}
153
Alexander Kornienko9e90b622013-04-17 17:34:05 +0000154protected:
Daniel Jasper7d42f3f2017-01-31 11:25:01 +0000155 BreakableToken(const FormatToken &Tok, bool InPPDirective,
156 encoding::Encoding Encoding, const FormatStyle &Style)
157 : Tok(Tok), InPPDirective(InPPDirective), Encoding(Encoding),
158 Style(Style) {}
Manuel Klimek9043c742013-05-27 15:23:34 +0000159
Alexander Kornienko9e90b622013-04-17 17:34:05 +0000160 const FormatToken &Tok;
Alexander Kornienkobe633902013-06-14 11:46:10 +0000161 const bool InPPDirective;
162 const encoding::Encoding Encoding;
Alexander Kornienkoebb43ca2013-09-05 14:08:34 +0000163 const FormatStyle &Style;
Alexander Kornienkocb45bc12013-04-15 14:28:00 +0000164};
165
Manuel Klimek9043c742013-05-27 15:23:34 +0000166/// \brief Base class for single line tokens that can be broken.
167///
168/// \c getSplit() needs to be implemented by child classes.
169class BreakableSingleLineToken : public BreakableToken {
Alexander Kornienkocb45bc12013-04-15 14:28:00 +0000170public:
Craig Topperfb6b25b2014-03-15 04:29:04 +0000171 unsigned getLineCount() const override;
172 unsigned getLineLengthAfterSplit(unsigned LineIndex, unsigned TailOffset,
173 StringRef::size_type Length) const override;
Alexander Kornienko9e90b622013-04-17 17:34:05 +0000174
175protected:
Daniel Jasper7d42f3f2017-01-31 11:25:01 +0000176 BreakableSingleLineToken(const FormatToken &Tok, unsigned StartColumn,
177 StringRef Prefix, StringRef Postfix,
178 bool InPPDirective, encoding::Encoding Encoding,
Alexander Kornienkoebb43ca2013-09-05 14:08:34 +0000179 const FormatStyle &Style);
Alexander Kornienko9e90b622013-04-17 17:34:05 +0000180
Manuel Klimek9043c742013-05-27 15:23:34 +0000181 // The column in which the token starts.
182 unsigned StartColumn;
183 // The prefix a line needs after a break in the token.
184 StringRef Prefix;
185 // The postfix a line needs before introducing a break.
186 StringRef Postfix;
187 // The token text excluding the prefix and postfix.
188 StringRef Line;
Alexander Kornienko9e90b622013-04-17 17:34:05 +0000189};
190
Manuel Klimek9043c742013-05-27 15:23:34 +0000191class BreakableStringLiteral : public BreakableSingleLineToken {
Alexander Kornienkocb45bc12013-04-15 14:28:00 +0000192public:
Manuel Klimek9043c742013-05-27 15:23:34 +0000193 /// \brief Creates a breakable token for a single line string literal.
194 ///
195 /// \p StartColumn specifies the column in which the token will start
196 /// after formatting.
Daniel Jasper7d42f3f2017-01-31 11:25:01 +0000197 BreakableStringLiteral(const FormatToken &Tok, unsigned StartColumn,
198 StringRef Prefix, StringRef Postfix,
199 bool InPPDirective, encoding::Encoding Encoding,
200 const FormatStyle &Style);
Alexander Kornienkocb45bc12013-04-15 14:28:00 +0000201
Krasimir Georgiev17725d82017-03-08 08:55:12 +0000202 Split getSplit(unsigned LineIndex, unsigned TailOffset, unsigned ColumnLimit,
203 llvm::Regex &CommentPragmasRegex) const override;
Craig Topperfb6b25b2014-03-15 04:29:04 +0000204 void insertBreak(unsigned LineIndex, unsigned TailOffset, Split Split,
205 WhitespaceManager &Whitespaces) override;
Krasimir Georgiev91834222017-01-25 13:58:58 +0000206 void compressWhitespace(unsigned LineIndex, unsigned TailOffset, Split Split,
207 WhitespaceManager &Whitespaces) override {}
Manuel Klimek9043c742013-05-27 15:23:34 +0000208};
Alexander Kornienkocb45bc12013-04-15 14:28:00 +0000209
Krasimir Georgiev91834222017-01-25 13:58:58 +0000210class BreakableComment : public BreakableToken {
211protected:
212 /// \brief Creates a breakable token for a comment.
Manuel Klimek9043c742013-05-27 15:23:34 +0000213 ///
Krasimir Georgiev4b159222017-02-21 10:54:50 +0000214 /// \p StartColumn specifies the column in which the comment will start after
215 /// formatting.
Daniel Jasper7d42f3f2017-01-31 11:25:01 +0000216 BreakableComment(const FormatToken &Token, unsigned StartColumn,
Daniel Jasper7d42f3f2017-01-31 11:25:01 +0000217 bool InPPDirective, encoding::Encoding Encoding,
218 const FormatStyle &Style);
Krasimir Georgiev91834222017-01-25 13:58:58 +0000219
220public:
221 unsigned getLineCount() const override;
Krasimir Georgiev17725d82017-03-08 08:55:12 +0000222 Split getSplit(unsigned LineIndex, unsigned TailOffset, unsigned ColumnLimit,
223 llvm::Regex &CommentPragmasRegex) const override;
Krasimir Georgiev91834222017-01-25 13:58:58 +0000224 void compressWhitespace(unsigned LineIndex, unsigned TailOffset, Split Split,
225 WhitespaceManager &Whitespaces) override;
226
227protected:
228 virtual unsigned getContentStartColumn(unsigned LineIndex,
229 unsigned TailOffset) const = 0;
230
231 // Returns a split that divides Text into a left and right parts, such that
232 // the left part is suitable for reflowing after PreviousEndColumn.
233 Split getReflowSplit(StringRef Text, StringRef ReflowPrefix,
234 unsigned PreviousEndColumn, unsigned ColumnLimit) const;
235
236 // Returns the token containing the line at LineIndex.
237 const FormatToken &tokenAt(unsigned LineIndex) const;
238
239 // Checks if the content of line LineIndex may be reflown with the previous
240 // line.
Krasimir Georgiev00c5c722017-02-02 15:32:19 +0000241 virtual bool mayReflow(unsigned LineIndex,
242 llvm::Regex &CommentPragmasRegex) const = 0;
Krasimir Georgiev91834222017-01-25 13:58:58 +0000243
244 // Contains the original text of the lines of the block comment.
245 //
246 // In case of a block comments, excludes the leading /* in the first line and
247 // trailing */ in the last line. In case of line comments, excludes the
248 // leading // and spaces.
249 SmallVector<StringRef, 16> Lines;
250
251 // Contains the text of the lines excluding all leading and trailing
252 // whitespace between the lines. Note that the decoration (if present) is also
253 // not considered part of the text.
254 SmallVector<StringRef, 16> Content;
255
256 // Tokens[i] contains a reference to the token containing Lines[i] if the
257 // whitespace range before that token is managed by this block.
258 // Otherwise, Tokens[i] is a null pointer.
259 SmallVector<FormatToken *, 16> Tokens;
260
261 // ContentColumn[i] is the target column at which Content[i] should be.
262 // Note that this excludes a leading "* " or "*" in case of block comments
263 // where all lines have a "*" prefix, or the leading "// " or "//" in case of
264 // line comments.
265 //
266 // In block comments, the first line's target column is always positive. The
267 // remaining lines' target columns are relative to the first line to allow
268 // correct indentation of comments in \c WhitespaceManager. Thus they can be
269 // negative as well (in case the first line needs to be unindented more than
270 // there's actual whitespace in another line).
271 SmallVector<int, 16> ContentColumn;
272
273 // The intended start column of the first line of text from this section.
274 unsigned StartColumn;
275
Krasimir Georgiev91834222017-01-25 13:58:58 +0000276 // The prefix to use in front a line that has been reflown up.
277 // For example, when reflowing the second line after the first here:
278 // // comment 1
279 // // comment 2
280 // we expect:
281 // // comment 1 comment 2
282 // and not:
283 // // comment 1comment 2
284 StringRef ReflowPrefix = " ";
285};
286
287class BreakableBlockComment : public BreakableComment {
288public:
Daniel Jasper7d42f3f2017-01-31 11:25:01 +0000289 BreakableBlockComment(const FormatToken &Token, unsigned StartColumn,
290 unsigned OriginalStartColumn, bool FirstInLine,
291 bool InPPDirective, encoding::Encoding Encoding,
292 const FormatStyle &Style);
Manuel Klimek9043c742013-05-27 15:23:34 +0000293
Krasimir Georgiev91834222017-01-25 13:58:58 +0000294 unsigned getLineLengthAfterSplit(unsigned LineIndex,
295 unsigned TailOffset,
Craig Topperfb6b25b2014-03-15 04:29:04 +0000296 StringRef::size_type Length) const override;
Craig Topperfb6b25b2014-03-15 04:29:04 +0000297 void insertBreak(unsigned LineIndex, unsigned TailOffset, Split Split,
298 WhitespaceManager &Whitespaces) override;
Krasimir Georgiev91834222017-01-25 13:58:58 +0000299 Split getSplitBefore(unsigned LineIndex, unsigned PreviousEndColumn,
Krasimir Georgiev00c5c722017-02-02 15:32:19 +0000300 unsigned ColumnLimit,
301 llvm::Regex &CommentPragmasRegex) const override;
Krasimir Georgiev91834222017-01-25 13:58:58 +0000302 unsigned getLineLengthAfterSplitBefore(unsigned LineIndex,
303 unsigned TailOffset,
304 unsigned PreviousEndColumn,
305 unsigned ColumnLimit,
306 Split SplitBefore) const override;
307 void replaceWhitespaceBefore(unsigned LineIndex, unsigned PreviousEndColumn,
308 unsigned ColumnLimit,
309 Split SplitBefore,
Craig Topperfb6b25b2014-03-15 04:29:04 +0000310 WhitespaceManager &Whitespaces) override;
Krasimir Georgiev00c5c722017-02-02 15:32:19 +0000311 bool mayReflow(unsigned LineIndex,
312 llvm::Regex &CommentPragmasRegex) const override;
Alexander Kornienkocb45bc12013-04-15 14:28:00 +0000313
314private:
Krasimir Georgiev91834222017-01-25 13:58:58 +0000315 // Rearranges the whitespace between Lines[LineIndex-1] and Lines[LineIndex].
Manuel Klimek9043c742013-05-27 15:23:34 +0000316 //
Krasimir Georgiev91834222017-01-25 13:58:58 +0000317 // Updates Content[LineIndex-1] and Content[LineIndex] by stripping off
318 // leading and trailing whitespace.
319 //
320 // Sets ContentColumn to the intended column in which the text at
Manuel Klimek9043c742013-05-27 15:23:34 +0000321 // Lines[LineIndex] starts (note that the decoration, if present, is not
322 // considered part of the text).
Alexander Kornienkoebb43ca2013-09-05 14:08:34 +0000323 void adjustWhitespace(unsigned LineIndex, int IndentDelta);
Alexander Kornienko9e90b622013-04-17 17:34:05 +0000324
Krasimir Georgiev91834222017-01-25 13:58:58 +0000325 // Computes the end column if the full Content from LineIndex gets reflown
326 // after PreviousEndColumn.
327 unsigned getReflownColumn(StringRef Content,
328 unsigned LineIndex,
329 unsigned PreviousEndColumn) const;
Alexander Kornienko9e90b622013-04-17 17:34:05 +0000330
Krasimir Georgiev91834222017-01-25 13:58:58 +0000331 unsigned getContentStartColumn(unsigned LineIndex,
332 unsigned TailOffset) const override;
Manuel Klimek9043c742013-05-27 15:23:34 +0000333
334 // The column at which the text of a broken line should start.
335 // Note that an optional decoration would go before that column.
336 // IndentAtLineBreak is a uniform position for all lines in a block comment,
337 // regardless of their relative position.
338 // FIXME: Revisit the decision to do this; the main reason was to support
339 // patterns like
340 // /**************//**
341 // * Comment
342 // We could also support such patterns by special casing the first line
343 // instead.
344 unsigned IndentAtLineBreak;
345
Alexander Kornienko614d96a2013-07-08 14:12:07 +0000346 // This is to distinguish between the case when the last line was empty and
347 // the case when it started with a decoration ("*" or "* ").
348 bool LastLineNeedsDecoration;
349
Manuel Klimek9043c742013-05-27 15:23:34 +0000350 // Either "* " if all lines begin with a "*", or empty.
351 StringRef Decoration;
Krasimir Georgievbb99a362017-02-16 12:39:31 +0000352
353 // If this block comment has decorations, this is the column of the start of
354 // the decorations.
355 unsigned DecorationColumn;
Alexander Kornienkocb45bc12013-04-15 14:28:00 +0000356};
357
Krasimir Georgiev91834222017-01-25 13:58:58 +0000358class BreakableLineCommentSection : public BreakableComment {
359public:
Daniel Jasper7d42f3f2017-01-31 11:25:01 +0000360 BreakableLineCommentSection(const FormatToken &Token, unsigned StartColumn,
Krasimir Georgiev91834222017-01-25 13:58:58 +0000361 unsigned OriginalStartColumn, bool FirstInLine,
362 bool InPPDirective, encoding::Encoding Encoding,
363 const FormatStyle &Style);
364
365 unsigned getLineLengthAfterSplit(unsigned LineIndex,
366 unsigned TailOffset,
367 StringRef::size_type Length) const override;
368 void insertBreak(unsigned LineIndex, unsigned TailOffset, Split Split,
369 WhitespaceManager &Whitespaces) override;
370 Split getSplitBefore(unsigned LineIndex, unsigned PreviousEndColumn,
Krasimir Georgiev00c5c722017-02-02 15:32:19 +0000371 unsigned ColumnLimit,
372 llvm::Regex &CommentPragmasRegex) const override;
Krasimir Georgiev91834222017-01-25 13:58:58 +0000373 unsigned getLineLengthAfterSplitBefore(unsigned LineIndex, unsigned TailOffset,
374 unsigned PreviousEndColumn,
375 unsigned ColumnLimit,
376 Split SplitBefore) const override;
377 void replaceWhitespaceBefore(unsigned LineIndex, unsigned PreviousEndColumn,
378 unsigned ColumnLimit, Split SplitBefore,
379 WhitespaceManager &Whitespaces) override;
380 void updateNextToken(LineState& State) const override;
Krasimir Georgiev00c5c722017-02-02 15:32:19 +0000381 bool mayReflow(unsigned LineIndex,
382 llvm::Regex &CommentPragmasRegex) const override;
Krasimir Georgiev91834222017-01-25 13:58:58 +0000383
384private:
385 unsigned getContentStartColumn(unsigned LineIndex,
386 unsigned TailOffset) const override;
387
Krasimir Georgiev2091a3a2017-02-08 14:45:19 +0000388 // OriginalPrefix[i] contains the original prefix of line i, including
389 // trailing whitespace before the start of the content. The indentation
390 // preceding the prefix is not included.
391 // For example, if the line is:
392 // // content
393 // then the original prefix is "// ".
394 SmallVector<StringRef, 16> OriginalPrefix;
395
Krasimir Georgiev91834222017-01-25 13:58:58 +0000396 // Prefix[i] contains the intended leading "//" with trailing spaces to
397 // account for the indentation of content within the comment at line i after
398 // formatting. It can be different than the original prefix when the original
399 // line starts like this:
400 // //content
401 // Then the original prefix is "//", but the prefix is "// ".
402 SmallVector<StringRef, 16> Prefix;
403
404 SmallVector<unsigned, 16> OriginalContentColumn;
405
406 /// \brief The token to which the last line of this breakable token belongs
407 /// to; nullptr if that token is the initial token.
408 ///
409 /// The distinction is because if the token of the last line of this breakable
410 /// token is distinct from the initial token, this breakable token owns the
411 /// whitespace before the token of the last line, and the whitespace manager
412 /// must be able to modify it.
413 FormatToken *LastLineTok = nullptr;
414};
Alexander Kornienkocb45bc12013-04-15 14:28:00 +0000415} // namespace format
416} // namespace clang
417
Benjamin Kramer2f5db8b2014-08-13 16:25:19 +0000418#endif