26 Replies Last post: May 16, 2011 9:20 PM by Piotr Kolaczkowski  
Gordon Tyler Apprentice 797 posts since
Aug 20, 2002
Currently Being Moderated

Mar 30, 2011 6:12 PM

Latest Scala IDE for Eclipse uses new compiler interface

I just read the announcement about the new version of the Scala IDE for Eclipse and it mentions that it's based on a new compiler interface that has substantially improved its equivalent of type-aware highlighting and code navigation. Would the IDEA Scala plugin be able to take advantage of this new compiler interface instead of essentially re-implementing the Scala compiler internally?

 

http://www.scala-lang.org/node/8990

 

Ciao,

Gordon

Jason Zaugg Novice 106 posts since
Oct 20, 2009
Currently Being Moderated
Mar 31, 2011 11:15 AM in response to: Gordon Tyler
Re: Latest Scala IDE for Eclipse uses new compiler interface

As much has been suggested a few times, we've even left this ticket open to keep us open to the possibility: http://youtrack.jetbrains.net/issue/SCL-2708?query=scalac+type

 

But it's a fundamental change, would take a lot of effort, and might end up with fewer features (although better fidelity).

 

A lot of the smarts of IntelliJ come from being able to type programs in spite of syntax errors, and I'm not sure how far scalac has progressed in this regard.

 

Scala might expose some of the compiler internals, for example tp1 <:< tp2, in a future version of the standard libary as part of a reflection package. This would open up interesting possibilities for reuse.

Eric Hubbard Newbie 5 posts since
Oct 18, 2002
Currently Being Moderated
Apr 1, 2011 2:10 AM in response to: Gordon Tyler
Re: Latest Scala IDE for Eclipse uses new compiler interface

I have to agree on fidelity.  Scala is a fairly new language to me -- and if I use intellij I get great autocomplete -- and completely uselss syntax highlighting.

 

object hmm {

 

def main(args: Array[String]) {

     val f = new File(args(0)) ///   intellij says the 0 is red...

     val a = new Array[String](100)

    a(100) = "fred" // again intelllij highlights the 100 in red

    (1 to 100) aspar foreach (println) //  and in this case intellij FAILS to mark aspar red . desipte it not being defined on the sequence

  }

}

 

 

If I go over to Eclipse... it works perfectly.   Of course... intellij is more polished and the auto-complete features (even in scala) work better.. but... when I'm learning a new language.. those red wavvy lines are so so critical...

 

-Eric

Andrey Eremchenko Newbie 16 posts since
Oct 18, 2009
Currently Being Moderated
Apr 1, 2011 3:44 PM in response to: Eric Hubbard
Re: Latest Scala IDE for Eclipse uses new compiler interface

With current version of plugin there are no problems with this code:

IDEA-scala-highlight-errors.png

Taras Tielkes Apprentice 1,028 posts since
Oct 20, 2002
Currently Being Moderated
Apr 1, 2011 9:09 PM in response to: Eric Hubbard
Re: Latest Scala IDE for Eclipse uses new compiler interface

Just as Andrey, I don't see the false positives or negatives that you report.

Have you enabled type-aware highlighting? How is the scala library/compile configured?

 

Most likely there is some issue in the configuration of your module or project.

All the features you're asking for are implemented as expected, and have been working for quite a long time.

 

-tt

Eric Hubbard Newbie 5 posts since
Oct 18, 2002
Currently Being Moderated
Apr 1, 2011 9:59 PM in response to: Taras Tielkes
Re: Latest Scala IDE for Eclipse uses new compiler interface

"Just as Andrey, I don't see the false positives or negatives that you report.

Have you enabled type-aware highlighting? How is the scala library/compile configured?

 

Most likely there is some issue in the configuration of your module or project.

All the features you're asking for are implemented as expected, and have been working for quite a long time."

 

oo... it would be great if this worked for me.    This is exciting that it works for you guys.  Lets start with the basics..

 

1)  did I plug it in?  yes.. I did... just being silly

2)  Type-aware highlighting?  <--- woa!  whats that? where is it?  I'm clicking around and can't find it  -- I checked the facet configuration for scala within project structure... and scala compiler within  settings

3)  I'm using plugin verison.....0.4.589

 

  Perhaps I just need to grab the latest bits manually?  I had assumed that updating from the plugin manager would give me the latest and greatest...

 

Eric Hubbard Newbie 5 posts since
Oct 18, 2002
Currently Being Moderated
Apr 1, 2011 10:18 PM in response to: Eric Hubbard
Re: Latest Scala IDE for Eclipse uses new compiler interface

*blush*  okay that is embarassing..   It looks much better now...:)

 

I can now code in my favoriate IDE again!    

 

-Eric

-- In Jetbrains I trust

Taras Tielkes Apprentice 1,028 posts since
Oct 20, 2002
Currently Being Moderated
Apr 2, 2011 12:25 AM in response to: Eric Hubbard
Re: Latest Scala IDE for Eclipse uses new compiler interface

Good

Eric Hubbard Newbie 5 posts since
Oct 18, 2002
Currently Being Moderated
Apr 2, 2011 12:35 AM in response to: Taras Tielkes
Re: Latest Scala IDE for Eclipse uses new compiler interface

I also went ahead and moved to 10.5 to get that nifty type stuff... so far so good.  Thanks again!  

Alexander Podkhalyuzin JetBrains 1,101 posts since
Jun 7, 2008
Currently Being Moderated
Apr 7, 2011 8:46 PM in response to: Gordon Tyler
Re: Latest Scala IDE for Eclipse uses new compiler interface

I think I'll add support of Scala 2.9 presentation compiler. Anyway I think it's good idea to try.

 

Best regards,

Alexander Podkhalyuzin.

Eric Hubbard Newbie 5 posts since
Oct 18, 2002
Currently Being Moderated
Apr 7, 2011 8:48 PM in response to: Alexander Podkhalyuzin
Re: Latest Scala IDE for Eclipse uses new compiler interface

... another approach would be to use both...  the intellij method for refactorings..etc.. and the scala compiler method for syntax/type errors...

Maarten Hazewinkel Novice 246 posts since
Feb 19, 2003
Currently Being Moderated
Apr 8, 2011 9:55 AM in response to: Eric Hubbard
Re: Latest Scala IDE for Eclipse uses new compiler interface

That does not seem like a very good idea to me, at least not as a starting principle.

 

If you're going to start using the presentation compiler for this, use it for everything that it can deliver. Use your own code to augment it only where it doesn't delivere the information you need (and file an enhancement requests on the presentation compiler for that information as well).

 

In situations like this I rather strongly believe that you're better of with 1 source of truth than with 2 sources of truth that could end up in conflict.

 

Anyhow, at this point it sounds more like Alexander is going testing to see if the presentation compiler can work at all for this plugin, so there's no need for definitive decisions until the test results are in.

I hope Alexander will post the results of his experiment to the forum.

Alexander Podkhalyuzin JetBrains 1,101 posts since
Jun 7, 2008
Currently Being Moderated
Apr 22, 2011 12:02 PM in response to: Maarten Hazewinkel
Re: Latest Scala IDE for Eclipse uses new compiler interface

I implemented some support of presentation compiler. It works ok now, except two bugs (which I found in presentation compiler). It now works in very simple way, like in Eclipse (I mean highlighting).

Now I need more work to add features like Add Import, Unused Imports etc. (after that I'll update plugin with this optional feature).

Then I'll think about everything from presentation compiler. But I'm not sure what way will be chosen.

 

Best regards,

Alexander Podkhalyuzin.

Jason Zaugg Novice 106 posts since
Oct 20, 2009
Currently Being Moderated
Apr 22, 2011 1:02 PM in response to: Alexander Podkhalyuzin
Re: Latest Scala IDE for Eclipse uses new compiler interface

This is very interesting news -- there are some aspects of Scala that really stretch the currenct approach. For example, find-usages for apply/update/unapply/implicit views isn't possible without typing the whole program; our approach to expected types breaks down when there are apply/update methods involved; method type argument inference is problematic; higher-kinded types, etc, etc.

 

I think that a hybrid approach will be needed, stitching the two views of the program together will be the fun part

Taras Tielkes Apprentice 1,028 posts since
Oct 20, 2002
Currently Being Moderated
Apr 22, 2011 9:41 PM in response to: Jason Zaugg
Re: Latest Scala IDE for Eclipse uses new compiler interface

Hi Jason,

 

How does the presentation compiler solve these issues?

(not sure if there's a short answer to this question)

 

-tt

Eric Hubbard Newbie 16 posts since
Sep 8, 2008
Currently Being Moderated
Apr 22, 2011 7:41 PM in response to: Alexander Podkhalyuzin
Re: Latest Scala IDE for Eclipse uses new compiler interface

Thanks for looking into this approach.  The effort is much appreciated!

Thomas Vultura Newbie 61 posts since
Feb 12, 2010
Currently Being Moderated
May 10, 2011 11:30 AM in response to: Gordon Tyler
Re: Latest Scala IDE for Eclipse uses new compiler interface

Are there any news on the presentation compiler investigation front?

Alexander Podkhalyuzin JetBrains 1,101 posts since
Jun 7, 2008
Currently Being Moderated
May 10, 2011 12:13 PM in response to: Thomas Vultura
Re: Latest Scala IDE for Eclipse uses new compiler interface

I can't to stabilize presentation compiler, It fails often (I'm sure I can fix it from IDE side by often rerunning compiler, but I'm really not sure this is right). So I think we can wait until presentation compiler (2.9.1?) will be faster and until it will highlight more error types than now (and I hope more stable than now and obviously if plugin still be in such state with many "good code is red"). Sorry that I haven't met expectation.

 

Anyway I think I'll do a branch with current changes of presentation compiler using; so you will be able to try.

 

Best regards,

Alexander Podkhalyuzin.

Thomas Vultura Newbie 61 posts since
Feb 12, 2010
Currently Being Moderated
May 10, 2011 3:43 PM in response to: Alexander Podkhalyuzin
Re: Latest Scala IDE for Eclipse uses new compiler interface

There's no reason for being sorry. After all you've looked into it and made a decision about how to efficiently distribute your resources. If the presentation compiler isn't stable enough there's no point in spending too much work on it.

 

Maybe one should think about whether it will be used in the future. And based on this decision delay complicated features that can be easily handled by it, thus reducing the duplicate work as much as possible.

 

And thanks for making your efforts public. I've thought about looking into the plugin source several times. Maybe I'll use this occasion for it.

Eugene Vigdorchik Newbie 20 posts since
Jun 10, 2008
Currently Being Moderated
May 10, 2011 10:36 PM in response to: Alexander Podkhalyuzin
Re: Latest Scala IDE for Eclipse uses new compiler interface

Hi Alex,
Sorry to hear that IntelliJ failed to incorporate the presentation compiler. Eclipse is currently stable and doesn't require presentation compiler restart. So something might be different/not following PC invariants from IntelliJ side.

Alexander Podkhalyuzin JetBrains 1,101 posts since
Jun 7, 2008
Currently Being Moderated
May 11, 2011 12:11 PM in response to: Eugene Vigdorchik
Re: Latest Scala IDE for Eclipse uses new compiler interface

I know that Eclipse uses presentation compiler and it's almost stable (I got an error once, after which compiler was broken completely, but I can't reproduce it again:( ). I think the same thing for NetBeans and Emacs.

I was near to commit my changes to trunk, when I got FreashRunReq outside of compiler thread exception again (after this exception compiler can't restart automatically). I mean that presenation compiler still has task queue problems, which cause this exception.

I don't know really how to fix it from IDEA side except to handle stdout about FreshRunReq and to restart presentation compiler (maybe can help some mystical sleep or to change API calls order).

Presentation Compiler is really good idea, but now I think that it's better to wait more complete Presentation Compiler work.

 

Best regards,

Alexander Podkhalyuzin.

Eugene Vigdorchik Newbie 20 posts since
Jun 10, 2008
Currently Being Moderated
May 11, 2011 12:33 PM in response to: Alexander Podkhalyuzin
Re: Latest Scala IDE for Eclipse uses new compiler interface

Well, if you think the compiler has problems, why  don't you write the test that demonstrates the problem? Otherwise I don't think there's going to be any activity on the presentation compiler front in future releases.

Piotr Kolaczkowski Newbie 27 posts since
Jul 11, 2009
Currently Being Moderated
May 16, 2011 9:20 PM in response to: Eugene Vigdorchik
Re: Latest Scala IDE for Eclipse uses new compiler interface

BTW: Just to check, I enabled the type-aware highligting in the recent nightly build of the Scala plugin and in half of my files I see code in red (ofc, the code compiles).

It seems the plugin has still some problems with generic types. So, at least for me, current highlighting is still not quite useful, and I'm really eager to see if the presentation compiler can fix this.

More Like This

  • Retrieving data ...