A bundle of options for the formatter that control how the code should be formatted.
The default arguments are modeled after the ceylon.language
module and the Ceylon SDK.
You can refine them using named arguments:
FormattingOptions { indentMode = Tabs(4); // modify some others // keep the rest }
Anything
FormattingOptions
SparseFormattingOptions
Basic
Identifiable
Object
Anything
no subtypes hierarchy
Initializer |
FormattingOptions(IndentMode indentMode = ..., Integer|Unlimited maxLineLength = ..., LineBreakStrategy lineBreakStrategy = ..., Boolean braceOnOwnLine = false, Boolean spaceBeforeParamListOpeningParen = false, Boolean spaceAfterParamListOpeningParen = false, Boolean spaceBeforeParamListClosingParen = false, Boolean spaceAfterParamListClosingParen = true, All|{String*} inlineAnnotations = ..., Boolean spaceBeforeMethodOrClassPositionalArgumentList = false, Boolean spaceBeforeAnnotationPositionalArgumentList = true, Range<Integer> lineBreaksBetweenImportElements = ..., Boolean spaceAroundImportAliasEqualsSign = false, Range<Integer> lineBreaksBeforeLineComment = ..., Range<Integer> lineBreaksAfterLineComment = ..., Range<Integer> lineBreaksBeforeSingleComment = ..., Range<Integer> lineBreaksAfterSingleComment = ..., Range<Integer> lineBreaksBeforeMultiComment = ..., Range<Integer> lineBreaksAfterMultiComment = ..., Range<Integer> lineBreaksInTypeParameterList = ..., Boolean spaceAfterSequenceEnumerationOpeningBrace = true, Boolean spaceBeforeSequenceEnumerationClosingBrace = true, Boolean spaceAfterValueIteratorOpeningParenthesis = false, Boolean spaceBeforeValueIteratorClosingParenthesis = false, Boolean failFast = true, Boolean spaceAfterTypeArgListComma = false, Boolean spaceAfterTypeParamListComma = true, Boolean spaceAroundTypeParamListEqualsSign = false, Integer indentBeforeTypeInfo = ..., Boolean indentBlankLines = true, LineBreak lineBreak = ..., Boolean elseOnOwnLine = false, Boolean spaceAroundSatisfiesOf = true, Boolean spaceAfterControlStructureKeyword = true, Integer spaceOptionalAroundOperatorLevel = ..., Boolean indentComprehensionClauses = true) Parameters:
|
Attributes | |
braceOnOwnLine | Source Codeshared actual Boolean braceOnOwnLine Decide whether to keep an opening brace ('{') on the same line (One True Style) or put them on the next line (Allman Style). |
elseOnOwnLine | Source Codeshared actual Boolean elseOnOwnLine Decide whether if (something) { // ... } else { // ... } vs. if (something) { // ... } else { // ... } |
failFast | Source Codeshared actual Boolean failFast Decide whether, in the case of an error, the formatter should attempt to recover and continue or immediately exit. This is mostly for internal use; in the finished formatter, there shouldn’t be any errors when formatting syntactically valid code. Refines SparseFormattingOptions.failFast |
indentBeforeTypeInfo | Source Codeshared actual Integer indentBeforeTypeInfo By how many levels For example: // 2 class Foo() extends Bar() satisfies Baz {} // vs // 1 class Foo() extends Bar() satisfies Baz {} |
indentBlankLines | Source Codeshared actual Boolean indentBlankLines Decide whether blank lines should be indented or not. |
indentComprehensionClauses | Source Codeshared actual Boolean indentComprehensionClauses Decide whether comprehension clauses should be indented by one level or not. For example: Integer.sum { for (employee in employees) if (employee.level < manager) employee.salary } vs. Integer.sum { for (employee in employees) if (employee.level < manager) employee.salary } |
indentMode | Source Codeshared actual IndentMode indentMode The indentation mode. |
inlineAnnotations | Source Codeshared actual All|{String*} inlineAnnotations Decide which annotations should be on the same line as their declaration.
If you give an by ("John Doe") throws (`class Anything`) shared formal void foo(); where If the value of this option is It should be noted that the annotations can look weird if you put “inline” annotations before or between “own-line” annotations: shared by ("John Doe") formal throws (`class Anything`) void foo(); Don’t do that. (You can already see in this small example how the combination “shared by” can be potentially confusing.) |
lineBreak | Source Codeshared actual LineBreak lineBreak The character(s) used to break lines, or |
lineBreakStrategy | Source Codeshared actual LineBreakStrategy lineBreakStrategy The strategy to determine where lines should be broken to accomodate |
lineBreaksAfterLineComment | Source Codeshared actual Range<Integer> lineBreaksAfterLineComment The range of line breaks allowed after a line comment ( Note that the minimum value of the range must be |
lineBreaksAfterMultiComment | Source Codeshared actual Range<Integer> lineBreaksAfterMultiComment The range of line breaks allowed after a multi-line comment ( |
lineBreaksAfterSingleComment | Source Codeshared actual Range<Integer> lineBreaksAfterSingleComment The range of line breaks allowed after a single-line multi comment ( |
lineBreaksBeforeLineComment | Source Codeshared actual Range<Integer> lineBreaksBeforeLineComment The range of line breaks allowed before a line comment ( |
lineBreaksBeforeMultiComment | Source Codeshared actual Range<Integer> lineBreaksBeforeMultiComment The range of line breaks allowed before a multi-line comment ( |
lineBreaksBeforeSingleComment | Source Codeshared actual Range<Integer> lineBreaksBeforeSingleComment The range of line breaks allowed before a single-line multi comment ( |
lineBreaksBetweenImportElements | Source Codeshared actual Range<Integer> lineBreaksBetweenImportElements The range of line breaks allowed between import elements.
import java.lang { Thread, JString=String, Runtime { runtime } }
import java.lang { Thread, JString=String, Runtime { runtime } }
import java.lang { Thread, JString=String, Runtime { runtime } } (Of course, wider ranges like |
lineBreaksInTypeParameterList | Source Codeshared actual Range<Integer> lineBreaksInTypeParameterList The range of line breaks allowed in a type parameter list. |
maxLineLength | Source Codeshared actual Integer|Unlimited maxLineLength The maximum line length, or |
spaceAfterControlStructureKeyword | Source Codeshared actual Boolean spaceAfterControlStructureKeyword Decide whether there should be a space between a control structure keyword and its opening parenthesis. This applies to the following keywords:
|
spaceAfterParamListClosingParen | Source Codeshared actual Boolean spaceAfterParamListClosingParen Decide whether to put a space after the closing parenthesis (')') of a method definition’s parameter list or not. This only applies when the parameter list is followed by a brace (as is the case for simple functions and classes). If it is instead followed by a fat arrow, a space is always added; if it’s followed by a semicolon (formal), or a comma or closing paren (parameter list of functional parameter), no space is be added. For example: |
spaceAfterParamListOpeningParen | Source Codeshared actual Boolean spaceAfterParamListOpeningParen Decide whether to put a space after the opening parenthesis ('(') of a method definition’s parameter list or not. For example: |
spaceAfterSequenceEnumerationOpeningBrace | Source Codeshared actual Boolean spaceAfterSequenceEnumerationOpeningBrace Decide whether there should be a space after the opening brace of a sequence enumeration. For example: |
spaceAfterTypeArgListComma | Source Codeshared actual Boolean spaceAfterTypeArgListComma Decide whether there should be a space after commas in a type argument list. For example: |
spaceAfterTypeParamListComma | Source Codeshared actual Boolean spaceAfterTypeParamListComma Decide whether there should be a space after commas in a type parameter list. For example: |
spaceAfterValueIteratorOpeningParenthesis | Source Codeshared actual Boolean spaceAfterValueIteratorOpeningParenthesis Decide whether there should be a space after the opening parenthesis of a value iterator. For example: |
spaceAroundImportAliasEqualsSign | Source Codeshared actual Boolean spaceAroundImportAliasEqualsSign Decide if there should be spaces around the equals sign ('=') of an import alias, that is import java.lang { JString=String } // vs import java.lang { JString = String } |
spaceAroundSatisfiesOf | Source Codeshared actual Boolean spaceAroundSatisfiesOf Decide whether there should be spaces around satisfied interfaces and case types. For example: class MyClass() satisfies MyInterface&MyOtherInterface of CaseType1|CaseType2 { ... } vs. class MyClass() satisfies MyInterface & MyOtherInterface of CaseType1 | CaseType2 { ... } |
spaceAroundTypeParamListEqualsSign | Source Codeshared actual Boolean spaceAroundTypeParamListEqualsSign Decide whether there should be a space around equals signs in a type parameter list. For example: |
spaceBeforeAnnotationPositionalArgumentList | Source Codeshared actual Boolean spaceBeforeAnnotationPositionalArgumentList Decide if there should be a space in front of a positional argument list for an annotation. A positional argument list is the complement of a named argument list, i. e. what you’d probably know as simply an argument list: process.arguments.filter("--help --usage --version".split().contains); // '----------positional argument list---------' |
spaceBeforeMethodOrClassPositionalArgumentList | Source Codeshared actual Boolean spaceBeforeMethodOrClassPositionalArgumentList Decide if there should be a space in front of a positional argument list for a method or class. A positional argument list is the complement of a named argument list, i. e. what you’d probably know as simply an argument list: process.arguments.filter("--help --usage --version".split().contains); // '----------positional argument list---------' |
spaceBeforeParamListClosingParen | Source Codeshared actual Boolean spaceBeforeParamListClosingParen Decide whether to put a space before the closing parenthesis (')') of a method definition’s parameter list or not. For example: |
spaceBeforeParamListOpeningParen | Source Codeshared actual Boolean spaceBeforeParamListOpeningParen Decide whether to put a space before the opening parenthesis ('(') of a method definition’s parameter list or not. For example: |
spaceBeforeSequenceEnumerationClosingBrace | Source Codeshared actual Boolean spaceBeforeSequenceEnumerationClosingBrace Decide whether there should be a space before the closing brace of a sequence enumeration. For example: |
spaceBeforeValueIteratorClosingParenthesis | Source Codeshared actual Boolean spaceBeforeValueIteratorClosingParenthesis Decide whether there should be a space before the closing parenthesis of a value iterator. For example: |
spaceOptionalAroundOperatorLevel | Source Codeshared actual Integer spaceOptionalAroundOperatorLevel The maximum operator layer for which spaces are optional. If the spaces around an operator are optional, then the formatter omits them when the operator is nested within other operators, for instance: value hollowCubeVolume = w*h*d - iW*iH*iD; // (inner) width/height/depth The operator layers are listed in the Ceylon Language Specification, table 6.1; a brief summary is:
Spaces are optional around all operators of level up to the value of this option.
The default value is value sum = 1 + 2 + 3; value hollowCubeVolume = w*h*d - iW*iH*iD; // (inner) width/height/depth value allEqual = a==b && b==c && c==d; value regular = start..end; value shifted = start+offset .. end+offset; If you don’t like the look of |
Inherited Methods |
Methods inherited from: Object equals |