diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckCLDR.java b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckCLDR.java index 3640f1bd7e1..edab700459c 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckCLDR.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckCLDR.java @@ -7,6 +7,7 @@ package org.unicode.cldr.test; +import com.google.common.collect.ComparisonChain; import com.google.common.collect.ImmutableSet; import com.ibm.icu.dev.util.ElapsedTimer; import com.ibm.icu.impl.Row.R3; @@ -763,6 +764,8 @@ protected boolean accept(List result) { cachedPossibleErrors.clear(); // call into the subclass handleSetCldrFileToCheck(this.cldrFileToCheck, cachedOptions, cachedPossibleErrors); + // all of these are entireLocale + cachedPossibleErrors.forEach(e -> e.setEntireLocale()); initted = true; } // unconditionally append all cached possible errors @@ -782,7 +785,7 @@ protected boolean accept(List result) { Options cachedOptions = null; /** Status value returned from check */ - public static class CheckStatus { + public static class CheckStatus implements Comparable { public static final Type alertType = Type.Comment, warningType = Type.Warning, errorType = Type.Error, @@ -1117,6 +1120,38 @@ public static boolean hasType(List result, Type type) { } return false; } + + /** + * @returns true if this status applies to the entire locale, not a single path + */ + public boolean isEntireLocale() { + return entireLocale; + } + + /** Mark this CheckStatus as isEntireLocale */ + CheckStatus setEntireLocale() { + entireLocale = true; + return this; + } + + private boolean entireLocale = false; + + @Override + public int compareTo(CheckStatus o) { + if (this == o) return 0; + return ComparisonChain.start() + .compare(getType(), o.getType()) + .compare(getSubtype(), o.getSubtype()) + .compare(getMessage(), o.getMessage()) + .result(); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o instanceof CheckStatus) return false; + return compareTo((CheckStatus) o) == 0; + } } public abstract static class SimpleDemo { @@ -1488,6 +1523,8 @@ public void handleCheckPossibleErrors( } } if (SHOW_TIMES) System.out.println("Overall: " + testOverallTime + ": {0}"); + // all of these are entire locale + possibleErrors.forEach(e -> e.setEntireLocale()); } public Matcher getFilter() { diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/test/ConsoleCheckCLDR.java b/tools/cldr-code/src/main/java/org/unicode/cldr/test/ConsoleCheckCLDR.java index f8924e8447f..eeefa83326c 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/test/ConsoleCheckCLDR.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/test/ConsoleCheckCLDR.java @@ -550,7 +550,6 @@ public static void main(String[] args) throws Throwable { return; // get out, it's an error. } - List result = new ArrayList<>(); Set paths = new TreeSet<>(); // CLDRFile.ldmlComparator); Map m = new TreeMap<>(); Map options = new HashMap<>(); @@ -653,40 +652,12 @@ public static void main(String[] args) throws Throwable { parent = new CLDRFile.TestUser(parent, user, isLanguageLocale); } } - // checkCldr.setCldrFileToCheck(file, new Options(options), result); subtotalCount.clear(); - for (Iterator it3 = result.iterator(); it3.hasNext(); ) { - CheckStatus status = it3.next(); - String statusString = status.toString(); // com.ibm.icu.impl.Utility.escape( - CheckStatus.Type statusType = status.getType(); + final Set possibleProblems = new TreeSet<>(); + possibleProblems.addAll(bundle.getPossibleProblems()); - if (errorsOnly) { - if (!statusType.equals(CheckStatus.errorType)) continue; - } - - if (subtypeFilter != null) { - if (!subtypeFilter.contains(status.getSubtype())) { - continue; - } - } - - if (checkOnSubmit) { - if (!status.isCheckOnSubmit() - || !statusType.equals(CheckStatus.errorType)) continue; - } - showValue( - file, - null, - localeID, - null, - null, - null, - null, - statusString, - status.getSubtype()); - } paths.clear(); CoverageInfo covInfo = cldrConf.getCoverageInfo(); @@ -796,6 +767,7 @@ public static void main(String[] args) throws Throwable { } int limit = 1; for (int jj = 0; jj < limit; ++jj) { + final List result = new ArrayList<>(); if (jj == 0) { bundle.check(path, result, value); } else { @@ -805,6 +777,10 @@ public static void main(String[] args) throws Throwable { boolean showedOne = false; for (Iterator it3 = result.iterator(); it3.hasNext(); ) { CheckStatus status = it3.next(); + if (status.isEntireLocale()) { + possibleProblems.add(status); + continue; + } String statusString = status.toString(); // com.ibm.icu.impl.Utility.escape( CheckStatus.Type statusType = status.getType(); @@ -890,6 +866,42 @@ public static void main(String[] args) throws Throwable { } } + // handle possibleProblems (non path-based errors) + { + for (Iterator it3 = possibleProblems.iterator(); + it3.hasNext(); ) { + CheckStatus status = it3.next(); + String statusString = + status.toString(); // com.ibm.icu.impl.Utility.escape( + CheckStatus.Type statusType = status.getType(); + + if (errorsOnly) { + if (!statusType.equals(CheckStatus.errorType)) continue; + } + + if (subtypeFilter != null) { + if (!subtypeFilter.contains(status.getSubtype())) { + continue; + } + } + + if (checkOnSubmit) { + if (!status.isCheckOnSubmit() + || !statusType.equals(CheckStatus.errorType)) continue; + } + showValue( + file, + null, + localeID, + null, + null, + null, + null, + statusString, + status.getSubtype()); + } + } + if (resolveVotesDirectory != null) { LocaleVotingData.resolveErrors(localeID); }