Intellij Idea scala Plugin to support macro question

Hello, I've enjoyed writing small plugin for Intellij to support scala macros, but recently I had this case.


case class Test(x: Int)


And @MyAnnotation adds methods to companion object. So result looks like this


case class Test(x: Int)

object Test {

   def generatedMethod(x: Int) = ... 


Making long story short: How to tell Idea that I generated method to companion object of Test case class. Is it possible? What method from injector should i override? InjectInner?


Thx for reading,


Comment actions Permalink
Official comment

The method you're looking for is injectFunctions.

The logic here is fairly simple - when your injector starts processing an object, look whether its companion class has an annotation and if it does, return the synthetic methods.

It's pretty much the same thing monocle injector does. See example

Comment actions Permalink

Ok, so you can check case class of the object. Thanks for an answer. 


Please sign in to leave a comment.