doorgan/sourceror

Add `Sourceror.map_args`?

doorgan opened this issue · 1 comments

In the Multi alias expansion, we use the :collapse_comments to avoid correcting the line number of comments when mapping over the aliases. The main problem in that case is that if one of the nodes being mapped performs a line correction in itself, there's no easy way to propagate that correction to the subsequent nodes, and we would need to resort to cumbersome solutions with Enum.reduce.

Sourceror.map_args would work similarly to Enum.map but it would take a whole node as an argument and the mapper function should return a {quoted, state} tuple much like Sourceror.postwalk/3. This function would automatically apply line corrections, and would return both the updated args and the line corrections accumulated during the mapping. It would also take care of correcting only the ending lines of the parent node.

Closing as line corrections are no longer needed.