Re: [scala-ide-user] IDE compiler bug for scala 2.10.0-M7?

120 views
Skip to first unread message

iulian dragos

unread,
Sep 11, 2012, 4:05:04 AM9/11/12
to scala-i...@googlegroups.com


On Tue, Sep 11, 2012 at 4:59 AM, Rodrigo Cano <ioni...@gmail.com> wrote:
The globalCache function accessible in macros does not seem to work in the IDE. My project compiles from SBT just fine, but in the IDE, values set in the globalCache seem to get lost, breaking the functionality of my macros.

Is anyone aware of this?

AFAIK there is no Scala IDE built for 2.10.0-M7. Are you using a nightly version? What are the exact versions you're using (both in Sbt and of the IDE)?

iulian
 

Thanks.



--
« Je déteste la montagne, ça cache le paysage »
Alphonse Allais

Eugene Burmako

unread,
Sep 11, 2012, 10:13:41 AM9/11/12
to Scala IDE User
I just chatted with Iulian, and he told me that presentation compiler
can sometimes be restarted, effectively making it impossible for us to
provide reliable caching APIs. So right now I'm thinking of removing
the caches altogether: https://issues.scala-lang.org/browse/SI-6362.

Could you please describe your use case? Then we would be able to
figure out the best course of action.

On Sep 11, 4:59 am, Rodrigo Cano <ioniv...@gmail.com> wrote:
> The globalCache function accessible in macros does not seem to work in the
> IDE. My project compiles from SBT just fine, but in the IDE, values set in
> the globalCache seem to get lost, breaking the functionality of my macros.
>
> Is anyone aware of this?
>
> Thanks.

iulian dragos

unread,
Sep 11, 2012, 10:17:21 AM9/11/12
to scala-i...@googlegroups.com
On Tue, Sep 11, 2012 at 4:13 PM, Eugene Burmako <xen...@gmail.com> wrote:
I just chatted with Iulian, and he told me that presentation compiler
can sometimes be restarted, effectively making it impossible for us to
provide reliable caching APIs.

For example, the presentation compiler is restarted if the classpath changes (either a dependent project is rebuilt, or a jar file has changed). In general, you can't rely on having the same instance of the compiler all the time.

iulian
 
So right now I'm thinking of removing
the caches altogether: https://issues.scala-lang.org/browse/SI-6362.

Could you please describe your use case? Then we would be able to
figure out the best course of action.

On Sep 11, 4:59 am, Rodrigo Cano <ioniv...@gmail.com> wrote:
> The globalCache function accessible in macros does not seem to work in the
> IDE. My project compiles from SBT just fine, but in the IDE, values set in
> the globalCache seem to get lost, breaking the functionality of my macros.
>
> Is anyone aware of this?
>
> Thanks.

Rodrigo Cano

unread,
Sep 11, 2012, 12:15:49 PM9/11/12
to scala-i...@googlegroups.com
Hi, I guess the complete version of the IDE no longer matters given what you described.

The use case is the following:

I'm doing some integration between fxml (javafx) and scala so that I can create the GUI in the scene builder and in the code bind variables to components by means of a selector string. Said selector is checked against the fxml to check whether it exists or not.
In order to do this I have two macros, the first one is declareFxmlSource, which associates a file (yes, not the class) with the fxml, it loads the XML and stores it in the cache for later use of the second macro: that is subNode which takes the root node as loaded by FXMLLoader and the string.

The end result is quite pleasing.

Not being able to use the globalCache, I would have to resort to some kind of cache in a temp file system or reparse the fxml each time which doesn't seem very promising..

Thanks for the quick feedback.

  private val declaration = FxMacros.declareFxmlSource("main.fxml")
  val allContent: BorderPane = FXMLLoader.load(getClass.getResource("/main.fxml"))

  val menuBar: MenuBar = FxMacros.subNode(allContent)("top/MenuBar")
  val fileMenu: Menu = FxMacros.subNode(allContent)("top/MenuBar/menus/Menu#file")

iulian dragos

unread,
Sep 11, 2012, 12:40:24 PM9/11/12
to scala-i...@googlegroups.com
On Tue, Sep 11, 2012 at 6:15 PM, Rodrigo Cano <ioni...@gmail.com> wrote:
Hi, I guess the complete version of the IDE no longer matters given what you described.

The use case is the following:

I'm doing some integration between fxml (javafx) and scala so that I can create the GUI in the scene builder and in the code bind variables to components by means of a selector string. Said selector is checked against the fxml to check whether it exists or not.
In order to do this I have two macros, the first one is declareFxmlSource, which associates a file (yes, not the class) with the fxml, it loads the XML and stores it in the cache for later use of the second macro: that is subNode which takes the root node as loaded by FXMLLoader and the string.

The end result is quite pleasing.

Not being able to use the globalCache, I would have to resort to some kind of cache in a temp file system or reparse the fxml each time which doesn't seem very promising..

I don't fully understand why this wouldn't work. As far as I understand, the first macro call and all subsequent calls that assume a cache-hit are run in the same compilation run. The presentation compiler may be restarted between type-checking runs, but not 'in the middle'. So at first glance, this should work.

iulian

Rodrigo Cano

unread,
Sep 11, 2012, 1:21:40 PM9/11/12
to scala-i...@googlegroups.com
I thought the same, but using context.echo's, I outputted whatever there was in the cache, and nothing was in it.

Anyway, the version of the IDE in use is (a real PITA to copy paste):
2.1.0.nightly-2_10-201208280319-529cd70
and sbt is mainstream 0.12.

Anyway, it should be easy to reproduce, just declare two macros, the first puts something int the cache, and the second one tries to use it.

It could be that I'm doing something wrong, since I'm just learning macros, but from sbt it works fine..

Thanks for the attention.

iulian dragos

unread,
Sep 11, 2012, 1:47:40 PM9/11/12
to scala-i...@googlegroups.com
On Tue, Sep 11, 2012 at 7:21 PM, Rodrigo Cano <ioni...@gmail.com> wrote:
I thought the same, but using context.echo's, I outputted whatever there was in the cache, and nothing was in it.

Anyway, the version of the IDE in use is (a real PITA to copy paste):

Yeah, it's better go to the Scala menu and choose "Report a bug".. it will allow you to copy-paste the relevant version numbers (in fact I know of no other way to actually copy a version number on the Eclipse platform..)

iulian

James Moore

unread,
Sep 11, 2012, 2:26:54 PM9/11/12
to scala-i...@googlegroups.com
On Tue, Sep 11, 2012 at 10:47 AM, iulian dragos <jagu...@gmail.com> wrote:
> Yeah, it's better go to the Scala menu and choose "Report a bug".. it will
> allow you to copy-paste the relevant version numbers (in fact I know of no
> other way to actually copy a version number on the Eclipse platform..)

On a mac:

Eclipse > About Eclipse > Installation details button > Configuration
> Copy to clipboard

Along with thousands of lines (8k or so for me) of useful config
information, you'll find things like:

org.scala-ide.sdt.feature (2.1.0.nightly-2_10-201209110310-d635441)
"Scala Plugin"

--
James Moore
ja...@restphone.com
http://blog.restphone.com/
http://www.linkedin.com/in/jamesmmooreiv

Rodrigo Cano

unread,
Sep 13, 2012, 11:25:36 AM9/13/12
to scala-i...@googlegroups.com
By the way, isn't it possible to extract the cache map before resetting the compiler, and set it into the new one?. I'm not sure the cache feature is replaceable, because even I/O would be undesirable in fast compilation (I'm thinking on serializing the processed xml tree), so ideally, I should process the XML once and leave its result processed somewhere no?.

Any solution that you can think of?

Thanks

Eugene Burmako

unread,
Sep 16, 2012, 5:25:29 AM9/16/12
to scala-i...@googlegroups.com
Rodrigo, I took some time to think about your problem and decided to remove caches from the macro API for now.

Unfortunately we don't have time to expose a decent caching API, and I would hate to release something half-baked that we're going to regret in a few months. In the meanwhile, you can emulate caching by using a, most likely weak, static map. If you need caching within a single compilation run, you could index that map by c.run.

Sorry to bring bad news, I'll try to fix this in one of the next point releases.

Eugene Burmako

unread,
Sep 16, 2012, 5:39:19 AM9/16/12
to scala-i...@googlegroups.com
Here's an issue I created to track progress on this: https://issues.scala-lang.org/browse/SI-6377

Rodrigo Cano

unread,
Sep 16, 2012, 2:28:19 PM9/16/12
to scala-i...@googlegroups.com
Eugene, thanks your time. Your conclusion is completely reasonable, I'll see how I can work around this. Nevertheless, good thing this popped up before the release :)

Cheers.
Reply all
Reply to author
Forward
0 new messages