Eclipse: Issues resolving implicit conversions and macro annotations in Scala

243 Views Asked by At

I'm using macroparadise to generate methods and case classes in my project (the macros themselves are defined in a separate project from my core files where I use them).

Everything compiles and runs as expected, but Eclipse is unable to resolve variables and methods generated by my macros. However, when I close and re-open Eclipse, it identifies everything perfectly; I can hover over the classes and methods and get the correct info. But, as soon as I change anything, or even just close and reopen the file referencing generate methods, Eclipse underlines all the generated variables and methods and tells me "not found: value {name}" (where {name} is the var name).

Update
I've isolated the behavior to cases like the following:

  1. I start with an annotated object A in one file, and an object B that uses A.hello in another file.
  2. I compile A's file, which adds method "hello" to object A.
  3. Everything works fine, until(!) I reopen the file containing object A.

Question: What does Eclipse do when I open a file? Does it attempt to reindex a class based on the written file rather than the compiled one?
End Update

How does Eclipse resolve variables? Is it looking at the class files in my target/ folder? I have the *.class files for all my generated code, so if Eclipse is looking at those, these variables should actually exist.

Has anyone gotten Eclipse to resolve these variables properly? I tried IntelliJ IDEA, but IDEA can't resolve anything using implicit conversions and macros (I followed directions I found online with no luck).

Info:
Eclipse IDE for Java Developers

Version: Oxygen Release (4.7.0)
Build id: 20170620-1800

Scala Plugin
scala-ide.org
4.4.1.v-2_11-201605041057-92a3ed3
org.scala-ide.sdt.feature

Compiler plugin:
macroparadise
org.scalamacros
paradise_2.11.8
version 2.1.0

1

There are 1 best solutions below

0
On

After looking around, it seems like the org.scala.macroparadise plugin isn't supported by Intellij or Eclipse. I resolved my issue by switching to the org.scalameta.paradise plugin, which is supported by the Intellij scala plugin.

Using org.scalameta, all my generated variables can be resolved, and my macros can be expanded in the IDE.