View Source Sourceror.Comments (Sourceror v0.13.0)

Utilities to merge an un-merge comments and quoted expressions.

Link to this section Summary

Functions

Does the opposite of merge_comments/2, it extracts the comments from the quoted expression and returns both as a {quoted, comments} tuple.

Merges the comments into the given quoted expression.

Link to this section Functions

Link to this function

extract_comments(quoted, opts \\ [])

View Source

Does the opposite of merge_comments/2, it extracts the comments from the quoted expression and returns both as a {quoted, comments} tuple.

Link to this function

merge_comments(quoted, comments)

View Source
@spec merge_comments(Macro.t(), [map()]) :: Macro.t()

Merges the comments into the given quoted expression.

The comments are inserted into the metadata of their closest node. Comments in the same line of before a node are inserted into the :leading_comments field while comments that are right before an end keyword are inserted into the :trailing_comments field.