Skip to content

Commit 3128591

Browse files
authored
Merge pull request #7508 from martijnhoekstra/options
Adds -Xprint-phases
2 parents f4847fc + 22d8622 commit 3128591

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

compiler/src/dotty/tools/dotc/config/CompilerCommand.scala

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ object CompilerCommand {
102102
}
103103

104104
def isStandard(s: Setting[?]): Boolean = !isAdvanced(s) && !isPrivate(s)
105-
def isAdvanced(s: Setting[?]): Boolean = s.name startsWith "-X"
106-
def isPrivate(s: Setting[?]) : Boolean = s.name startsWith "-Y"
105+
def isAdvanced(s: Setting[?]): Boolean = s.name.startsWith("-X") && s.name != "-X"
106+
def isPrivate(s: Setting[?]) : Boolean = s.name.startsWith("-Y") && s.name != "-Y"
107107

108108
/** Messages explaining usage and options */
109109
def usageMessage = createUsageMsg("where possible standard", shouldExplain = false, isStandard)
@@ -112,7 +112,14 @@ object CompilerCommand {
112112

113113
def shouldStopWithInfo = {
114114
import settings._
115-
Set(help, Xhelp, Yhelp, showPlugins) exists (_.value)
115+
Set(help, Xhelp, Yhelp, showPlugins, XshowPhases) exists (_.value)
116+
}
117+
118+
def phasesMessage: String = {
119+
(new Compiler()).phases.map {
120+
case List(single) => single.phaseName
121+
case more => more.map(_.phaseName).mkString("{", ", ", "}")
122+
}.mkString("\n")
116123
}
117124

118125
def infoMessage: String = {
@@ -121,6 +128,7 @@ object CompilerCommand {
121128
else if (Xhelp.value) xusageMessage
122129
else if (Yhelp.value) yusageMessage
123130
else if (showPlugins.value) ctx.pluginDescriptions
131+
else if (XshowPhases.value) phasesMessage
124132
else ""
125133
}
126134

compiler/src/dotty/tools/dotc/config/ScalaSettings.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,10 @@ class ScalaSettings extends Settings.SettingGroup {
7676
val XprintTypes: Setting[Boolean] = BooleanSetting("-Xprint-types", "Print tree types (debugging option).")
7777
val XprintDiff: Setting[Boolean] = BooleanSetting("-Xprint-diff", "Print changed parts of the tree since last print.")
7878
val XprintDiffDel: Setting[Boolean] = BooleanSetting("-Xprint-diff-del", "Print changed parts of the tree since last print including deleted parts.")
79-
val XprintInline: Setting[Boolean] = BooleanSetting("-Xprint-inline", "Show where inlined code comes from")
79+
val XprintInline: Setting[Boolean] = BooleanSetting("-Xprint-inline", "Show where inlined code comes from")
8080
val XprintSuspension: Setting[Boolean] = BooleanSetting("-Xprint-suspension", "Show when code is suspended until macros are compiled")
8181
val Xprompt: Setting[Boolean] = BooleanSetting("-Xprompt", "Display a prompt after each error (debugging option).")
82+
val XshowPhases: Setting[Boolean] = BooleanSetting("-Xshow-phases", "Print all compiler phases")
8283
val XnoValueClasses: Setting[Boolean] = BooleanSetting("-Xno-value-classes", "Do not use value classes. Helps debugging.")
8384
val XreplLineWidth: Setting[Int] = IntSetting("-Xrepl-line-width", "Maximal number of columns per line for REPL output", 390)
8485
val XfatalWarnings: Setting[Boolean] = BooleanSetting("-Xfatal-warnings", "Fail the compilation if there are any warnings.")

0 commit comments

Comments
 (0)