[Kapt] Ensure flag names and default values are consistent

Group flag names and default values in one place to make the code easier
to read and prevent mistakes and inconsistencies.
This commit is contained in:
hungvietnguyen
2021-03-23 07:41:28 +00:00
committed by GitHub
parent 752be27557
commit 7c4225b9d1
2 changed files with 68 additions and 26 deletions
@@ -60,11 +60,8 @@ class KaptOptions(
val processingOptions: MutableMap<String, String> = mutableMapOf()
val javacOptions: MutableMap<String, String> = mutableMapOf()
val flags: MutableSet<KaptFlag> = mutableSetOf(
KaptFlag.USE_LIGHT_ANALYSIS,
KaptFlag.INCLUDE_COMPILE_CLASSPATH,
KaptFlag.KEEP_KDOC_COMMENTS_IN_STUBS
)
// Initialize this set with the flags that are enabled by default. This set may be changed later (with flags added or removed).
val flags: MutableSet<KaptFlag> = KaptFlag.values().filter { it.defaultValue }.toMutableSet()
var mode: AptMode = AptMode.WITH_COMPILATION
var detectMemoryLeaks: DetectMemoryLeaksMode = DetectMemoryLeaksMode.DEFAULT
@@ -104,19 +101,19 @@ interface KaptFlags {
}
}
enum class KaptFlag(val description: String) {
enum class KaptFlag(val description: String, val defaultValue: Boolean = false) {
SHOW_PROCESSOR_TIMINGS("Show processor time"),
VERBOSE("Verbose mode"),
INFO_AS_WARNINGS("Info as warnings"),
USE_LIGHT_ANALYSIS("Use light analysis"),
USE_LIGHT_ANALYSIS("Use light analysis", defaultValue = true),
CORRECT_ERROR_TYPES("Correct error types"),
DUMP_DEFAULT_PARAMETER_VALUES("Dump default parameter values"),
MAP_DIAGNOSTIC_LOCATIONS("Map diagnostic locations"),
STRICT("Strict mode"),
INCLUDE_COMPILE_CLASSPATH("Detect annotation processors in compile classpath"),
INCLUDE_COMPILE_CLASSPATH("Detect annotation processors in compile classpath", defaultValue = true),
INCREMENTAL_APT("Incremental annotation processing (apt mode)"),
STRIP_METADATA("Strip @Metadata annotations from stubs"),
KEEP_KDOC_COMMENTS_IN_STUBS("Keep KDoc comments in stubs")
KEEP_KDOC_COMMENTS_IN_STUBS("Keep KDoc comments in stubs", defaultValue = true),
;
}