Allow multiple same jsr305 options in the command-line

do not report duplicate jsr305 entries if options are the same
This commit is contained in:
Ilya Chernikov
2018-07-05 13:37:45 +02:00
parent 563e4c9e57
commit ec58929e39
3 changed files with 12 additions and 8 deletions
@@ -37,19 +37,21 @@ class Jsr305Parser(private val collector: MessageCollector) {
item.startsWith("@") -> { item.startsWith("@") -> {
val (name, state) = parseJsr305UserDefined(item) ?: return@forEach val (name, state) = parseJsr305UserDefined(item) ?: return@forEach
val current = userDefined[name] val current = userDefined[name]
if (current != null) { if (current == null) {
userDefined[name] = state
} else if (current != state) {
reportDuplicateJsr305("@$name:${current.description}", item) reportDuplicateJsr305("@$name:${current.description}", item)
return@forEach return@forEach
} }
userDefined[name] = state
} }
item.startsWith("under-migration") -> { 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) reportDuplicateJsr305("under-migration:${migration?.description}", item)
return@forEach return@forEach
} }
migration = parseJsr305UnderMigration(item)
} }
item == "enable" -> { item == "enable" -> {
collector.report( collector.report(
@@ -61,11 +63,12 @@ class Jsr305Parser(private val collector: MessageCollector) {
global = ReportLevel.STRICT global = ReportLevel.STRICT
} }
else -> { else -> {
if (global != null) { if (global == null) {
global = ReportLevel.findByDescription(item)
} else if (global!!.description != item) {
reportDuplicateJsr305(global!!.description, item) reportDuplicateJsr305(global!!.description, item)
return@forEach return@forEach
} }
global = ReportLevel.findByDescription(item)
} }
} }
} }
+2
View File
@@ -6,7 +6,9 @@ $TEMP_DIR$
-Xjsr305=@hello\:warning -Xjsr305=@hello\:warning
-Xjsr305=@hello\:warn -Xjsr305=@hello\:warn
-Xjsr305=@hello\:ignore -Xjsr305=@hello\:ignore
-Xjsr305=@hello\:warn
-Xjsr305=strict -Xjsr305=strict
-Xjsr305=ignore -Xjsr305=ignore
-Xjsr305=under-migration\:ignore -Xjsr305=under-migration\:ignore
-Xjsr305=under-migration\:strict -Xjsr305=under-migration\:strict
-Xjsr305=under-migration\:ignore
-1
View File
@@ -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: under-migration:stct
error: unrecognized -Xjsr305 value: @hello:warning error: unrecognized -Xjsr305 value: @hello:warning
error: conflict duplicating -Xjsr305 value: @hello:warn, @hello:ignore 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: strict, ignore
error: conflict duplicating -Xjsr305 value: under-migration:ignore, under-migration:strict error: conflict duplicating -Xjsr305 value: under-migration:ignore, under-migration:strict
COMPILATION_ERROR COMPILATION_ERROR