• Modules
    • By category
    • By name
    • Most popular
    • Most downloaded
    • Repository
  • Register
  • Log in
  • Help
    • Start using Ceylon Herd
    • Publish your first module
    • Module publishing guidelines
    • All about Ceylon
    • Keyboard Shortcuts

    • s Focus search module bar
      ? Open this information panel
      j Move selection down
      k Move selection up
      enter Open current selection
Module info
Name
lucaswerkmeister / ceylon.formatter
Ceylon Source Code Formatter
Description

A formatter for the Ceylon programming language.

Command line usage

Note: if the ceylon format plugin wasn’t installed by default in your distribution, you can add it by running:

ceylon plugin install ceylon.formatter/1.3.3

To format all Ceylon code in the source and test-source directories:

ceylon format source test-source

To format all Ceylon code in the source directory into the source-formatted directory:

ceylon format source --to source-formatted

To format all Ceylon code in the source and test-source directories into the source-formatted directory:

ceylon format source --and test-source --to source-formatted

(This results in two subdirectories source and test-source of source-formatted.)

You can specify an arbitrary amount of these formatting commands:

ceylon format \
        source --to source-formatted \
        test-source --to test-source-formatted

(The line breaks are only included for clarity and not a part of the command line syntax.)

If no formatting commands are present, the formatter operates in “pipe mode”, reading code from standard input and writing to standard output.

Options

You can specify formatting options using the following syntax:

--optionName=optionValue
# or
--optionName optionValue

For available option names, see ceylon.formatter.options::FormattingOptions. The syntax of optionValue is:

  • for Boolean or Integer values, use a Ceylon-style literal (1, true)
  • for Range values, use a Ceylon-style range operator x..y
  • for IndentMode values, see the documentation of parseIndentMode
  • for Iterable values, list the individual elements, separated by spaces
  • for LineBreakStrategy, the only valid value is default
  • for enumerated types, use the name of one of the object cases (lf, all)

Library usage

Use the format function to format any AST node. This can be a compilation unit (simply speaking, a complete file) or any other node.

If the node was parsed from an existing file, don’t forget to pass the token stream to format – without the token stream, the formatter can’t obtain the comments, so they won’t be present in the formatted file.

To construct FormattingOptions, usage of named arguments is highly recommended:

FormattingOptions {
    indentMode = Spaces(8);
    maxLineLength = 80;
}

You can also use SparseFormattingOptions and combinedOptions to compose several sets of options, like this:

combinedOptions {
    baseOptions = companyWideOptions;
    SparseFormattingOptions {
        indentMode = Spaces(1); // our department has very small screens :-(
    }
}
Category Command-line plugins

Modules which have command-line plugins available. You can install them with ceylon plugin install name/version.

Last Published Sep 5, 2017
Stats Downloads (JVM): 3578
Downloads (JS): 0
Source downloads: 3532
Module links Home
Code repository
Issue tracker
Imported By
Browse
List of published versions
1.3.3 JVM JVM: 1.2.x, 1.3.x (latest) Published Sep 5, 2017 Browse
View docs
1.3.2 JVM JVM: 1.2.x, 1.3.x (latest) Published Mar 2, 2017 Browse
View docs
1.3.1 JVM JVM: 1.2.x, 1.3.x (latest) Published Nov 21, 2016 Browse
View docs
1.3.0 JVM JVM: 1.2.x, 1.3.x (latest) Published Sep 15, 2016 Browse
View docs
1.2.2 JVM JVM: 1.2.x, 1.3.x (latest) Published Mar 13, 2016 Browse
View docs
1.2.1 JVM JVM: 1.2.x, 1.3.x (latest) Published Feb 11, 2016 Browse
View docs
1.2.0 JVM JVM: 1.2.x, 1.3.x (latest) Published Oct 28, 2015 Browse
View docs
1.1.0 JVM JVM: 1.1.0 (outdated) Published Oct 8, 2014 Browse
View docs
You must be logged in to comment.

Ceylon Herd v1.24 Copyright 2012-2022 Red Hat. About