Langium - v4.0.0
    Preparing search index...

    Class LangiumGrammarFormatter

    Language specific service for handling formatting related LSP requests.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    collector: FormattingCollector = ...

    Accessors

    • get formatOnTypeOptions(): undefined | DocumentOnTypeFormattingOptions

      Options that determine when the formatDocumentOnType method should be invoked by the language client. When undefined is returned, document format on type will be disabled.

      Returns undefined | DocumentOnTypeFormattingOptions

    Methods

    • Creates a formatter scoped to the supplied AST node. Allows to define fine-grained formatting rules for elements.

      Example usage:

      export class CustomFormatter extends AbstractFormatter {
      protected override format(node: AstNode): void {
      if (isPerson(node)) {
      const formatter = this.getNodeFormatter(node);
      formatter.property('name').prepend(Formatting.oneSpace());
      }
      }
      }

      Type Parameters

      Parameters

      • node: T

        The specific node the formatter should be scoped to. Every call to properties or keywords will only select those which belong to the supplied AST node.

      Returns NodeFormatter<T>