Skip to content

Commit 599438b

Browse files
allow printing of phases
1 parent 6337a93 commit 599438b

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(phasegroup => {
120+
if(phasegroup.length == 1) phasegroup.head.phaseName
121+
else phasegroup.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,7 +76,8 @@ 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")
80+
val XshowPhases: Setting[Boolean] = BooleanSetting("-Xprint-phases", "Print all compiler phases")
8081
val XprintSuspension: Setting[Boolean] = BooleanSetting("-Xprint-suspension", "Show when code is suspended until macros are compiled")
8182
val Xprompt: Setting[Boolean] = BooleanSetting("-Xprompt", "Display a prompt after each error (debugging option).")
8283
val XnoValueClasses: Setting[Boolean] = BooleanSetting("-Xno-value-classes", "Do not use value classes. Helps debugging.")

0 commit comments

Comments
 (0)