In the following code example when one tries to import the
this is the result:
This problem occurs only in a very specific situation. Not only there needs to be a closing parenthesis in a string after the definition of the class, there also has to be another definition between the class and the point where the import is added, in this case it is a simple object definition (comments/other imports don't seem to be a problem).
Another problem, which is probably related to this, occurs when the string with the parentheses is before the class definition:
In this case it is a compilation error anyway, but the result is even more awkward:
Regex
typeobject X
class Y {
")"
val r: Regex
}
this is the result:
import scala.util.matching.Regex
object X
(class Y {
")"
val r: Regex
}
This problem occurs only in a very specific situation. Not only there needs to be a closing parenthesis in a string after the definition of the class, there also has to be another definition between the class and the point where the import is added, in this case it is a simple object definition (comments/other imports don't seem to be a problem).
Another problem, which is probably related to this, occurs when the string with the parentheses is before the class definition:
object X
")"
class Y {
val r: Regex
}
In this case it is a compilation error anyway, but the result is even more awkward:
import scala.util.matching.Regex
object X
"
"
class Y {
val r: Regex
}
Leave a comment
on 2015-02-09 03:58 *
By piotr.kukielka113452
You can observe similar problem with opening parenthesis:
Importing LinkedHashSet in the code above (or using optimize imports feature) results in the following code:
object DummyObject
class WrongFormatting {
def importHere = LinkedHashSet("(")
()
}
Importing LinkedHashSet in the code above (or using optimize imports feature) results in the following code:
import scala.collection.mutable.LinkedHashSet
object DummyObject
class WrongFormatting {
def importHere = LinkedHashSet("(")
())
}
Ticket assignment reverted due to inactivity.
I've a fix for this, which is based on https://github.com/scala-ide/scala-refactoring/pull/93, in this branch: https://github.com/mlangc/scala-refactoring/tree/organize-imports-adds-opening-parenthesis-1002088
I'll create a PR as soon as the former PR is merged.
I'll create a PR as soon as the former PR is merged.
Except for
@sschaef: Would it be OK for you to move the non compiling example to another ticket, so that we can close this one after the PR is merged?
object X
")"
class Y {
val r: Regex
}
, which does not compile, this is fixed by https://github.com/scala-ide/scala-refactoring/pull/94.@sschaef: Would it be OK for you to move the non compiling example to another ticket, so that we can close this one after the PR is merged?
No file chosen
You have an empty file field. Please select or remove it.
Name | Size |
---|