Skip to content

Commit e936bf4

Browse files
committed
Better handling of presentation compiler settings. Honors most settings now, including compiler plugins. Fixed #1000367.
1 parent c742b82 commit e936bf4

File tree

2 files changed

+66
-16
lines changed

2 files changed

+66
-16
lines changed

org.scala-ide.sdt.core/src/scala/tools/eclipse/ScalaProject.scala

Lines changed: 20 additions & 1 deletion
Original file line numberOriginal file lineDiff line numberDiff line change
@@ -45,7 +45,7 @@ class ScalaProject(val underlying: IProject) {
45
try {
45
try {
46
val settings = new Settings
46
val settings = new Settings
47
settings.printtypes.tryToSet(Nil)
47
settings.printtypes.tryToSet(Nil)
48-
initialize(settings, _.name.startsWith("-Ypresentation"))
48+
initialize(settings, isPCSetting(settings))
49
Some(new ScalaPresentationCompiler(ScalaProject.this, settings))
49
Some(new ScalaPresentationCompiler(ScalaProject.this, settings))
50
} catch {
50
} catch {
51
case ex @ MissingRequirementError(required) =>
51
case ex @ MissingRequirementError(required) =>
@@ -66,6 +66,25 @@ class ScalaProject(val underlying: IProject) {
66
}
66
}
67
}
67
}
68

68

69+
/** Compiler settings that are honored by the presentation compiler. */
70+
private def isPCSetting(settings: Settings): Set[Settings#Setting] = {
71+
import settings.{ plugin => pluginSetting, _ }
72+
Set(deprecation,
73+
unchecked,
74+
pluginOptions,
75+
verbose,
76+
Xexperimental,
77+
future,
78+
Xmigration28,
79+
pluginSetting,
80+
pluginsDir,
81+
YpresentationDebug,
82+
YpresentationVerbose,
83+
YpresentationLog,
84+
YpresentationReplay,
85+
YpresentationDelay)
86+
}
87+
69
private var messageShowed = false
88
private var messageShowed = false
70

89

71
private def failedCompilerInitialization(msg: String) {
90
private def failedCompilerInitialization(msg: String) {

org.scala-ide.sdt.core/src/scala/tools/eclipse/properties/EclipseSettings.scala

Lines changed: 46 additions & 15 deletions
Original file line numberOriginal file lineDiff line numberDiff line change
@@ -21,14 +21,18 @@ trait EclipseSettings {
21
case setting : Settings#StringSetting =>
21
case setting : Settings#StringSetting =>
22
setting.name match {
22
setting.name match {
23
case "-Ypresentation-log" | "-Ypresentation-replay" =>
23
case "-Ypresentation-log" | "-Ypresentation-replay" =>
24-
println("setting a file setting")
24+
println("file setting for " + setting.name)
25
new FileSetting(setting)
25
new FileSetting(setting)
26
case _ =>
26
case _ =>
27
println("plain old string setting " + setting.name)
27
println("plain old string setting " + setting.name)
28
new StringSetting(setting)
28
new StringSetting(setting)
29
}
29
}
30
// case setting : Settings#PhasesSetting => new StringSetting(setting) // !!!
30
// case setting : Settings#PhasesSetting => new StringSetting(setting) // !!!
31-
case setting : Settings#MultiStringSetting => new MultiStringSetting(setting)
31+
case setting : Settings#MultiStringSetting =>
32+
setting.name match {
33+
case "-Xplugin" => new MultiFileSetting(setting)
34+
case _ => new MultiStringSetting(setting)
35+
}
32
case setting : Settings#ChoiceSetting => new ComboSetting(setting)
36
case setting : Settings#ChoiceSetting => new ComboSetting(setting)
33
}
37
}
34

38

@@ -215,23 +219,50 @@ trait EclipseSettings {
215
layout.widthHint = 200
219
layout.widthHint = 200
216
}
220
}
217
control.setLayoutData(layout)
221
control.setLayoutData(layout)
222+
control.setMessage("Path is relative to the workspace")
218
control.addModifyListener(ModifyListenerSing)
223
control.addModifyListener(ModifyListenerSing)
219
}
224
}
220

225

221-
def fileName() = {
226+
def isChanged = setting.value != fileName(control.getText)
222-
import scala.tools.eclipse.ScalaPlugin
223-
import java.io.File
224-
225-
val text = control.getText
226-
if (text.nonEmpty && !text.startsWith(File.separator)) {
227-
val workspacePath = ScalaPlugin.plugin.workspaceRoot.getLocation
228-
workspacePath + java.io.File.separator + text
229-
} else text
230-
}
231-
232-
def isChanged = setting.value != fileName()
233
def reset() { control.setText(setting.default) }
227
def reset() { control.setText(setting.default) }
234-
def apply() { setting.value = fileName() }
228+
def apply() { setting.value = fileName(control.getText) }
229+
}
230+
231+
232+
233+
class MultiFileSetting(setting: Settings#MultiStringSetting) extends EclipseSetting(setting) {
234+
var control : Text = _
235+
def createControl(page : Composite) {
236+
control = new Text(page, SWT.SINGLE | SWT.BORDER)
237+
control.setText(setting.value.mkString(", "))
238+
var layout = data
239+
if (setting.value.isEmpty) {
240+
layout = new GridData()
241+
layout.widthHint = 200
242+
}
243+
control.setLayoutData(layout)
244+
control.setMessage("Path is relative to the workspace")
245+
control.addModifyListener(ModifyListenerSing)
246+
}
247+
248+
def fileNames() = {
249+
control.getText().split(',').map(f => fileName(f.trim)).toList
250+
}
251+
252+
override def isChanged = setting.value != fileNames()
253+
override def reset() { control.setText("") }
254+
override def apply() { setting.value = fileNames() }
255+
}
256+
257+
def fileName(text: String) = {
258+
import scala.tools.eclipse.ScalaPlugin
259+
import java.io.File
260+
261+
if (text.nonEmpty && !text.startsWith(File.separator)) {
262+
val workspacePath = ScalaPlugin.plugin.workspaceRoot.getLocation
263+
workspacePath + java.io.File.separator + text
264+
} else text
235
}
265
}
236

266

267+
237
}
268
}

0 commit comments

Comments
 (0)