Explicit Api mode: prototype with check for missing explicit visibility
Add cli flag with 3-state switch
This commit is contained in:
+12
@@ -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()}"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user