Class Formatter

java.lang.Object
software.amazon.smithy.syntax.Formatter

public final class Formatter extends 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 Details

    • format

      public static 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 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.