From ec58929e395f92d9c6e4fd1401aa7891ca432330 Mon Sep 17 00:00:00 2001 From: Ilya Chernikov Date: Thu, 5 Jul 2018 13:37:45 +0200 Subject: [PATCH] Allow multiple same jsr305 options in the command-line do not report duplicate jsr305 entries if options are the same --- .../kotlin/cli/common/arguments/Jsr305Parser.kt | 17 ++++++++++------- compiler/testData/cli/jvm/wrongXjsr305.args | 2 ++ compiler/testData/cli/jvm/wrongXjsr305.out | 1 - 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/Jsr305Parser.kt b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/Jsr305Parser.kt index f72fa5bfc10..ee728444e62 100644 --- a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/Jsr305Parser.kt +++ b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/Jsr305Parser.kt @@ -37,19 +37,21 @@ class Jsr305Parser(private val collector: MessageCollector) { item.startsWith("@") -> { val (name, state) = parseJsr305UserDefined(item) ?: return@forEach val current = userDefined[name] - if (current != null) { + if (current == null) { + userDefined[name] = state + } else if (current != state) { reportDuplicateJsr305("@$name:${current.description}", item) return@forEach } - userDefined[name] = state } item.startsWith("under-migration") -> { - if (migration != null) { + val state = parseJsr305UnderMigration(item) + if (migration == null) { + migration = state + } else if (migration != state) { reportDuplicateJsr305("under-migration:${migration?.description}", item) return@forEach } - - migration = parseJsr305UnderMigration(item) } item == "enable" -> { collector.report( @@ -61,11 +63,12 @@ class Jsr305Parser(private val collector: MessageCollector) { global = ReportLevel.STRICT } else -> { - if (global != null) { + if (global == null) { + global = ReportLevel.findByDescription(item) + } else if (global!!.description != item) { reportDuplicateJsr305(global!!.description, item) return@forEach } - global = ReportLevel.findByDescription(item) } } } diff --git a/compiler/testData/cli/jvm/wrongXjsr305.args b/compiler/testData/cli/jvm/wrongXjsr305.args index 1ba791849e4..4b99679d4d5 100644 --- a/compiler/testData/cli/jvm/wrongXjsr305.args +++ b/compiler/testData/cli/jvm/wrongXjsr305.args @@ -6,7 +6,9 @@ $TEMP_DIR$ -Xjsr305=@hello\:warning -Xjsr305=@hello\:warn -Xjsr305=@hello\:ignore +-Xjsr305=@hello\:warn -Xjsr305=strict -Xjsr305=ignore -Xjsr305=under-migration\:ignore -Xjsr305=under-migration\:strict +-Xjsr305=under-migration\:ignore diff --git a/compiler/testData/cli/jvm/wrongXjsr305.out b/compiler/testData/cli/jvm/wrongXjsr305.out index 78ec5fb7b0f..ecabf63ad1d 100644 --- a/compiler/testData/cli/jvm/wrongXjsr305.out +++ b/compiler/testData/cli/jvm/wrongXjsr305.out @@ -2,7 +2,6 @@ warning: option 'enable' for -Xjsr305 flag is deprecated. Please use 'strict' in error: unrecognized -Xjsr305 value: under-migration:stct error: unrecognized -Xjsr305 value: @hello:warning error: conflict duplicating -Xjsr305 value: @hello:warn, @hello:ignore -error: conflict duplicating -Xjsr305 value: strict, strict error: conflict duplicating -Xjsr305 value: strict, ignore error: conflict duplicating -Xjsr305 value: under-migration:ignore, under-migration:strict COMPILATION_ERROR