Organize Imports doesn't handle "package { }"
Actions.scala:
When referencing Action in another file and doing Ctrl+Shift+O to Organize Imports, it will try adding com.example.app.Action rather than com.example.app.actions.Action.
Scala plugin version: 2.0.0.nightly-2_09-201109292035-e7cf23a
Eclipse version: 3.7.1.v201109091335
package com.example.app
package actions {
class Action
}
When referencing Action in another file and doing Ctrl+Shift+O to Organize Imports, it will try adding com.example.app.Action rather than com.example.app.actions.Action.
Scala plugin version: 2.0.0.nightly-2_09-201109292035-e7cf23a
Eclipse version: 3.7.1.v201109091335
Leave a comment
on 2011-11-25 10:16 *
By Mirko Stocker
I'm sorry but I cannot reproduce this. Is the file where you do the organize imports a Java or Scala file? (I tried it with both, and it works fine).
Pure Scala. I can reproduce it even with everything in one source file. e.g.
Organize Imports adds "import com.example.app.Dao".
The behaviour seems to depend on the location of the file. If this file is in src/com/example/app, you get the behaviour described. If it's just in src/, Organize Imports does nothing. If it's in src/cakes, then "import cakes.Dao" is added. So when a class is in package{} it seems to be using the directory structure, which I understand s irrelevant for Scala packages.
package com.example.app
class MyApp(val dao:Dao)
package data {
class Dao
}
Organize Imports adds "import com.example.app.Dao".
The behaviour seems to depend on the location of the file. If this file is in src/com/example/app, you get the behaviour described. If it's just in src/, Organize Imports does nothing. If it's in src/cakes, then "import cakes.Dao" is added. So when a class is in package{} it seems to be using the directory structure, which I understand s irrelevant for Scala packages.
Oh, with a single source file I can reproduce it too.
on 2011-11-25 16:49 *
By Mirko Stocker
So the problem is that we use the JDT's
SearchEngine
to search for all types that match Dao
(in ScalaQuickFixProcessor#suggestImportType), and the search returns the wrong information that Dao's
fully qualified name is xy.Dao
. Maybe a bug in the structure builder?
on 2011-11-25 16:51 *
By Mirko Stocker
Assigned to changed from Mirko Stocker to -none-
Component changed from Eclipse to JDT integration
Seems to be fixed. Can't reproduce anymore.