How to cast a simple name in volume?

I am developing a code generator that will output the following classes / objects:

class A { var a : Int = _ var b : B = _ class B { var b : Int = _ var c : C = _ class C { var c : Int = _ } } } object A { val a = ... object B extends Base { val b = ... object C extends Base { val c = ... } } } 

with the user creating the following terms:

 A ( a(1), B ( b(2), C ( c(3) ) ) ) 

Now, to make it work, I need to insert 3 imports into the user code:

 import A._ import AB_ import ABC_ 

It looks ugly to me. Maybe there is another way to solve the problem that I just see blind?

Thanks in advance.

+4
source share
2 answers

After import A._ B will be in the import area (at least in Scala 2.8), so you can save a few letters:

 import A._ import B._ import C._ 
+1
source

You can use def in the generated code. For instance,

 object A { // ... other code def b = Bb def C = BC def c = Cc } 
+1
source

All Articles