• 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 / 1.2.0
Ceylon Source Code Formatter
Category Command-line plugins

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

Backends JVM
Maven coordinates
Compatible Ceylon release JVM: 1.2.x, 1.3.x (latest)
Published Oct 28, 2015
Stats Downloads (JVM): 565
Source downloads: 529
Authors Lucas Werkmeister <mail@lucaswerkmeister.de>
License https://www.apache.org/licenses/LICENSE-2.0.html
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.2.0

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 :-(
    }
}
Dependencies
ceylon.collection/1.2.0
ceylon.file/1.2.0 shared
ceylon.interop.java/1.2.0
ceylon.language/1.2.0
com.redhat.ceylon.common/1.2.0 shared
com.redhat.ceylon.typechecker/1.2.0 shared
java.base/7 JDK shared
Usage
  • Import
  • Run from command-line
  • Run from Ant
  • Install scripts from command-line
  • Install scripts from Ant
 import ceylon.formatter "1.2.0";
$ ceylon run ceylon.formatter/1.2.0
<property name="ceylon.home" value="…"/>
<property name="ceylon.ant.lib" 
  value="${ceylon.home}/lib/ceylon-ant.jar"/>
<path id="ant-tasks">
  <pathelement path="${ceylon.ant.lib}"/>
</path>
<typedef resource="com/redhat/ceylon/ant/antlib.xml" classpathref="ant-tasks"/>

<target name="run">
  <ceylon-run module="ceylon.formatter/1.2.0"/>
</target>
$ ceylon plugin install ceylon.formatter/1.2.0
<property name="ceylon.home" value="…"/>
<property name="ceylon.ant.lib" 
  value="${ceylon.home}/lib/ceylon-ant.jar"/>
<path id="ant-tasks">
  <pathelement path="${ceylon.ant.lib}"/>
</path>
<typedef resource="com/redhat/ceylon/ant/antlib.xml" classpathref="ant-tasks"/>

<target name="run">
  <ceylon-plugin mode=install module="ceylon.formatter/1.2.0"/>
</target>
Module links Members
Imported By
Home
Code repository
Issue tracker
Browse
Download .car
No .js archive
Download source archive
Download scripts archive
Scripts
Download module documentation
View API documentation

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