Questions tagged [treehugger]

treehugger.scala is a library to write Scala source code programmatically

https://eed3si9n.com/treehugger/

treehugger.scala is a library to write Scala source code programmatically. It’s also an implementation of Scala abstract syntax tree based on Reflection API.

8 questions
15
votes
3 answers

Code generation with Scala

When using the SBT toolchain in Scala, is it possible to write a task that will read a special part of the project's source to generate scala-code at compile time. Any ideas or even articles/tutorials on this? I am looking for something rather…
Lanbo
  • 15,118
  • 16
  • 70
  • 147
2
votes
2 answers

meta-programming to parse json in scala

I need some hints to write a scala program that could read json file and create a case class at run time. As an example if we have json class like - Employ{ name:{datatype:String, null:false} age:{datatype:Int, null:true} …
tesnik03
  • 1,324
  • 2
  • 13
  • 23
2
votes
2 answers

What's the advantage of using Macros (instead of functions) is Scala?

What are macros used for in Scala? What can be done with a Macro that cannot be done with a function? I suppose one advantage are: The ability to parse the AST at the call point, but that's a fairly rare use case. The code doesn't result in an…
EugeneMi
  • 3,475
  • 3
  • 38
  • 57
1
vote
1 answer

Get Scala type name for common AnyVal types/primitives

In my scala code I have a Class[_ <: AnyVal] instance, such as the one obtained from classOf[Int]. When I try to obtain the scala type name from this (using classOf[Int].getName), I am expecting to see "scala.Int", but instead I am getting the…
derabbink
  • 2,419
  • 1
  • 22
  • 47
1
vote
3 answers

How to create a scala class based on user input?

I have a use case where I need to create a class based on user input. For example, the user input could be : "(Int,fieldname1) : (String,fieldname2) : .. etc" Then a class has to be created as follows at runtime Class Some { Int fieldname1 …
Rahul
  • 903
  • 8
  • 16
0
votes
0 answers

docly-gen installation error incompatible version

docly-gen /Users/abhinandansharma/form_app ____ __ / __ \____ _____/ /_ __ / / / / __ \/ ___/ / / / / / /_/ / /_/ / /__/ / /_/ / /_____/\____/\___/_/\__, / /____/ …
0
votes
1 answer

code generation using Treehugger scala

I am using TreeHugger to generate code at runtime. I could not find many documents related to it. My question is, if I generate classes using treehugger, will I be able to access those classes in future? To be precise: I want to read data coming…
ssri
  • 13
  • 6
0
votes
2 answers

Generate a case class in scala

How to generate case classes in scala based on information kept in 100s of java classes? Basically, I need this for writing a wrapper for a java library. Is it even possible? I have a feeling that no. In that case what is the best alternative?
Anton Kuzmin
  • 821
  • 1
  • 10
  • 26