File tree Expand file tree Collapse file tree 7 files changed +36
-0
lines changed
compiler/src/dotty/tools/dotc/tastyreflect Expand file tree Collapse file tree 7 files changed +36
-0
lines changed Original file line number Diff line number Diff line change
1
+ package dotty .tools .dotc .tastyreflect
2
+
3
+ trait SettingsOpsImpl extends scala.tasty.reflect.SettingsOps with TastyCoreImpl {
4
+
5
+ def settings (implicit ctx : Context ): Settings = ctx.settings
6
+
7
+ def SettingsDeco (settings : Settings ): SettingsAPI = new SettingsAPI {
8
+ def color (implicit ctx : Context ): Boolean = settings.color.value == " always"
9
+ }
10
+
11
+ }
Original file line number Diff line number Diff line change @@ -9,6 +9,8 @@ trait TastyCoreImpl extends scala.tasty.reflect.TastyCore {
9
9
10
10
type Context = core.Contexts .Context
11
11
12
+ type Settings = config.ScalaSettings
13
+
12
14
type TermOrTypeTree = tpd.Tree
13
15
14
16
type Tree = tpd.Tree
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ class TastyImpl(val rootContext: Contexts.Context)
14
14
with PatternOpsImpl
15
15
with PositionOpsImpl
16
16
with PrintersImpl
17
+ with SettingsOpsImpl
17
18
with SignatureOpsImpl
18
19
with StandardDefinitions
19
20
with SymbolOpsImpl
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ abstract class Tasty
13
13
with PatternOps
14
14
with PositionOps
15
15
with Printers
16
+ with SettingsOps
16
17
with SignatureOps
17
18
with StandardDefinitions
18
19
with SymbolOps
Original file line number Diff line number Diff line change
1
+ package scala .tasty .reflect
2
+
3
+ trait SettingsOps extends TastyCore {
4
+
5
+ /** Compiler settings */
6
+ def settings (implicit ctx : Context ): Settings
7
+
8
+ trait SettingsAPI {
9
+ def color (implicit ctx : Context ): Boolean
10
+ }
11
+ implicit def SettingsDeco (settings : Settings ): SettingsAPI
12
+
13
+ }
Original file line number Diff line number Diff line change @@ -114,6 +114,9 @@ trait TastyCore {
114
114
/** Compilation context */
115
115
type Context
116
116
117
+ /** Settings */
118
+ type Settings
119
+
117
120
// TODO: When bootstrapped, remove and use `Term | TypeTree` type directly in other files
118
121
/** Workaround missing `|` types in Scala 2 to represent `Term | TypeTree` */
119
122
type TermOrTypeTree /* Term | TypeTree */
Original file line number Diff line number Diff line change @@ -6,6 +6,11 @@ import scala.annotation.switch
6
6
class ShowSourceCode [T <: Tasty with Singleton ](tasty0 : T ) extends Show [T ](tasty0) {
7
7
import tasty .{rootContext => _ , _ }
8
8
9
+ private [this ] val color : Boolean = {
10
+ import tasty .rootContext
11
+ tasty.settings.color
12
+ }
13
+
9
14
def showTree (tree : Tree )(implicit ctx : Context ): String =
10
15
(new Buffer ).printTree(tree).result()
11
16
You can’t perform that action at this time.
0 commit comments