Lines Matching +full:in +full:- +full:line
1 //===--- BreakableToken.h - Format C++ code ---------------------*- C++ -*-===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
12 /// token type-specific logic to break long lines in tokens and reflow content
15 //===----------------------------------------------------------------------===//
27 /// Checks if \p Token switches formatting, like /* clang-format off */.
34 /// within the tokens - for example, to avoid whitespace beyond the column
37 /// Generally, a breakable token consists of logical lines, addressed by a line
38 /// index. For example, in a sequence of line comments, each line comment is its
39 /// own logical line; similarly, for a block comment, each line in the block
40 /// comment is on its own logical line.
43 /// - getRangeLength measures the number of columns needed for a range of text
44 /// within a logical line, and
45 /// - getContentStartColumn returns the start column at which we want the
46 /// content of a logical line to start (potentially after introducing a line
54 /// - getSplit, for finding a split starting at a position,
55 /// - insertBreak, for executing the split using a whitespace manager.
58 /// range with a single space if that will bring the line length under the
60 /// - getLineLengthAfterCompression, for calculating the size in columns of the
61 /// line after a whitespace range has been compressed, and
62 /// - compressWhitespace, for executing the whitespace compression using a
63 /// whitespace manager; note that the compressed whitespace may be in the
64 /// middle of the original line and of the reformatted line.
66 /// For tokens where the whitespace before each line needs to be also
68 /// operations that might be executed before the main line breaking occurs:
69 /// - getReflowSplit, for finding a split such that the content preceding it
71 /// - reflow, for executing the split using a whitespace manager,
72 /// - introducesBreakBefore, for checking if reformatting the beginning
73 /// of the content introduces a line break before it,
74 /// - adaptStartOfLine, for executing the reflow using a whitespace
77 /// For tokens that require the whitespace after the last line to be
78 /// reformatted, for example in multiline jsdoc comments that require the
79 /// trailing '*/' to be on a line of itself, there are analogous operations
80 /// that might be executed after the last line has been reformatted:
81 /// - getSplitAfterLastLine, for finding a split after the last line that needs
83 /// - replaceWhitespaceAfterLastLine, for executing the reflow using a
93 /// Returns the number of lines in this token in the original code.
96 /// Returns the number of columns required to format the text in the
99 /// \p Offset is the byte offset from the start of the content of the line
102 /// \p StartColumn is the column at which the text starts in the formatted
109 /// the byte \p Offset in the line \p LineIndex, including potentially
112 /// \p Offset is the byte offset from the start of the content of the line
115 /// \p StartColumn is the column at which the text starts in the formatted
118 /// For breakable tokens that never use extra space at the end of a line, this
125 /// Returns the column at which content in line \p LineIndex starts,
128 /// If \p Break is true, returns the column at which the line should start
129 /// after the line break.
130 /// If \p Break is false, returns the column at which the line itself will
135 /// Returns additional content indent required for the second line after the
136 /// content at line \p LineIndex is broken.
138 // (Next lines do not start with `///` since otherwise -Wdocumentation picks
141 // in this example getContentIndex(1) returns 4.
143 // * @param loooooooooooooong line
148 /// Returns a range (offset, length) at which to break the line at
150 /// violate \p ColumnLimit, assuming the text starting at \p TailOffset in
151 /// the token is formatted starting at ContentStartColumn in the reformatted
164 /// by \p RemainingTokenColumns, and that the whitespace in Split is reduced
179 /// LineIndex such that the content of that line is reflown to the end of the
184 /// The range will include any whitespace preceding the specified line's
188 /// line comments, returns (0, <length>).
194 /// Reflows the current line into the end of the previous one.
198 /// Returns whether there will be a line break at the start of the
202 /// Replaces the whitespace between \p LineIndex-1 and \p LineIndex.
207 /// the last line that needs to be reformatted after the last line has been
216 /// Replaces the whitespace from \p SplitAfterLastLine on the last line
217 /// after the last line has been formatted by performing a reformatting.
221 insertBreak(getLineCount() - 1, TailOffset, SplitAfterLastLine,
231 /// wrapping a JavaScript string in parentheses after it gets broken with plus
249 /// Creates a breakable token for a single line string literal.
251 /// \p StartColumn specifies the column in which the token will start
275 // The column in which the token starts.
277 // The prefix a line needs after a break in the token.
279 // The postfix a line needs before introducing a break.
282 StringRef Line;
284 // contain line breaks.
296 /// Creates a breakable token for a single line string literal for C#, Java,
299 /// \p StartColumn specifies the column in which the token will start
323 // apply to the first line.
331 /// \p StartColumn specifies the column in which the comment will start after
347 // Returns the token containing the line at LineIndex.
350 // Checks if the content of line LineIndex may be reflown with the previous
351 // line.
357 // In case of a block comments, excludes the leading /* in the first line and
358 // trailing */ in the last line. In case of line comments, excludes the
373 // Note that this excludes a leading "* " or "*" in case of block comments
374 // where all lines have a "*" prefix, or the leading "// " or "//" in case of
375 // line comments.
377 // In block comments, the first line's target column is always positive. The
378 // remaining lines' target columns are relative to the first line to allow
379 // correct indentation of comments in \c WhitespaceManager. Thus they can be
380 // negative as well (in case the first line needs to be unindented more than
381 // there's actual whitespace in another line).
384 // The intended start column of the first line of text from this section.
387 // The prefix to use in front a line that has been reflown up.
388 // For example, when reflowing the second line after the first here:
435 // Rearranges the whitespace between Lines[LineIndex-1] and Lines[LineIndex].
437 // Updates Content[LineIndex-1] and Content[LineIndex] by stripping off
440 // Sets ContentColumn to the intended column in which the text at
445 // The column at which the text of a broken line should start.
447 // IndentAtLineBreak is a uniform position for all lines in a block comment,
453 // We could also support such patterns by special casing the first line
457 // This is to distinguish between the case when the last line was empty and
469 // line of itself. Styles like jsdoc require this for multiline comments.
473 // contain line breaks.
501 // OriginalPrefix[i] contains the original prefix of line i, including
504 // For example, if the line is:
511 /// comment at line i after formatting. It can be different than the original
513 /// When the original line starts like this:
515 /// Then the OriginalPrefix[i] is "//", but the Prefix[i] is "// " in the LLVM
517 /// When the line starts like:
527 /// The token to which the last line of this breakable token belongs
530 /// The distinction is because if the token of the last line of this breakable
532 /// whitespace before the token of the last line, and the whitespace manager