Class Formatter


  • public final class Formatter
    extends java.lang.Object
    Formats valid Smithy IDL models.

    This formatter will by default sort use statements, remove unused use statements, and fix documentation comments that should be normal comments.

    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String format​(TokenTree root)
      Formats the given token tree, wrapping lines at 120 characters.
      static java.lang.String format​(TokenTree root, int maxWidth)
      Formats the given token tree.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • format

        public static java.lang.String format​(TokenTree root)
        Formats the given token tree, wrapping lines at 120 characters.
        Parameters:
        root - Root TreeType.IDL tree node to format.
        Returns:
        Returns the formatted model as a string.
        Throws:
        ModelSyntaxException - if the model contains errors.
      • format

        public static java.lang.String format​(TokenTree root,
                                              int maxWidth)
        Formats the given token tree.
        Parameters:
        root - Root TreeType.IDL tree node to format.
        maxWidth - Maximum line width.
        Returns:
        Returns the formatted model as a string.
        Throws:
        ModelSyntaxException - if the model contains errors.