Options for the Ceylon formatter.
The formatter requires an object satisfying FormattingOptions
.
There are several ways in which you can obtain such an object:
Manually create one, defining each attribute yourself:
FormattingVisitor(tokens, writer, FormattingOptions { indentMode = Spaces(4); // ... });
Read one from a file using formattingFile()
:
FormattingVisitor(tokens, writer, formattingFile(filename));
Use the default options:
FormattingVisitor(tokens, writer, FormattingOptions());
Combine existing FormattingOptions
with manually created SparseFormattingOptions
:
FormattingVisitor(tokens, writer, combinedOptions(defaultOptions, SparseFormattingOptions { indentMode = Mixed(Tabs(8), Spaces(4)); // ... }));
Values | |
all | Source Codeshared all all |
crlf | Source Codeshared crlf crlf |
lf | Source Codeshared lf lf |
os | Source Codeshared os os |
unlimited | Source Codeshared unlimited unlimited |
Functions | |
combinedOptions | Source Codeshared FormattingOptions combinedOptions(FormattingOptions baseOptions, SparseFormattingOptions* decoration) A combination of several Each attribute is first searched in each of the In the typical use case, FormattingVisitor(tokens, writer, combinedOptions(defaultOptions, SparseFormattingOptions { indentMode = Mixed(Tabs(8), Spaces(4)); // ... })); |
commandLineOptions | Source Codeshared [FormattingOptions, String[]] commandLineOptions(String[] arguments = ...) Parameters:
|
configProfileName | Source Codeshared String? configProfileName() Loads the profile name from the Ceylon configuration
(key See also loadProfile() |
formattingFile | Source Codeshared FormattingOptions formattingFile(String filename, FormattingOptions baseOptions = ...) Reads a file with formatting options. The file consists of lines of key=value pairs or comments, like this: # Boss Man says the One True Style is evil blockBraceOnNewLine=true # 80 characters is not enough maxLineWidth=120 indentMode=4 spaces As you can see, comment lines begin with a The keys are attributes of A special option in this regard is The file is processed in the following order:
Thus, options in the top-level file override options in included files. Parameters:
|
loadProfile | Source Codeshared FormattingOptions loadProfile(String profile = ..., Boolean inherit = true, String baseDir = ...) Loads formatting options from the given profile. A profile is a file with the name "``profile``.format" next to the regular Ceylon config file. It contains
formatting options in a [formatter] indentMode = 4 spaces braceOnOwnLine = false If Parameters:
|
parseIndentMode | Source Codeshared IndentMode? parseIndentMode(String string) The The format is like this: |
parseIntegerRange | Source Codeshared Range<Integer>? parseIntegerRange(String string) |
parseLineBreakStrategy | Source Codeshared LineBreakStrategy? parseLineBreakStrategy(String string) |
saveProfile | Source Codeshared void saveProfile(SparseFormattingOptions profile, String name = ..., String baseDir = ..., String relativePath = ...) Saves formatting options to the given profile. For more informations on profiles, see the
Parameters:
See also loadProfile() |
Classes | |
All | Source Codeshared abstract All |
FormattingOptions | Source Codeshared FormattingOptions A bundle of options for the formatter that control how the code should be formatted. The default arguments are modeled after the FormattingOptions { indentMode = Tabs(4); // modify some others // keep the rest } |
IndentMode | Source Codeshared abstract IndentMode A mode to indent code based on levels of indentation. |
LineBreak | Source Codeshared abstract LineBreak |
LineBreakStrategy | Source Codeshared abstract LineBreakStrategy A strategy to break a series of tokens into multiple lines to accomodate a maximum line length. |
Mixed | Source Codeshared Mixed Indent using tabs and spaces.
Mixed(Tabs(8), Spaces(4)) or, more verbosely, Mixed { Tabs { width = 8; }; Spaces { spacesPerLevel = 4; }; }; |
Spaces | Source Codeshared Spaces Indent using spaces. |
SparseFormattingOptions | Source Codeshared SparseFormattingOptions A superclass of The intended use is that users take a “default” |
Tabs | Source Codeshared Tabs Indent using tabs. |
Unlimited | Source Codeshared abstract Unlimited |
VariableOptions | Source Codeshared VariableOptions A subclass of |
all | Source Codeshared all |
crlf | Source Codeshared crlf |
lf | Source Codeshared lf |
os | Source Codeshared os |
unlimited | Source Codeshared unlimited |
Exceptions | |
ParseOptionException | Source Codeshared ParseOptionException |
UnknownOptionException | Source Codeshared UnknownOptionException |