Skip to content

Commit 51f3487

Browse files
Merge pull request #12751 from lrytz/vwxy
Align compiler options to VWXY scheme
2 parents a059dbc + da3dae8 commit 51f3487

File tree

9 files changed

+137
-89
lines changed

9 files changed

+137
-89
lines changed

community-build/src/scala/dotty/communitybuild/projects.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -357,8 +357,8 @@ object projects:
357357
lazy val stdLib213 = SbtCommunityProject(
358358
project = "stdLib213",
359359
extraSbtArgs = List("-Dscala.build.compileWithDotty=true"),
360-
sbtTestCommand = """library/compile""",
361-
sbtPublishCommand = """set library/Compile/packageDoc/publishArtifact := false; library/publishLocal""",
360+
sbtTestCommand = """set Global / fatalWarnings := false; library/compile""",
361+
sbtPublishCommand = """set Global / fatalWarnings := false; set library/Compile/packageDoc/publishArtifact := false; library/publishLocal""",
362362
// sbtDocCommand = "library/doc" // Does no compile? No idea :/
363363
)
364364

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

+19-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import Settings._
77
import core.Contexts._
88
import Properties._
99

10-
import scala.collection.JavaConverters._
10+
import scala.PartialFunction.cond
11+
import scala.collection.JavaConverters._
1112

1213
trait CliCommand:
1314

@@ -107,7 +108,7 @@ trait CliCommand:
107108
// For now, skip the default values that do not make sense for the end user.
108109
// For example 'false' for the version command.
109110
""
110-
s"${formatName(s.name)} ${formatDescription(s.description)}${formatSetting("Default", defaultValue)}${formatSetting("Choices", s.legalChoices)}"
111+
s"${formatName(s.name)} ${formatDescription(shortHelp(s))}${formatSetting("Default", defaultValue)}${formatSetting("Choices", s.legalChoices)}"
111112
ss.map(helpStr).mkString("", "\n", s"\n${formatName("@<file>")} ${formatDescription("A text file containing compiler arguments (options and source files).")}\n")
112113
end availableOptionsMsg
113114

@@ -123,15 +124,30 @@ trait CliCommand:
123124
prefix + "\n" + availableOptionsMsg(cond)
124125

125126
protected def isStandard(s: Setting[?])(using settings: ConcreteSettings)(using SettingsState): Boolean =
126-
!isAdvanced(s) && !isPrivate(s)
127+
!isVerbose(s) && !isWarning(s) && !isAdvanced(s) && !isPrivate(s) || s.name == "-Werror" || s.name == "-Wconf"
128+
protected def isVerbose(s: Setting[?])(using settings: ConcreteSettings)(using SettingsState): Boolean =
129+
s.name.startsWith("-V") && s.name != "-V"
130+
protected def isWarning(s: Setting[?])(using settings: ConcreteSettings)(using SettingsState): Boolean =
131+
s.name.startsWith("-W") && s.name != "-W" || s.name == "-Xlint"
127132
protected def isAdvanced(s: Setting[?])(using settings: ConcreteSettings)(using SettingsState): Boolean =
128133
s.name.startsWith("-X") && s.name != "-X"
129134
protected def isPrivate(s: Setting[?])(using settings: ConcreteSettings)(using SettingsState): Boolean =
130135
s.name.startsWith("-Y") && s.name != "-Y"
136+
protected def shortHelp(s: Setting[?])(using settings: ConcreteSettings)(using SettingsState): String =
137+
s.description.linesIterator.next()
138+
protected def isHelping(s: Setting[?])(using settings: ConcreteSettings)(using SettingsState): Boolean =
139+
cond(s.value) {
140+
case ss: List[?] if s.isMultivalue => ss.contains("help")
141+
case s: String => "help" == s
142+
}
131143

132144
/** Messages explaining usage and options */
133145
protected def usageMessage(using settings: ConcreteSettings)(using SettingsState) =
134146
createUsageMsg("where possible standard", shouldExplain = false, isStandard)
147+
protected def vusageMessage(using settings: ConcreteSettings)(using SettingsState) =
148+
createUsageMsg("Possible verbose", shouldExplain = true, isVerbose)
149+
protected def wusageMessage(using settings: ConcreteSettings)(using SettingsState) =
150+
createUsageMsg("Possible warning", shouldExplain = true, isWarning)
135151
protected def xusageMessage(using settings: ConcreteSettings)(using SettingsState) =
136152
createUsageMsg("Possible advanced", shouldExplain = true, isAdvanced)
137153
protected def yusageMessage(using settings: ConcreteSettings)(using SettingsState) =

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

+5-1
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,15 @@ abstract class CompilerCommand extends CliCommand:
1414

1515
final def helpMsg(using settings: ScalaSettings)(using SettingsState, Context): String =
1616
if (settings.help.value) usageMessage
17+
else if (settings.Vhelp.value) vusageMessage
18+
else if (settings.Whelp.value) wusageMessage
1719
else if (settings.Xhelp.value) xusageMessage
1820
else if (settings.Yhelp.value) yusageMessage
1921
else if (settings.showPlugins.value) ctx.base.pluginDescriptions
2022
else if (settings.XshowPhases.value) phasesMessage
2123
else ""
2224

2325
final def isHelpFlag(using settings: ScalaSettings)(using SettingsState): Boolean =
24-
Set(settings.help, settings.Xhelp, settings.Yhelp, settings.showPlugins, settings.XshowPhases) exists (_.value)
26+
import settings._
27+
val flags = Set(help, Vhelp, Whelp, Xhelp, Yhelp, showPlugins, XshowPhases)
28+
flags.exists(_.value) || allSettings.exists(isHelping)

0 commit comments

Comments
 (0)