Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

New option for Organize Imports to always omit/prepend the scala package #143

Merged
merged 1 commit into from

3 participants

@misto
Owner

The default value is set to false, but that's up for discussion, as is the naming of the setting in the UI.

Fixes #1001127

...tools/eclipse/refactoring/OrganizeImportsAction.scala
@@ -241,7 +241,13 @@ class OrganizeImportsAction extends RefactoringAction with ActionWithNoWizard {
val groups = getGroupsForProject(project).toList
- expandOrCollapse ::: List(wildcards, refactoring.SortImports, refactoring.GroupImports(groups))
+ val omitScalaPackage = if (shouldOmitScalaPackage(project)){
@dotta Owner
dotta added a note

maybe this should be renamed to scalaPackageStrategy? (I can't find a better name :( )

@misto Owner
misto added a note

Changed! It also fits better with the organizationStrategy above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@dotta
Owner

lgtm

@dotta
Owner

By the way, so awesome to see all these "nice to have" features getting into master so quickly! :)

@misto
Owner

I'm just trying to get my number of open bugs down before going on vacation ;-)

@misto
Owner

Sorry Jenkins, but you'll have to try again tomorrow when a fresh nightly build of scala-refactoring is available.

@misto
Owner

PLS REBUILD ALL

@dotta dotta merged commit d8de93d into scala-ide:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 5, 2012
  1. @misto
This page is out of date. Refresh to see the latest.
View
15 org.scala-ide.sdt.core/src/scala/tools/eclipse/properties/OrganizeImportsPreferences.scala
@@ -19,6 +19,7 @@ import scala.tools.eclipse.ScalaPlugin
import org.eclipse.jface.preference.RadioGroupFieldEditor
import org.eclipse.jface.preference.FieldEditor
import scala.tools.eclipse.util.Utils
+import org.eclipse.jface.preference.BooleanFieldEditor
@@ -130,6 +131,7 @@ class OrganizeImportsPreferencesPage extends PropertyPage with IWorkbenchPrefere
)
new RadioGroupFieldEditor(expandCollapseKey, "Multiple imports from the same package or type:", 1, options, parent, true) {
allEnableDisableControls += getRadioBoxControl(parent)
+ allEnableDisableControls ++= getRadioBoxControl(parent).getChildren
}
}
@@ -157,6 +159,12 @@ class OrganizeImportsPreferencesPage extends PropertyPage with IWorkbenchPrefere
}
}
}
+
+ fieldEditors += addNewFieldEditorWrappedInComposite(parent = control) { parent =>
+ new BooleanFieldEditor(omitScalaPackage, "Omit the scala package prefix", parent) {
+ allEnableDisableControls += getChangeControl(parent)
+ }
+ }
if (!isWorkbenchPage) {
val enabled = getPreferenceStore.getBoolean(USE_PROJECT_SPECIFIC_SETTINGS_KEY)
@@ -190,6 +198,8 @@ object OrganizeImportsPreferences extends Enumeration {
val groupsKey = PREFIX +".groups"
val wildcardsKey = PREFIX +".wildcards"
val expandCollapseKey = PREFIX +".expandcollapse"
+
+ val omitScalaPackage = PREFIX +".scalapackage"
private def getPreferenceStore(project: IProject): IPreferenceStore = {
val workspaceStore = ScalaPlugin.prefStore
@@ -203,6 +213,10 @@ object OrganizeImportsPreferences extends Enumeration {
getPreferenceStore(project).getString(groupsKey).split("\\$")
}
+ def shouldOmitScalaPackage(project: IProject) = {
+ getPreferenceStore(project).getBoolean(omitScalaPackage)
+ }
+
def getWildcardImportsForProject(project: IProject) = {
getPreferenceStore(project).getString(wildcardsKey).split("\\$")
}
@@ -223,6 +237,7 @@ class OrganizeImportsPreferencesInitializer extends AbstractPreferenceInitialize
Utils.tryExecute {
val node = new DefaultScope().getNode(ScalaPlugin.plugin.pluginId)
+ node.put(OrganizeImportsPreferences.omitScalaPackage, "false")
node.put(OrganizeImportsPreferences.groupsKey, "java$scala$org$com")
node.put(OrganizeImportsPreferences.wildcardsKey, "scalaz$scalaz.Scalaz")
node.put(OrganizeImportsPreferences.expandCollapseKey, OrganizeImportsPreferences.ExpandImports.toString)
View
10 org.scala-ide.sdt.core/src/scala/tools/eclipse/refactoring/OrganizeImportsAction.scala
@@ -20,7 +20,7 @@ import org.eclipse.jface.action.IAction
import org.eclipse.jface.window.Window
import scala.tools.eclipse.javaelements.{ScalaSourceFile, ScalaElement, LazyToplevelClass}
-import scala.tools.eclipse.properties.OrganizeImportsPreferences.{getWildcardImportsForProject, getOrganizeImportStrategy, getGroupsForProject, PreserveExistingGroups, ExpandImports, CollapseImports}
+import scala.tools.eclipse.properties.OrganizeImportsPreferences._
import scala.tools.refactoring.implementations.{OrganizeImports, AddImportStatement}
/**
@@ -241,7 +241,13 @@ class OrganizeImportsAction extends RefactoringAction with ActionWithNoWizard {
val groups = getGroupsForProject(project).toList
- expandOrCollapse ::: List(wildcards, refactoring.SortImports, refactoring.GroupImports(groups))
+ val scalaPackageStrategy = if (shouldOmitScalaPackage(project)){
+ refactoring.DropScalaPackage
+ } else {
+ refactoring.PrependScalaPackage
+ }
+
+ expandOrCollapse ::: List(scalaPackageStrategy, wildcards, refactoring.SortImports, refactoring.GroupImports(groups))
}
val deps = {
Something went wrong with that request. Please try again.