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

0
26 comments

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.

0

Thanks for the reply, Jason. I realize that it's not something you can just snap your fingers and have done. I just wanted to point you at the news so that you were at least aware of it and could take it into consideration.

jzaugg@gmail.com wrote:

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


Although, I must say that I would prefer fidelity over features. Syntax error checking is pointless if it's wrong and very annoying to deal with in the editor when it tells me my code is wrong when it isn't.

Ciao,
Gordon

0

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

0
Avatar
Andrey Eremchenko

With current version of plugin there are no problems with this code:
IDEA-scala-highlight-errors.png

0

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

0

"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...

0

The latest version is 0.4.755. Versions after 0.4.735 will only work with IDEA 10.5 EAP, but you should be able to download the latest compatible version from the plugin manager. If not, get it from here: http://download.jetbrains.com/scala/scala-intellij-bin-0.4.735.zip

0

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

I can now code in my favoriate IDE again!  :)   

-Eric
-- In Jetbrains I trust

0

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

0

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.

0

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

0
Avatar
Maarten Hazewinkel

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.

0

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.

0

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 :)

0

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

0

Hi Jason,

How does the presentation compiler solve these issues?
(not sure if there's a short answer to this question)

-tt

0

Thank you very much for looking into this, Alex. Your efforts are greatly appreciated. :)

0

Are there any news on the presentation compiler investigation front?

0

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.
0

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.

0

Thanks for trying, Alex. If you think you have useful information about the failures, maybe you could file bugs or give that information back to the scala guys? Maybe they can fix it for 2.9.1.

0
Avatar
Eugene Vigdorchik

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.

0

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.

0
Avatar
Eugene Vigdorchik

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.

0
Avatar
Piotr Kolaczkowski

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.

0

Please sign in to leave a comment.