Skip to content

Update showExtractors to Printer.TreeStructure #10849

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

Merged
merged 2 commits into from
Dec 21, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions docs/docs/reference/metaprogramming/tasty-reflect.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,14 @@ def natConstImpl(x: Expr[Int])(using Quotes): Expr[Int] = {
}
```

To easily know which extractors are needed, the `showExtractors` method on a
`quotes.reflect.Term` returns the string representation of the extractors.
To easily know which extractors are needed using the `Printer.TreeStructure.show` which returns the string representation the structure of the tree. Other printers can also be found in the `Printer` module.

```scala
xTree.show(using Printer.TreeStructure)
// or
Printer.TreeStructure.show(xTree)
```


The methods `quotes.reflect.Term.{asExpr, asExprOf}` provide a way to go back to a `quoted.Expr`.
Note that `asExpr` returns a `Expr[Any]`.
Expand Down