From 599438b54324985f9d009575fb1bfa9fc3933199 Mon Sep 17 00:00:00 2001 From: Martijn Hoekstra Date: Wed, 6 Nov 2019 12:25:46 +0100 Subject: [PATCH 1/2] allow printing of phases --- .../dotty/tools/dotc/config/CompilerCommand.scala | 14 +++++++++++--- .../dotty/tools/dotc/config/ScalaSettings.scala | 3 ++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/config/CompilerCommand.scala b/compiler/src/dotty/tools/dotc/config/CompilerCommand.scala index 8dcb7c78401b..f8a574e1032f 100644 --- a/compiler/src/dotty/tools/dotc/config/CompilerCommand.scala +++ b/compiler/src/dotty/tools/dotc/config/CompilerCommand.scala @@ -102,8 +102,8 @@ object CompilerCommand { } def isStandard(s: Setting[?]): Boolean = !isAdvanced(s) && !isPrivate(s) - def isAdvanced(s: Setting[?]): Boolean = s.name startsWith "-X" - def isPrivate(s: Setting[?]) : Boolean = s.name startsWith "-Y" + def isAdvanced(s: Setting[?]): Boolean = s.name.startsWith("-X") && s.name != "-X" + def isPrivate(s: Setting[?]) : Boolean = s.name.startsWith("-Y") && s.name != "-Y" /** Messages explaining usage and options */ def usageMessage = createUsageMsg("where possible standard", shouldExplain = false, isStandard) @@ -112,7 +112,14 @@ object CompilerCommand { def shouldStopWithInfo = { import settings._ - Set(help, Xhelp, Yhelp, showPlugins) exists (_.value) + Set(help, Xhelp, Yhelp, showPlugins, XshowPhases) exists (_.value) + } + + def phasesMessage: String = { + (new Compiler()).phases.map(phasegroup => { + if(phasegroup.length == 1) phasegroup.head.phaseName + else phasegroup.mkString("{", ", ", "}") + }).mkString("\n") } def infoMessage: String = { @@ -121,6 +128,7 @@ object CompilerCommand { else if (Xhelp.value) xusageMessage else if (Yhelp.value) yusageMessage else if (showPlugins.value) ctx.pluginDescriptions + else if (XshowPhases.value) phasesMessage else "" } diff --git a/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala b/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala index c52f7a231896..e748528e228f 100644 --- a/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala +++ b/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala @@ -76,7 +76,8 @@ class ScalaSettings extends Settings.SettingGroup { val XprintTypes: Setting[Boolean] = BooleanSetting("-Xprint-types", "Print tree types (debugging option).") val XprintDiff: Setting[Boolean] = BooleanSetting("-Xprint-diff", "Print changed parts of the tree since last print.") val XprintDiffDel: Setting[Boolean] = BooleanSetting("-Xprint-diff-del", "Print changed parts of the tree since last print including deleted parts.") - val XprintInline: Setting[Boolean] = BooleanSetting("-Xprint-inline", "Show where inlined code comes from") + val XprintInline: Setting[Boolean] = BooleanSetting("-Xprint-inline", "Show where inlined code comes from") + val XshowPhases: Setting[Boolean] = BooleanSetting("-Xprint-phases", "Print all compiler phases") val XprintSuspension: Setting[Boolean] = BooleanSetting("-Xprint-suspension", "Show when code is suspended until macros are compiled") val Xprompt: Setting[Boolean] = BooleanSetting("-Xprompt", "Display a prompt after each error (debugging option).") val XnoValueClasses: Setting[Boolean] = BooleanSetting("-Xno-value-classes", "Do not use value classes. Helps debugging.") From 22d8622f9c4267fd55ad6f5aa9ae615fc0eaabec Mon Sep 17 00:00:00 2001 From: Martijn Hoekstra Date: Wed, 6 Nov 2019 17:21:38 +0100 Subject: [PATCH 2/2] address PR feedback --- .../src/dotty/tools/dotc/config/CompilerCommand.scala | 8 ++++---- compiler/src/dotty/tools/dotc/config/ScalaSettings.scala | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/config/CompilerCommand.scala b/compiler/src/dotty/tools/dotc/config/CompilerCommand.scala index f8a574e1032f..eb17fbe376cd 100644 --- a/compiler/src/dotty/tools/dotc/config/CompilerCommand.scala +++ b/compiler/src/dotty/tools/dotc/config/CompilerCommand.scala @@ -116,10 +116,10 @@ object CompilerCommand { } def phasesMessage: String = { - (new Compiler()).phases.map(phasegroup => { - if(phasegroup.length == 1) phasegroup.head.phaseName - else phasegroup.mkString("{", ", ", "}") - }).mkString("\n") + (new Compiler()).phases.map { + case List(single) => single.phaseName + case more => more.map(_.phaseName).mkString("{", ", ", "}") + }.mkString("\n") } def infoMessage: String = { diff --git a/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala b/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala index e748528e228f..8b053263ed00 100644 --- a/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala +++ b/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala @@ -77,9 +77,9 @@ class ScalaSettings extends Settings.SettingGroup { val XprintDiff: Setting[Boolean] = BooleanSetting("-Xprint-diff", "Print changed parts of the tree since last print.") val XprintDiffDel: Setting[Boolean] = BooleanSetting("-Xprint-diff-del", "Print changed parts of the tree since last print including deleted parts.") val XprintInline: Setting[Boolean] = BooleanSetting("-Xprint-inline", "Show where inlined code comes from") - val XshowPhases: Setting[Boolean] = BooleanSetting("-Xprint-phases", "Print all compiler phases") val XprintSuspension: Setting[Boolean] = BooleanSetting("-Xprint-suspension", "Show when code is suspended until macros are compiled") val Xprompt: Setting[Boolean] = BooleanSetting("-Xprompt", "Display a prompt after each error (debugging option).") + val XshowPhases: Setting[Boolean] = BooleanSetting("-Xshow-phases", "Print all compiler phases") val XnoValueClasses: Setting[Boolean] = BooleanSetting("-Xno-value-classes", "Do not use value classes. Helps debugging.") val XreplLineWidth: Setting[Int] = IntSetting("-Xrepl-line-width", "Maximal number of columns per line for REPL output", 390) val XfatalWarnings: Setting[Boolean] = BooleanSetting("-Xfatal-warnings", "Fail the compilation if there are any warnings.")