• Convenience function for attaching tracing information to content of type Generated, 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 will create and return a new CompositeGeneratorNode being initialized with the given tracing information and add some content, if provided.

    Exception: if content is already a CompositeGeneratorNode containing no tracing information, that node is enriched with the given tracing information and returned, and no wrapping node is created.

    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)) => CompositeGeneratorNode)

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

    new CompositeGeneratorNode().appendTemplate
    `Hello World!`
    .appendNewLine().appendTracedTemplate(entity)
    `Hello ${ traceToNode(entity, 'name')(entity.name) }`
    .appendNewLineIfNotEmpty()
  • Convenience function for attaching tracing information to content of type Generated, in form of {astNode, property, index}.

    This method returns a helper function that takes the desired content and does the processing. The returned function will create and return a new CompositeGeneratorNode being initialized with the given tracing information and add some content, if provided.

    Exception: if content is already a CompositeGeneratorNode containing no tracing information, that node is enriched with the given tracing information and returned, and no wrapping node is created.

    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)) => CompositeGeneratorNode)

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

    new CompositeGeneratorNode().appendTemplate
    `Hello World!`
    .appendNewLine().appendTracedTemplate(entity)
    `Hello ${ traceToNode(entity, 'name')(entity.name) }`
    .appendNewLineIfNotEmpty()
  • Convenience function for attaching tracing information to content of type Generated, in form of concrete coordinates.

    This method returns a helper function that takes the desired content and does the processing. The returned function will create and return a new CompositeGeneratorNode being initialized with the given tracing information and add some content, if provided.

    Exception: if content is already a CompositeGeneratorNode containing no tracing information, that node is enriched with the given tracing information and returned, and no wrapping node is created.

    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)) => CompositeGeneratorNode)

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

    new CompositeGeneratorNode().appendTemplate
    `Hello World!`
    .appendNewLine().appendTracedTemplate(entity.$cstNode)
    `Hello ${ traceToNode(findNodeForProperty(entity.$cstNode, 'name'))(entity.name) }`
    .appendNewLineIfNotEmpty()
  • Convenience function for attaching tracing information to content of type Generated, 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 will create and return a new CompositeGeneratorNode being initialized with the given tracing information and add some content, if provided.

    Exception: if content is already a CompositeGeneratorNode containing no tracing information, that node is enriched with the given tracing information and returned, and no wrapping node is created.

    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 region within some file in form of concrete coordinates, if empty no tracing will happen

    Returns ((content?: Generated | ((node: CompositeGeneratorNode) => void)) => CompositeGeneratorNode)

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

    new CompositeGeneratorNode().appendTemplate
    `Hello World!`
    .appendNewLine().appendTracedTemplate(entity.$cstNode)
    `Hello ${ traceToNode(findNodesForProperty(entity.$cstNode, 'name'))(entity.name) }`
    .appendNewLineIfNotEmpty()