Compiler Plugins and Type-Aware Highlighting

We use a DI library called subcut that uses a Scala compiler plugin.  We build with maven and have the subcut plugin specified as a compilerPlugin configuration option to scala-maven-plugin.

While (externally) building and running in IntelliJ works fine, unfortunately the bits of syntax that the compiler plugin takes care of aren't understood by IntelliJ type-aware highlighting, resulting in lots of red.  Is there any way to tell type-aware highlighting about the compiler plugin?

3 comments

Hi, Luke,

If you want to use IntelliJ IDEA with your custom compiler plugin, you need to write appropriate custom plugin for IntelliJ IDEA Scala plugin.
Please write me directly (Alexander.Podkhalyuzin@jetbrains.com) to discuss what we can do in your case.

Currently we haven't any simple mechanism in direction of creating such plugins, but I hope that we can do it together (by understanding your needs and implementings some extention points for Scala plugin).

Best regards,
Alexander Podkhalyuzin.

0

Hi, I'd like to knows if anything ever happened regarding this old issue? If not, I may be willing to try to work with you on a solution. I have zero experience with Intellij plugins, but it seems like this is a fairly simple problem?

Basically, here's what happens. There is a trait AutoInjectable which extends Injectable:

trait AutoInjectable extends Injectable

trait Injectable {
  implicit def bindingModule: BindingModule

  // ...

}
When there is a class like :

class Foo(// some parameters) extends AutoInjectable {// class body}
The compiler plugin adds an implicit constructor parameter, so you don't have to write it yourself:

class Foo(// some parameters)(implicit val bindingModule: BindingModule) extends AutoInjectable {// class body}

Since IDEA doesn't knows about the compiler plugin, it complains that the abstract member bindingModule must be implemented or Foo must be abstract. So all that's needed is for IDEA to ignore the missing implementation of bindingModule when a class extends AutoInjectable.

0

It's long-term task to deal with compiler plugins or macros (definitions or annotations). And it's not yet available.
It's possible to implement what you want (a bit harder than usual compiler plugins, but still possilbe). So as workaround for your problem you can try to build your own version of Scala plugin, which will support it (as first step). So write me to my e-mail (Alexander.Podkhalyuzin@jetbrains.com), and we will discuss entry points to Scala plugin sources and what to do for your compiler plugin.

Best regards,
Alexander Podkhalyuzin.

0

Please sign in to leave a comment.