Skip to content

Commit

Permalink
Better handling of presentation compiler settings. Honors most settin…
Browse files Browse the repository at this point in the history
…gs now, including compiler plugins. Fixed #1000367.
  • Loading branch information
dragos committed Apr 13, 2011
1 parent c742b82 commit e936bf4
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 16 deletions.
Expand Up @@ -45,7 +45,7 @@ class ScalaProject(val underlying: IProject) {
try { try {
val settings = new Settings val settings = new Settings
settings.printtypes.tryToSet(Nil) settings.printtypes.tryToSet(Nil)
initialize(settings, _.name.startsWith("-Ypresentation")) initialize(settings, isPCSetting(settings))
Some(new ScalaPresentationCompiler(ScalaProject.this, settings)) Some(new ScalaPresentationCompiler(ScalaProject.this, settings))
} catch { } catch {
case ex @ MissingRequirementError(required) => case ex @ MissingRequirementError(required) =>
Expand All @@ -66,6 +66,25 @@ class ScalaProject(val underlying: IProject) {
} }
} }


/** Compiler settings that are honored by the presentation compiler. */
private def isPCSetting(settings: Settings): Set[Settings#Setting] = {
import settings.{ plugin => pluginSetting, _ }
Set(deprecation,
unchecked,
pluginOptions,
verbose,
Xexperimental,
future,
Xmigration28,
pluginSetting,
pluginsDir,
YpresentationDebug,
YpresentationVerbose,
YpresentationLog,
YpresentationReplay,
YpresentationDelay)
}

private var messageShowed = false private var messageShowed = false


private def failedCompilerInitialization(msg: String) { private def failedCompilerInitialization(msg: String) {
Expand Down
Expand Up @@ -21,14 +21,18 @@ trait EclipseSettings {
case setting : Settings#StringSetting => case setting : Settings#StringSetting =>
setting.name match { setting.name match {
case "-Ypresentation-log" | "-Ypresentation-replay" => case "-Ypresentation-log" | "-Ypresentation-replay" =>
println("setting a file setting") println("file setting for " + setting.name)
new FileSetting(setting) new FileSetting(setting)
case _ => case _ =>
println("plain old string setting " + setting.name) println("plain old string setting " + setting.name)
new StringSetting(setting) new StringSetting(setting)
} }
// case setting : Settings#PhasesSetting => new StringSetting(setting) // !!! // case setting : Settings#PhasesSetting => new StringSetting(setting) // !!!
case setting : Settings#MultiStringSetting => new MultiStringSetting(setting) case setting : Settings#MultiStringSetting =>
setting.name match {
case "-Xplugin" => new MultiFileSetting(setting)
case _ => new MultiStringSetting(setting)
}
case setting : Settings#ChoiceSetting => new ComboSetting(setting) case setting : Settings#ChoiceSetting => new ComboSetting(setting)
} }


Expand Down Expand Up @@ -215,23 +219,50 @@ trait EclipseSettings {
layout.widthHint = 200 layout.widthHint = 200
} }
control.setLayoutData(layout) control.setLayoutData(layout)
control.setMessage("Path is relative to the workspace")
control.addModifyListener(ModifyListenerSing) control.addModifyListener(ModifyListenerSing)
} }


def fileName() = { def isChanged = setting.value != fileName(control.getText)
import scala.tools.eclipse.ScalaPlugin
import java.io.File

val text = control.getText
if (text.nonEmpty && !text.startsWith(File.separator)) {
val workspacePath = ScalaPlugin.plugin.workspaceRoot.getLocation
workspacePath + java.io.File.separator + text
} else text
}

def isChanged = setting.value != fileName()
def reset() { control.setText(setting.default) } def reset() { control.setText(setting.default) }
def apply() { setting.value = fileName() } def apply() { setting.value = fileName(control.getText) }
}



class MultiFileSetting(setting: Settings#MultiStringSetting) extends EclipseSetting(setting) {
var control : Text = _
def createControl(page : Composite) {
control = new Text(page, SWT.SINGLE | SWT.BORDER)
control.setText(setting.value.mkString(", "))
var layout = data
if (setting.value.isEmpty) {
layout = new GridData()
layout.widthHint = 200
}
control.setLayoutData(layout)
control.setMessage("Path is relative to the workspace")
control.addModifyListener(ModifyListenerSing)
}

def fileNames() = {
control.getText().split(',').map(f => fileName(f.trim)).toList
}

override def isChanged = setting.value != fileNames()
override def reset() { control.setText("") }
override def apply() { setting.value = fileNames() }
}

def fileName(text: String) = {
import scala.tools.eclipse.ScalaPlugin
import java.io.File

if (text.nonEmpty && !text.startsWith(File.separator)) {
val workspacePath = ScalaPlugin.plugin.workspaceRoot.getLocation
workspacePath + java.io.File.separator + text
} else text
} }



} }

0 comments on commit e936bf4

Please sign in to comment.