Implementation of @{link GeneratorNode} denoting areas within the desired generated text of common increased indentation.

Hierarchy (view full)

Constructors

Properties

contents: (string | GeneratorNode)[] = []
indentation?: string
indentEmptyLines: boolean = false
indentImmediately: boolean = true

Methods

  • Appends strings and instances of GeneratorNode to this generator node, if condition is equal to true.

    If condition is satisfied this method delegates to append, otherwise it returns just this.

    Parameters

    • condition: boolean

      a boolean value indicating whether to append the elements of args to this.

    • Rest...content: (Generated | ((node: CompositeGeneratorNode) => void))[]

      a var arg mixture of strings, GeneratorNodes, or single param functions that are immediately called with this node as argument, and which may append elements themselves.

    Returns this

    this CompositeGeneratorNode for convenience.

    new CompositeGeneratorNode().append(
    'Hello World!'
    ).appendNewLine().appendIf(
    entity !== undefined, `Hello ${entity?.name}!`
    ).appendNewLineIfNotEmpty();
  • Convenience method for appending content in form of a template to this generator node, if condition is equal to true.

    This method returns a tag function that takes the desired template and does the processing.

    If condition is satisfied the tagged template delegates to appendTemplate, otherwise it returns just this.

    See expandToNode for details.

    Parameters

    • condition: boolean

      a boolean value indicating whether to append the template content to this.

    Returns ((staticParts: TemplateStringsArray, ...substitutions: unknown[]) => this)

    a tag function behaving as described above, which in turn returns this CompositeGeneratorNode for convenience.

      • (staticParts, ...substitutions): this
      • Parameters

        • staticParts: TemplateStringsArray
        • Rest...substitutions: unknown[]

        Returns this

    new CompositeGeneratorNode().appendTemplate
    `Hello World!`
    .appendNewLine().appendTemplateIf(entity !== undefined)
    `Hello ${entity?.name}!`
    .appendNewLineIfNotEmpty()
  • Convenience method for appending content to this generator node including tracing information in form of {astNode, property?, index: undefined}.

    This method returns a helper function that takes the desired content and does the processing. The returned function delegates to append, with the provided content being wrapped by an additional CompositeGeneratorNode configured with the tracing information.

    Type Parameters

    Parameters

    • astNode: T

      the AstNode corresponding to the appended content

    • Optionalproperty: Properties<T>

      the value property name (string) corresponding to the appended content, if e.g. the content corresponds to some string or number property of astNode, is optional

    Returns ((...content: (Generated | ((node: CompositeGeneratorNode) => void))[]) => this)

    a function behaving as described above, which in turn returns this CompositeGeneratorNode for convenience.

    new CompositeGeneratorNode().appendTemplate
    `Hello World!`
    .appendNewLine().append('Hello ').appendTraced(entity, 'name')(entity.name)
    .appendNewLineIfNotEmpty()
  • Convenience method for appending content to this generator node including tracing information in form of {astNode, property, index}.

    This method returns a helper function that takes the desired content and does the processing. The returned function delegates to append, with the provided content being wrapped by an additional CompositeGeneratorNode configured with the tracing information.

    Type Parameters

    Parameters

    • astNode: T

      the AstNode corresponding to the appended content

    • property: Properties<T>

      the value property name (string) corresponding to the appended content, if e.g. the content corresponds to some string or number property of astNode

    • index: undefined | number

      the index of the value within a list property corresponding to the appended content, if the property contains a list of elements, is ignored otherwise

    Returns ((...content: (Generated | ((node: CompositeGeneratorNode) => void))[]) => this)

    a function behaving as described above, which in turn returns this CompositeGeneratorNode for convenience.

    new CompositeGeneratorNode().appendTemplate
    `Hello World!`
    .appendNewLine().append('Hello ').appendTraced(entity, 'name')(entity.name)
    .appendNewLineIfNotEmpty()
  • Convenience method for appending content to this generator node including tracing information in form of concrete coordinates.

    This method returns a helper function that takes the desired content and does the processing. The returned function delegates to append, with the provided content being wrapped by an additional CompositeGeneratorNode configured with the tracing information.

    Parameters

    • sourceRegion: undefined | SourceRegion

      a text region within some file in form of concrete coordinates, if undefined no tracing will happen

    Returns ((...content: (Generated | ((node: CompositeGeneratorNode) => void))[]) => this)

    a function behaving as described above, which in turn returns this CompositeGeneratorNode for convenience.

    new CompositeGeneratorNode().appendTemplate
    `Hello World!`
    .appendNewLine().append('Hello ').appendTraced(findNodeForProperty(entity.$cstNode, 'name'))(entity.name)
    .appendNewLineIfNotEmpty()
  • Convenience method for appending content to this generator node including tracing information in form of a list of concrete coordinates.

    This method returns a helper function that takes the desired content and does the processing. The returned function delegates to append, with the provided content being wrapped by an additional CompositeGeneratorNode configured with the tracing information.

    The list of regions in sourceRegions will later be reduced to the smallest encompassing region of all the contained source regions.

    Parameters

    • sourceRegions: SourceRegion[]

      a list of text regions within some file in form of concrete coordinates, if empty no tracing will happen

    Returns ((...content: (Generated | ((node: CompositeGeneratorNode) => void))[]) => this)

    a function behaving as described above, which in turn returns this CompositeGeneratorNode for convenience.

    new CompositeGeneratorNode().appendTemplate
    `Hello World!`
    .appendNewLine().append('Hello ').appendTraced([ findNodeForProperty(entity.$cstNode, 'name') ])(entity.name)
    .appendNewLineIfNotEmpty()
  • Convenience method for appending content to this generator node including tracing information in form of {astNode, property?, index: undefined}, if condition is equal to true.

    This method returns a tag function that takes the desired template and does the processing.

    If condition is satisfied the returned function delegates to appendTraced, otherwise it returns just this.

    Type Parameters

    Parameters

    • condition: boolean

      a boolean value indicating whether to append the template content to this.

    • astNode: T

      the AstNode corresponding to the appended content

    • Optionalproperty: Properties<T>

      the value property name (string) corresponding to the appended content, if e.g. the content corresponds to some string or number property of astNode, is optional

    Returns ((...content: (Generated | ((node: CompositeGeneratorNode) => void))[]) => this)

    a function behaving as described above, which in turn returns this CompositeGeneratorNode for convenience.

    new CompositeGeneratorNode().appendTemplate
    `Hello World!`
    .appendNewLine().appendIf(entity !== undefined, 'Hello ').appendTracedIf(entity !== undefined, entity, 'name')(entity?.name)
    .appendNewLineIfNotEmpty()
  • Convenience method for appending content to this generator node including tracing information in form of {astNode, property, index}, if condition is equal to true.

    This method returns a tag function that takes the desired template and does the processing.

    If condition is satisfied the returned function delegates to appendTraced, otherwise it returns just this.

    Type Parameters

    Parameters

    • condition: boolean

      a boolean value indicating whether to append the template content to this.

    • astNode: T

      the AstNode corresponding to the appended content

    • property: Properties<T>

      the value property name (string) corresponding to the appended content, if e.g. the content corresponds to some string or number property of astNode

    • index: undefined | number

      the index of the value within a list property corresponding to the appended content, if the property contains a list of elements, is ignored otherwise

    Returns ((...content: (Generated | ((node: CompositeGeneratorNode) => void))[]) => this)

    a function behaving as described above, which in turn returns this CompositeGeneratorNode for convenience.

    new CompositeGeneratorNode().appendTemplate
    `Hello World!`
    .appendNewLine().appendIf(entity !== undefined, 'Hello ').appendTracedIf(entity !== undefined, entity, 'name')(entity?.name)
    .appendNewLineIfNotEmpty()
  • Convenience method for appending content to this generator node including tracing information in form of concrete coordinates, if condition is equal to true.

    This method returns a tag function that takes the desired template and does the processing.

    If condition is satisfied the returned function delegates to appendTraced, otherwise it returns just this.

    If sourceRegion is a function supplying the corresponding region, it's only called if condition is satisfied.

    Parameters

    • condition: boolean

      a boolean value indicating whether to append the template content to this.

    • sourceRegion: undefined | SourceRegion | (() => SourceRegion | undefined)

      a text region within some file in form of concrete coordinates, if undefined no tracing will happen

    Returns ((...content: (Generated | ((node: CompositeGeneratorNode) => void))[]) => this)

    a function behaving as described above, which in turn returns this CompositeGeneratorNode for convenience.

    new CompositeGeneratorNode().appendTemplate
    `Hello World!`
    .appendNewLine().appendIf(entity !== undefined, 'Hello ').appendTracedIf(entity !== undefined, () => findNodeForProperty(entity.$cstNode, 'name'))(entity?.name)
    .appendNewLineIfNotEmpty()
  • Convenience method for appending content to this generator node including tracing information in form of a list of concrete coordinates, if condition is equal to true.

    This method returns a tag function that takes the desired template and does the processing.

    If condition is satisfied the returned function delegates to appendTraced, otherwise it returns just this.

    The list of regions in sourceRegions will later be reduced to the smallest encompassing region of all the contained source regions. If sourceRegions is a function supplying the corresponding regions, it's only called if condition is satisfied.

    Parameters

    • condition: boolean

      a boolean value indicating whether to append the template content to this.

    • sourceRegions: SourceRegion[] | (() => SourceRegion[])

      a list of text regions within some file in form of concrete coordinates, if empty no tracing will happen

    Returns ((...content: (Generated | ((node: CompositeGeneratorNode) => void))[]) => this)

    a function behaving as described above, which in turn returns this CompositeGeneratorNode for convenience.

    new CompositeGeneratorNode().appendTemplate
    `Hello World!`
    .appendNewLine().appendIf(entity !== undefined, 'Hello ').appendTracedIf(entity !== undefined, () => [ findNodeForProperty(entity.$cstNode, 'name') ])(entity?.name)
    .appendNewLineIfNotEmpty()
  • Convenience method for appending content in form of a template to this generator node including tracing information in form of {astNode, property?, index: undefined}.

    This method returns a tag function that takes the desired template and does the processing by delegating to expandTracedToNode.

    Type Parameters

    Parameters

    • astNode: T

      the AstNode corresponding to the appended content

    • Optionalproperty: Properties<T>

      the value property name (string) corresponding to the appended content, if e.g. the content corresponds to some string or number property of astNode, is optional

    Returns ((staticParts: TemplateStringsArray, ...substitutions: unknown[]) => this)

    a tag function behaving as described above, which in turn returns this CompositeGeneratorNode for convenience.

      • (staticParts, ...substitutions): this
      • Parameters

        • staticParts: TemplateStringsArray
        • Rest...substitutions: unknown[]

        Returns this

    new CompositeGeneratorNode().appendTemplate
    `Hello World!`
    .appendNewLine().appendTracedTemplate(entity, 'name')
    `Hello ${entity?.name}!`
    .appendNewLineIfNotEmpty()
  • Convenience method for appending content in form of a template to this generator node including tracing information in form of {astNode, property, index}.

    This method returns a tag function that takes the desired template and does the processing by delegating to expandTracedToNode.

    Type Parameters

    Parameters

    • astNode: T

      the AstNode corresponding to the appended content

    • property: Properties<T>

      the value property name (string) corresponding to the appended content, if e.g. the content corresponds to some string or number property of astNode

    • index: undefined | number

      the index of the value within a list property corresponding to the appended content, if the property contains a list of elements, is ignored otherwise, is optinal

    Returns ((staticParts: TemplateStringsArray, ...substitutions: unknown[]) => this)

    a tag function behaving as described above, which in turn returns this CompositeGeneratorNode for convenience.

      • (staticParts, ...substitutions): this
      • Parameters

        • staticParts: TemplateStringsArray
        • Rest...substitutions: unknown[]

        Returns this

    new CompositeGeneratorNode().appendTemplate
    `Hello World!`
    .appendNewLine().appendTracedTemplate(entity, 'name')
    `Hello ${entity?.name}!`
    .appendNewLineIfNotEmpty()
  • Convenience method for appending content in form of a template to this generator node including tracing information in form of concrete coordinates.

    This method returns a tag function that takes the desired template and does the processing by delegating to expandTracedToNode.

    Parameters

    • sourceRegion: undefined | SourceRegion

      a text region within some file in form of concrete coordinates, if undefined no tracing will happen

    Returns ((staticParts: TemplateStringsArray, ...substitutions: unknown[]) => this)

    a tag function behaving as described above, which in turn returns this CompositeGeneratorNode for convenience.

      • (staticParts, ...substitutions): this
      • Parameters

        • staticParts: TemplateStringsArray
        • Rest...substitutions: unknown[]

        Returns this

    new CompositeGeneratorNode().appendTemplate
    `Hello World!`
    .appendNewLine().appendTracedTemplate(findNodeForProperty(entity.$cstNode, 'name'))
    `Hello ${entity?.name}!`
    .appendNewLineIfNotEmpty()
  • Convenience method for appending content in form of a template to this generator node including tracing information in form of concrete coordinates.

    This method returns a tag function that takes the desired template and does the processing by delegating to expandTracedToNode.

    The list of regions in sourceRegions will later be reduced to the smallest encompassing region of all the contained source regions.

    Parameters

    • sourceRegions: SourceRegion[]

      a list of text regions within some file in form of concrete coordinates, if empty no tracing will happen

    Returns ((staticParts: TemplateStringsArray, ...substitutions: unknown[]) => this)

    a tag function behaving as described above, which in turn returns this CompositeGeneratorNode for convenience.

      • (staticParts, ...substitutions): this
      • Parameters

        • staticParts: TemplateStringsArray
        • Rest...substitutions: unknown[]

        Returns this

    new CompositeGeneratorNode().appendTemplate
    `Hello World!`
    .appendNewLine().appendTracedTemplate( findNodesForProperty(entity.$cstNode, 'name'))
    `Hello ${entity?.name}!`
    .appendNewLineIfNotEmpty()
  • Convenience method for appending content in form of a template to this generator node including tracing information in form of {astNode, property?, index: undefined}, if condition is equal to true.

    This method returns a tag function that takes the desired template and does the processing.

    If condition is satisfied the tagged template delegates to appendTracedTemplate, otherwise it returns just this. See also expandTracedToNode for details.

    Type Parameters

    Parameters

    • condition: boolean

      a boolean value indicating whether to append the template content to this.

    • astNode: T

      the AstNode corresponding to the appended content

    • Optionalproperty: Properties<T>

      the value property name (string) corresponding to the appended content, if e.g. the content corresponds to some string or number property of astNode, is optional

    Returns ((staticParts: TemplateStringsArray, ...substitutions: unknown[]) => this)

    a tag function behaving as described above, which in turn returns this CompositeGeneratorNode for convenience.

      • (staticParts, ...substitutions): this
      • Parameters

        • staticParts: TemplateStringsArray
        • Rest...substitutions: unknown[]

        Returns this

    new CompositeGeneratorNode().appendTemplate
    `Hello World!`
    .appendNewLine().appendTracedTemplateIf(entity?.name !== undefined, entity)
    `Hello ${entity?.name}!`
    .appendNewLineIfNotEmpty()
  • Convenience method for appending content in form of a template to this generator node including tracing information in form of {astNode, property, index}, if condition is equal to true.

    This method returns a tag function that takes the desired template and does the processing.

    If condition is satisfied the tagged template delegates to appendTracedTemplate, otherwise it returns just this. See also expandTracedToNode for details.

    Type Parameters

    Parameters

    • condition: boolean

      a boolean value indicating whether to append the template content to this.

    • astNode: T

      the AstNode corresponding to the appended content

    • property: Properties<T>

      the value property name (string) corresponding to the appended content, if e.g. the content corresponds to some string or number property of astNode

    • index: undefined | number

      the index of the value within a list property corresponding to the appended content, if the property contains a list of elements, is ignored otherwise

    Returns ((staticParts: TemplateStringsArray, ...substitutions: unknown[]) => this)

    a tag function behaving as described above, which in turn returns this CompositeGeneratorNode for convenience.

      • (staticParts, ...substitutions): this
      • Parameters

        • staticParts: TemplateStringsArray
        • Rest...substitutions: unknown[]

        Returns this

    new CompositeGeneratorNode().appendTemplate
    `Hello World!`
    .appendNewLine().appendTracedTemplateIf(entity?.name !== undefined, entity)
    `Hello ${entity?.name}!`
    .appendNewLineIfNotEmpty()
  • Convenience method for appending content in form of a template to this generator node including tracing information in form of concrete coordinates, if condition is equal to true.

    This method returns a tag function that takes the desired template and does the processing.

    If condition is satisfied the tagged template delegates to appendTracedTemplate, otherwise it returns just this. See also expandTracedToNode for details.

    • If sourceRegion is a function supplying the corresponding region, it's only called if condition is satisfied.

    Parameters

    • condition: boolean

      a boolean value indicating whether to append the template content to this.

    • sourceRegion: undefined | SourceRegion | (() => SourceRegion | undefined)

      a text region within some file in form of concrete coordinates, if undefined no tracing will happen

    Returns ((staticParts: TemplateStringsArray, ...substitutions: unknown[]) => this)

    a tag function behaving as described above, which in turn returns this CompositeGeneratorNode for convenience.

      • (staticParts, ...substitutions): this
      • Parameters

        • staticParts: TemplateStringsArray
        • Rest...substitutions: unknown[]

        Returns this

    new CompositeGeneratorNode().appendTemplate
    `Hello World!`
    .appendNewLine().appendTracedTemplateIf(entity?.name !== undefined, entity.$cstNode)
    `Hello ${entity?.name}!`
    .appendNewLineIfNotEmpty()
  • Convenience method for appending content in form of a template to this generator node including tracing information in form of a list of concrete coordinates, if condition is equal to true.

    This method returns a tag function that takes the desired template and does the processing.

    If condition is satisfied the tagged template delegates to appendTracedTemplate, otherwise it returns just this. See also expandTracedToNode for details.

    The list of regions in sourceRegions will later be reduced to the smallest encompassing region of all the contained source regions. If sourceRegions is a function supplying the corresponding regions, it's only called if condition is satisfied.

    Parameters

    • condition: boolean

      a boolean value indicating whether to append the template content to this.

    • sourceRegions: SourceRegion[] | (() => SourceRegion[])

      a list of text regions within some file in form of concrete coordinates, if empty no tracing will happen

    Returns ((staticParts: TemplateStringsArray, ...substitutions: unknown[]) => this)

    a tag function behaving as described above, which in turn returns this CompositeGeneratorNode for convenience.

      • (staticParts, ...substitutions): this
      • Parameters

        • staticParts: TemplateStringsArray
        • Rest...substitutions: unknown[]

        Returns this

    new CompositeGeneratorNode().appendTemplate
    `Hello World!`
    .appendNewLine().appendTracedTemplateIf(entity?.name !== undefined, () => [ findNodeForProperty(entity.$cstNode, 'name')! ])
    `Hello ${entity?.name}!`
    .appendNewLineIfNotEmpty()
  • Adds an area of indented text output. The content to be indented can be provided as an array consisting of strings and/or generation nodes (undefined is permitted), or via a callback offering the indentingNode to which the content shall be appended. Alternatively, an object satisfying IndentConfig can be provided taking the children as Array or via a callback as described previously via the indentedChildren property.

    The remaining properties of IndentConfig have the following effects:

    • indentation: a specific indentation length or string, defaults to the global indentation setting if omitted, see toString,
    • indentEmptyLines: apply indentation to empty lines, defaults to false
    • indentImmediately: apply the indentation immediately starting at the first line, defaults to true, might be set to false if preceding content is not terminated by any newline. If false the indentation is inserted only after child newline nodes followed by further content.

    Parameters

    Returns this

    this CompositeGeneratorNode for convenience.

    new CompositeGeneratorNode().append(
    '{'
    ).indent(indentingNode =>
    indentingNode.append(
    'name:', name, ','
    ).appendNewLine().appendIf(description !== undefined,
    'description:', description
    ).appendNewLineIfNotEmpty()
    ).append(
    '}'
    );
  • Adds tracing information in form of {astNode, property?, index: undefined} to this generator node. Overwrites existing trace data, if set previously.

    The given data are kept as they are, the actual resolution of text positions within the DSL text is done at the final processing of this node as part of ().

    Type Parameters

    Parameters

    • astNode: T

      the AstNode corresponding to this node's content

    • Optionalproperty: Properties<T>

      the value property name (string) corresponding to this node's content, e.g. if this node's content corresponds to some string or number property; is optional

    Returns this

    this CompositeGeneratorNode for convenience.

  • Adds tracing information in form of {astNode, property, index} to this generator node. Overwrites existing trace data, if set previously.

    The given data are kept as they are, the actual resolution of text positions within the DSL text is done at the final processing of this node as part of ().

    Type Parameters

    Parameters

    • astNode: T

      the AstNode corresponding to this node's content

    • property: Properties<T>

      the value property name (string) corresponding to this node's content, e.g. if this node's content corresponds to some string or number property

    • index: undefined | number

      the index of the value within a list property corresponding to this node's content, if the property contains a list of elements, is ignored otherwise

    Returns this

    this CompositeGeneratorNode for convenience.

  • Adds tracing information in form of concrete coordinates to this generator node. Complete coordinates are provided by the AstNodes' corresponding AstNode.$cstNodes. Overwrites existing trace data, if set previously.

    Parameters

    • sourceRegion: undefined | SourceRegion

      a text region within some file in form of concrete coordinates, if undefined no tracing will happen

    Returns this

    this CompositeGeneratorNode for convenience.

  • Adds tracing information in form of a list of concrete coordinates to this generator node. Overwrites existing trace data, if set previously.

    The list of regions in sourceRegion is reduced to the smallest encompassing region of all the contained source regions.

    Parameters

    • sourceRegion: SourceRegion[]

      a list of text regions within some file in form of concrete coordinates, if empty no tracing will happen

    Returns this

    this CompositeGeneratorNode for convenience.