• Convenience function for joining the elements of some iterable and gathering tracing information.

    This function returns another function that does the processing, and that expects same list of arguments as expected by joinToNode, i.e. an iterable, a function toGenerated converting each element into a Generated, as well as some options.

    That function than joins the elements of iterable by delegating to joinToNode. Via traceToNode the resulting generator node is supplemented with the provided tracing information in form of {astNode, property?, index?}, and finally returned. In addition, if property is given each element's generator node representation is augmented with the provided tracing information plus the index of the element within iterable.

    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 (<E>(iterable: Iterable<E> | E[], toGenerated?: ((element: E, index: number, isLast: boolean) => Generated) | JoinOptions<E>, options?: JoinOptions<E>) => CompositeGeneratorNode | undefined)

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

    expandToNode`
    children: ${ joinTracedToNode(entity, 'children')(entity.children, child => child.name, { separator: ' ' }) };
    `.appendNewLine()
  • Convenience function for joining the elements of some iterable and gathering tracing information in form of concrete coordinates.

    This function returns another function that does the processing, and that expects same list of arguments as expected by joinToNode, i.e. an iterable, a function toGenerated converting each element into a Generated, as well as some options.

    That function than joins the elements of iterable by delegating to joinToNode. Via traceToNode the resulting generator node is supplemented with the provided tracing information, and finally returned. Elementwise tracing need to be implemented by client code within toGenerated, if required.

    Parameters

    • sourceRegion: undefined | SourceRegion

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

    Returns (<E>(iterable: Iterable<E> | E[], toGenerated?: ((element: E, index: number, isLast: boolean) => Generated) | JoinOptions<E>, options?: JoinOptions<E>) => CompositeGeneratorNode | undefined)

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

    expandToNode`
    children: ${ joinTracedToNode(findNodesForProperty(entity.$cstNode, 'children'))(entity.children, child => child.name, { separator: ' ' }) };
    `.appendNewLine()
  • Convenience function for joining the elements of some iterable and gathering tracing information in form of a list of concrete coordinates.

    This function returns another function that does the processing, and that expects same list of arguments as expected by joinToNode, i.e. an iterable, a function toGenerated converting each element into a Generated, as well as some options.

    That function than joins the elements of iterable by delegating to joinToNode. Via traceToNode the resulting generator node is supplemented with the provided tracing information, and finally returned. Elementwise tracing need to be implemented by client code within toGenerated, if required.

    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 (<E>(iterable: Iterable<E> | E[], toGenerated?: ((element: E, index: number, isLast: boolean) => Generated) | JoinOptions<E>, options?: JoinOptions<E>) => CompositeGeneratorNode | undefined)

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

    expandToNode`
    children: ${ joinTracedToNode(findNodesForProperty(entity.$cstNode, 'children'))(entity.children, child => child.name, { separator: ' ' }) };
    `.appendNewLine()