• Convenience function for joining the elements of some iterable and gathering tracing information, if condition is equal to true.

    If condition is satisfied, 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 then 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. 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.

    Otherwise, if condition is equal to false, the returned function just returns undefined.

    Type Parameters

    Parameters

    • condition: boolean

      a boolean value indicating whether to evaluate the provided iterable.

    • 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 or undefined.

    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 a list of concrete coordinates, if condition is equal to true.

    If condition is satisfied, 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 then 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. Element-wise tracing need to be implemented by client code within toGenerated, if required.

    Otherwise, if condition is equal to false, the returned function just returns undefined.

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

    Parameters

    • condition: boolean

      a boolean value indicating whether to evaluate the provided iterable.

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

      a text region within some file in form of concrete coordinates or a supplier function, 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: ${ joinTracedToNodeIf(entity !== undefined, () => entity.$cstNode)(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, if condition is equal to true.

    If condition is satisfied, 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 then 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. Element-wise tracing need to be implemented by client code within toGenerated, if required.

    Otherwise, if condition is equal to false, the returned function just returns undefined.

    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 evaluate the provided iterable.

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

      a list of text regions within some file in form of concrete coordinates or a supplier function, 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: ${ joinTracedToNodeIf(entity !== undefined, () => findNodesForProperty(entity.$cstNode, 'children'))(entity.children, child => child.name, { separator: ' ' }) };
    `.appendNewLine()