Initializer
OpeningToken(String text, Boolean allowLineBreakBefore, Boolean allowLineBreakAfter, Integer indentBefore, Integer indentAfter, StackCondition stackIndentBefore, StackCondition stackIndentAfter, Integer wantsSpaceBefore, Integer wantsSpaceAfter, Integer sourceColumn, Integer() targetColumn)
Parameters:
  • sourceColumn

    The column to which subsequent lines of a multi-line token are aligned in the source.

    Consider the string literal in the following example:

    print(
      "Hello,
         World!");
    

    Here, the source column is 3, because the content of the string starts at column three, and the second line is aligned to that column. Formatted, the code looks like this:

    print(
        "Hello,
           World!");
    

    The FormattingWriter.Token.targetColumn of the string literal is 5 (because of the corrected indentation), therefore the second line should be aligned to that column. When the second line is then written, 3 spaces are first trimmed from it, arriving at ␣␣World!", which is the real content. Then, 5 spaces are added, so that ␣␣␣␣␣␣␣World! is actually written.

    Usually, this is charPositionInLine plus some constant value depending on the token type, like 1 for string literals and 3 for verbatim string literals. However, for string templates, things get more complicated: Later parts of the template are still aligned to the first part.

  • targetColumn

    The column to which subsequent lines of a multi-line token should be aligned in the target. For an explanation of source- and targetColumn, see the FormattingWriter.Token.sourceColumn documentation.

    (This needs to be lazily evaluated because it depends on currentWidth].

Attributes
allowLineBreakAftershared actual Boolean allowLineBreakAfter
allowLineBreakBeforeshared actual Boolean allowLineBreakBefore
contextshared actual context context

The context of this token. Because the indentation (indentBefore, indentAfter) stacks depending on conditions (stackIndentBefore, stackIndentAfter), the context’s context.indent isn’t known in advance; rather, the context must be initialized to specify if it’s the first and/or last token of its line, from which the context.indent can then be determined..

indentAftershared actual Integer indentAfter
indentBeforeshared actual Integer indentBefore
sourceColumnshared actual Integer sourceColumn

The column to which subsequent lines of a multi-line token are aligned in the source.

Consider the string literal in the following example:

print(
  "Hello,
     World!");

Here, the source column is 3, because the content of the string starts at column three, and the second line is aligned to that column. Formatted, the code looks like this:

print(
    "Hello,
       World!");

The FormattingWriter.Token.targetColumn of the string literal is 5 (because of the corrected indentation), therefore the second line should be aligned to that column. When the second line is then written, 3 spaces are first trimmed from it, arriving at ␣␣World!", which is the real content. Then, 5 spaces are added, so that ␣␣␣␣␣␣␣World! is actually written.

Usually, this is charPositionInLine plus some constant value depending on the token type, like 1 for string literals and 3 for verbatim string literals. However, for string templates, things get more complicated: Later parts of the template are still aligned to the first part.

stackIndentAftershared actual StackCondition stackIndentAfter
stackIndentBeforeshared actual StackCondition stackIndentBefore
targetColumnshared actual Integer() targetColumn

The column to which subsequent lines of a multi-line token should be aligned in the target. For an explanation of source- and targetColumn, see the FormattingWriter.Token.sourceColumn documentation.

(This needs to be lazily evaluated because it depends on currentWidth].

textshared actual String text
Refines Token.text
wantsSpaceAftershared actual Integer wantsSpaceAfter
wantsSpaceBeforeshared actual Integer wantsSpaceBefore
Inherited Attributes
Attributes inherited from: Object
hash, string
Attributes inherited from: FormattingWriter.Token
Attributes inherited from: FormattingWriter.Element
Inherited Methods
Methods inherited from: Object
equals
Nested Classes
contextshared actual context

The context of this token. Because the indentation (indentBefore, indentAfter) stacks depending on conditions (stackIndentBefore, stackIndentAfter), the context’s context.indent isn’t known in advance; rather, the context must be initialized to specify if it’s the first and/or last token of its line, from which the context.indent can then be determined..