Enhancements/Bugs

Here's a few things I've noticed. I'm posting here so everyone sees them but will create issues as well.

1) Given the following code:

package test
class ScalaTest {
}
object ScalaTest {
  def main(args: Array[String]) {
    println("Bla")
  }
}

If you create a run configuration it says that it can't find the test.ScalaTest. If you run this using 2.7.* scala, this is indeed the case. However, this bug seems to have been fixed in the latest 2.8 scala compiler and hence this warning message in idea is no longer required in 2.8 world.

2) 2.8 supports named parameters. Given this code:

package test
class ScalaTest {
  def outputInfo(width: Int, height: Int) {
    println("Width: " + width + "  Height: " + height)
  }
}
object ScalaTest {
  def main(args: Array[String]) {
    val scalaTest = new ScalaTest
    scalaTest.outputInfo(wi|    
  }
}

the cursor is at the red | , if I hit "Ctrl-Space" I would expect "width" to be given me as an option. It isn't currently.

3) When pulling something out of a map, idea doesn't know what type it is. Given the following code:

package test
class ScalaTest(val num: Int) {
  def printSomething(text: String) {
    println(text + " " + num)
  }
}
object ScalaTest {
  def main(args: Array[String]) {
    val map = Map(1 -> new ScalaTest(1))
    map(1).printSomething("Bla")
  }
}

if I do a "Find Usages" on the "printSomething" method in the class, it says there are no usages found. As you can see though, there is one usage after I've pulled the class out of the map. Related to this is after I type the dot in the code "map(1)." the choices that popup don't contain the "printSomething" method.

EDIT 1 ***********************

Here's another one:

4) Import says it is not being used when it is being used by an implicit conversion:

package test
object CollectionTest {
  import scala.collection.JavaConversions._
  import scala.collection.mutable.{Map => MMap}  
  def main(args: Array[String]) {
    val scalaMap = MMap(1 -> "one", 2 -> "two", 3 -> "three")
    println(scalaMap)

    val convertedJavaMap: java.util.Map[Int, String] = scalaMap
    println(convertedJavaMap)

    val convertedScalaMap: MMap[Int, String] = convertedJavaMap
    println(convertedScalaMap)
  }
}

EDIT 2 ***********************

Here's another one, and this bugs me a lot:

5) I have the scala-compiler.jar and the scala-library.jar installed as a library. No problems there although I would prefer to specify a scala SDK - but that's another thing. If I do a Ctrl-N and type in a scala class like "None", it shows up in the list and if I select it, it goes to the compiled class file as expected.

Now, if I add the scala-compiler-src.jar and scala-library-src.jar as sources to the library and then do another Ctrl-N, type in "None", two versions of this object appear. If I select either one I'm taken to the source file.

This doesn't happen with java classes/sources.

EDIT 3 ***********************

6) If a scala class extends a java interface but doesn't implement the method, it should be red underlined in the editor. The editor says everything is fine given the following code:

package test
class ImplementTest extends Comparable[ImplementTest] {
}

This doesn't complie. It would be good for it to be red underlined like in java world and then I can hit Alt-Enter and do a quick fix.

3 comments
Comment actions Permalink

Just want to say thanks before I leave for the weekend:

3) When pulling something out of a map, idea doesn't know what type it is.   ---------- FIXED

4) Import says it is not being used when it is being used by an implicit conversion ---------- FIXED


I've tested these and they work; this is great news. These two fixes allow me to be a lot more confident when refactoring and optimising imports.

...

0
Comment actions Permalink

It's Friday so I thought I would respond to my own email again!

Sometimes it is hard to understand what's happening when implicit conversions are used. Now that idea knows when implicits are being used maybe it can make things clearer for everyone.

Would it be possible to highlight (very slightly) when implicit conversions are at work right in the IDE at edit time?

Thanks, Nick.

0
Comment actions Permalink

I thought about this and question is how to highlight, becuase implicit conversions can be enclosed. But I'm open to any suggestion, before I'll find a way.

Best regards,
Alexander Podkhalyuzin.

0

Please sign in to leave a comment.