Interface GeneratorManager<MODEL>

Manages code generation for a specific model.

Provides:

  • Access to the underlying workspace, document, and model.
  • Methods to collect generated files.
  • Support for multiple output directories (targets).
interface GeneratorManager<MODEL extends AstNode = AstNode> {
    createFile(
        filePath: string,
        content: string,
        options?: CreateFileOptions,
    ): void;
    getDocument(): undefined | LangiumDocument<MODEL>;
    getDocumentLocalPath(): undefined | string;
    getModel(): MODEL;
    getWorkspaceURI(): undefined | URI;
}

Type Parameters

  • MODEL extends AstNode = AstNode

    The type of the AST node model.

Methods

  • Creates a new file with the specified content and options.

    Parameters

    • filePath: string

      The file name with an optional relative path, relative to the output directory.

    • content: string

      The generated content of the new file.

    • Optionaloptions: CreateFileOptions

      Optional settings for file generation.

    Returns void

  • Returns the relative path of the Langium document within the determined workspace. See getWorkspaceURI. If DSL file is outside of all workspace directories, filename with extension (basename) is returned. / is used on all platforms as directory separator.

    Returns undefined | string

    The relative path as a string, if the workspace URI could be determined, filename with extension or undefined otherwise.

  • Returns the workspace URI corresponding to the Langium document URI.

    The URI will be selected from a list of known workspace URIs.

    Returns undefined | URI

    The workspace URI if it could be determined, or undefined otherwise.