Scala Macro that re-writes class confuses the IDE

Hi, I saw a thread about a monocle macro, I am not sure if my problem is similar.

So I got an annotation macro that rewrites a class and is used like

class MyServiceRemote extends MyService

Now MyServiceRemote is re-written by the macro as

class MyServiceRemote {
... impl all MyService methods but with slightly different signature

So because of the macro it all compiles fine within the IDE or via sbt. But the editor is very confused as it things (as per the above code) that MyServiceRemote should impl all MyService methods. And then calling methods on MyServiceRemote looks like the call is invalid and ofcourse there is no autocomplete etc.

I suppose that the editor uses it's own parser so this is probably very hard to fix, is it?


You can try to use our new SyntheticMembersInjector API (
It can add new functions, however it can't remove "extends MyService". You can create a ticket for us to consider adding it to our API, however for the beggining it will be much better then you have it now.

Best regards,
Alexander Podkhalyuzin.


Hi Alexander, would it be feasible if the IDE provided some sort of API which I could call from my macro and notify the IDE about the src code of my macro? I.e.

.... macro code....
val src= "class X { def x = 5 }"
... do the macro stuff but also

I could then add IntellijScalaMacros to my classpath as "provided" so that it doesn't get deployed (in any case the macro code is not part of the deployable code)

I thought of just writing the class to a src folder (say generated/src) but then it will conflict with my annotated decl : @remoteService class X


We are going to implement some API, which enables IntelliJ Macro support if library author adds special classes for IntelliJ IDEA to this libarary. For me it looks more preferrable way.

Best regards,
Alexander Podkhalyuzin.


Thats sounds good to me too. I suppose there aren't any beta docs yet. When do you think this could be available, will it support my usecase?


Please sign in to leave a comment.