Explicit Api mode: prototype with check for missing explicit visibility

Add cli flag with 3-state switch
This commit is contained in:
Leonid Startsev
2019-05-24 15:18:23 +03:00
parent a7d60fbf2d
commit 7058492b55
10 changed files with 109 additions and 0 deletions
@@ -316,6 +316,14 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
@Argument(value = "-Xdisable-default-scripting-plugin", description = "Do not enable scripting plugin by default")
var disableDefaultScriptingPlugin: Boolean by FreezableVar(false)
@Argument(
value = "-Xapi-mode",
valueDescription = "{enable|disable|migration}",
description = "Enable api mode, force compiler to report errors an all public API declarations without explicit visibility.\n" +
"Use 'migration' level to issue warnings instead of errors."
)
var apiMode: String by FreezableVar(ApiMode.DISABLED.state)
open fun configureAnalysisFlags(collector: MessageCollector): MutableMap<AnalysisFlag<*>, Any> {
return HashMap<AnalysisFlag<*>, Any>().apply {
put(AnalysisFlags.skipMetadataVersionCheck, skipMetadataVersionCheck)
@@ -324,6 +332,10 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
put(AnalysisFlags.useExperimental, useExperimental?.toList().orEmpty())
put(AnalysisFlags.explicitApiVersion, apiVersion != null)
put(AnalysisFlags.allowResultReturnType, allowResultReturnType)
ApiMode.fromString(apiMode)?.also { put(AnalysisFlags.apiMode, it) } ?: collector.report(
CompilerMessageSeverity.ERROR,
"Unknown value for parameter -Xapi-mode: '$apiMode'. Value should be one of ${ApiMode.availableValues()}"
)
}
}