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.

@MyAnnotation

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,

Bartek

2 comments
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. 

0

Please sign in to leave a comment.