Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add accessors for code_path and tool_name to Expansion_context.Base #173

Merged
merged 1 commit into from
Sep 8, 2020

Conversation

jberdine
Copy link
Contributor

@jberdine jberdine commented Sep 6, 2020

For code implemented using
e.g. Ast_traverse.map_with_expansion_context, there is a base
expansion context available, but no accessors for e.g. the code_path
within. A hacky workaround is to write e.g.

let code_path base =
  Expansion_context.Extension.code_path
    (Expansion_context.Extension.make
       ~extension_point_loc:Location.none ~base ())

This patch adds accessors to directly obtain these values without such
a detour.

For code implemented using
e.g. `Ast_traverse.map_with_expansion_context`, there is a base
expansion context available, but no accessors for e.g. the `code_path`
within. A hacky workaround is to write e.g.
```ocaml
let code_path base =
  Expansion_context.Extension.code_path
    (Expansion_context.Extension.make
       ~extension_point_loc:Location.none ~base ())
```
This patch adds accessors to directly obtain these values without such
a detour.

Signed-off-by: Josh Berdine <[email protected]>
Copy link
Collaborator

@NathanReb NathanReb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me, thanks for adding those!

@NathanReb NathanReb merged commit a3878ab into ocaml-ppx:master Sep 8, 2020
NathanReb added a commit to NathanReb/opam-repository that referenced this pull request Sep 17, 2020
CHANGES:

- Add accessors for `code_path` and `tool_name` to `Expansion_context.Base`
  (ocaml-ppx/ppxlib#173, @jberdine)
- Add `cases` methods to traversal classes in `Ast_traverse` (ocaml-ppx/ppxlib#183, @pitag-ha)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants