You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We can easily know which extractors are needed using `Printer.TreeStructure.show`, which returns the string representation the structure of the tree. Other printers can also be found in the `Printer` module.
56
+
We can easily know which extractors are needed using `Printer.TreeStructure.show`,
57
+
which returns the string representation the structure of the tree. Other printers
58
+
can also be found in the `Printer` module.
58
59
59
60
```scala
60
61
xTree.show(usingPrinter.TreeStructure)
61
62
// or
62
63
Printer.TreeStructure.show(xTree)
63
64
```
64
65
65
-
66
-
The methods `quotes.reflect.Term.{asExpr, asExprOf}` provide a way to go back to a `quoted.Expr`.
67
-
Note that `asExpr` returns a `Expr[Any]`.
68
-
On the other hand `asExprOf[T]` returns a `Expr[T]`, if the type does not conform to it an exception will be thrown at runtime.
69
-
66
+
The methods `quotes.reflect.Term.{asExpr, asExprOf}` provide a way to go back to
67
+
a `quoted.Expr`. Note that `asExpr` returns a `Expr[Any]`. On the other hand
68
+
`asExprOf[T]` returns a `Expr[T]`, if the type does not conform to it an exception
69
+
will be thrown at runtime.
70
70
71
71
### Positions
72
72
73
-
The `ast` in the context provides a `rootPosition` value. It corresponds to
74
-
the expansion site for macros. The macro authors can obtain various information about that
75
-
expansion site. The example below shows how we can obtain position information
76
-
such as the start line, the end line or even the source code at the expansion
77
-
point.
73
+
The `Position` in the context provides an `ofMacroExpansion` value. It corresponds
74
+
to the expansion site for macros. The macro authors can obtain various information
75
+
about that expansion site. The example below shows how we can obtain position
76
+
information such as the start line, the end line or even the source code at the
77
+
expansion point.
78
78
79
79
```scala
80
80
defmacroImpl()(quotes: Quotes):Expr[Unit] =
81
81
importquotes.reflect._
82
-
valpos=rootPosition
82
+
valpos=Position.ofMacroExpansion
83
83
84
84
valpath= pos.sourceFile.jpath.toString
85
85
valstart= pos.start
@@ -99,15 +99,15 @@ transformation.
99
99
100
100
`TreeAccumulator` ties the knot of a traversal. By calling `foldOver(x, tree))`
101
101
we can dive into the `tree` node and start accumulating values of type `X` (e.g.,
102
-
of type List[Symbol] if we want to collect symbols). The code below, for
102
+
of type `List[Symbol]` if we want to collect symbols). The code below, for
103
103
example, collects the pattern variables of a tree.
Copy file name to clipboardExpand all lines: docs/docs/reference/other-new-features/indentation.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -105,7 +105,7 @@ at the top-level, inside braces `{...}`, but not inside parentheses `(...)`, pat
105
105
106
106
###OptionalBracesAroundTemplateBodies
107
107
108
-
TheScala grammar uses the term _template body_ for the definitions of a class, trait, or objectthat are normally enclosed in braces. The braces around a template body can also be omitted by means of the following rule
108
+
TheScala grammar uses the term _template body_ for the definitions of a class, trait, or objectthat are normally enclosed in braces. The braces around a template body can also be omitted by means of the following rule.
109
109
110
110
If at the point where a template body can start there is a `:` that occurs at the end
111
111
of a line, and that is followed by at least one indented statement, the recognized
0 commit comments