From ba7813b420519edf750bfc7fdfc80bd46ddf624b Mon Sep 17 00:00:00 2001 From: "Steven R. Loomis" Date: Tue, 19 Dec 2023 14:23:24 -0600 Subject: [PATCH 1/6] CLDR-17289 lazy setCldrFileToCheck: remove deprecated function - remove a deprecated overload of setCldrFileToCheck() --- .../java/org/unicode/cldr/test/CheckCLDR.java | 19 ------------------- .../org/unicode/cldr/tool/ConvertXTB.java | 2 +- .../org/unicode/cldr/tool/SearchCLDR.java | 2 +- 3 files changed, 2 insertions(+), 21 deletions(-) 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 d98b42a0a94..ec43d3d64a0 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 @@ -649,25 +649,6 @@ public final CLDRFile getCldrFileToCheck() { return cldrFileToCheck; } - /** - * Don't override this, use the other setCldrFileToCheck which takes an Options instead of a - * Map<> - * - * @param cldrFileToCheck - * @param options - * @param possibleErrors - * @return - * @see #setCldrFileToCheck(CLDRFile, Options, List) - * @deprecated - */ - @Deprecated - public final CheckCLDR setCldrFileToCheck( - CLDRFile cldrFileToCheck, - Map options, - List possibleErrors) { - return setCldrFileToCheck(cldrFileToCheck, new Options(options), possibleErrors); - } - /** * Set the CLDRFile. Must be done before calling check. If null is called, just skip Often * subclassed for initializing. If so, make the first 2 lines: if (cldrFileToCheck == null) diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/tool/ConvertXTB.java b/tools/cldr-code/src/main/java/org/unicode/cldr/tool/ConvertXTB.java index c113b70865d..62aee10f577 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/tool/ConvertXTB.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/tool/ConvertXTB.java @@ -469,7 +469,7 @@ private void check(XtbInfo xtbInfo) { } Map options = new HashMap<>(); List possibleErrors = new ArrayList<>(); - checkCldr.setCldrFileToCheck(cldrFile, options, possibleErrors); + checkCldr.setCldrFileToCheck(cldrFile, new CheckCLDR.Options(options), possibleErrors); for (CheckStatus status : possibleErrors) { System.out.println(locale + "\tLOCALE ERROR\t" + status.getMessage()); } diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/tool/SearchCLDR.java b/tools/cldr-code/src/main/java/org/unicode/cldr/tool/SearchCLDR.java index e2edd391dcc..3f4167c3386 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/tool/SearchCLDR.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/tool/SearchCLDR.java @@ -252,7 +252,7 @@ public static void main(String[] args) { int debug = 0; } result.clear(); - checkCldr.setCldrFileToCheck(resolvedFile, options, result); + checkCldr.setCldrFileToCheck(resolvedFile, new CheckCLDR.Options(options), result); } if (cldrDiffFactory != null) { From 0586fa8d36c2b43d5fc54fffe7b496ceb1efe170 Mon Sep 17 00:00:00 2001 From: "Steven R. Loomis" Date: Tue, 19 Dec 2023 15:07:18 -0600 Subject: [PATCH 2/6] CLDR-17289 lazy setCldrFileToCheck, add handleSetCldrFileToCheck - move all setCldrFileToCheck() functions to handleSetCldrFileToCheck(), which is shimmed from setCldrFileToCheck for now. --- .../java/org/unicode/cldr/test/CheckAlt.java | 4 ++-- .../unicode/cldr/test/CheckAttributeValues.java | 4 ++-- .../java/org/unicode/cldr/test/CheckCLDR.java | 17 +++++++++++------ .../java/org/unicode/cldr/test/CheckCasing.java | 4 ++-- .../org/unicode/cldr/test/CheckChildren.java | 4 ++-- .../cldr/test/CheckConsistentCasing.java | 4 ++-- .../org/unicode/cldr/test/CheckCoverage.java | 4 ++-- .../java/org/unicode/cldr/test/CheckDates.java | 4 ++-- .../cldr/test/CheckDisplayCollisions.java | 4 ++-- .../org/unicode/cldr/test/CheckExemplars.java | 4 ++-- .../org/unicode/cldr/test/CheckForCopy.java | 4 ++-- .../unicode/cldr/test/CheckForExemplars.java | 4 ++-- .../cldr/test/CheckLogicalGroupings.java | 4 ++-- .../java/org/unicode/cldr/test/CheckNew.java | 4 ++-- .../org/unicode/cldr/test/CheckNumbers.java | 4 ++-- .../org/unicode/cldr/test/CheckPersonNames.java | 4 ++-- .../unicode/cldr/test/CheckPlaceHolders.java | 4 ++-- .../java/org/unicode/cldr/test/CheckUnits.java | 4 ++-- .../java/org/unicode/cldr/test/CheckWidths.java | 4 ++-- .../java/org/unicode/cldr/test/CheckZones.java | 4 ++-- .../org/unicode/cldr/test/FactoryCheckCLDR.java | 4 ++-- .../org/unicode/cldr/util/VettingViewer.java | 2 +- 22 files changed, 52 insertions(+), 47 deletions(-) diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckAlt.java b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckAlt.java index 5aed63d39fc..292c80f7266 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckAlt.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckAlt.java @@ -48,7 +48,7 @@ public CheckCLDR handleCheck( } @Override - public CheckCLDR setCldrFileToCheck( + public CheckCLDR handleSetCldrFileToCheck( CLDRFile cldrFileToCheck, Options options, List possibleErrors) { if (cldrFileToCheck == null) return this; // Skip if the phase is not final testing @@ -59,7 +59,7 @@ public CheckCLDR setCldrFileToCheck( return this; } - super.setCldrFileToCheck(cldrFileToCheck, options, possibleErrors); + super.handleSetCldrFileToCheck(cldrFileToCheck, options, possibleErrors); seenSoFar.clear(); return this; } diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckAttributeValues.java b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckAttributeValues.java index 467fa30dc12..0aee3d6f553 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckAttributeValues.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckAttributeValues.java @@ -280,7 +280,7 @@ String getReplacement(String value, String attributeValue) { LocaleIDParser localeIDParser = new LocaleIDParser(); @Override - public CheckCLDR setCldrFileToCheck( + public CheckCLDR handleSetCldrFileToCheck( CLDRFile cldrFileToCheck, Options options, List possibleErrors) { if (cldrFileToCheck == null) return this; if (Phase.FINAL_TESTING == getPhase() || Phase.BUILD == getPhase()) { @@ -292,7 +292,7 @@ public CheckCLDR setCldrFileToCheck( pluralInfo = supplementalData.getPlurals(PluralType.cardinal, cldrFileToCheck.getLocaleID()); - super.setCldrFileToCheck(cldrFileToCheck, options, possibleErrors); + super.handleSetCldrFileToCheck(cldrFileToCheck, options, possibleErrors); isEnglish = "en".equals(localeIDParser.set(cldrFileToCheck.getLocaleID()).getLanguage()); synchronized (elementOrder) { if (!initialized) { 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 ec43d3d64a0..e258ecaff2a 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 @@ -652,13 +652,13 @@ public final CLDRFile getCldrFileToCheck() { /** * Set the CLDRFile. Must be done before calling check. If null is called, just skip Often * subclassed for initializing. If so, make the first 2 lines: if (cldrFileToCheck == null) - * return this; super.setCldrFileToCheck(cldrFileToCheck); do stuff + * return this; super.handleSetCldrFileToCheck(cldrFileToCheck); do stuff * * @param cldrFileToCheck * @param options (not currently used) * @param possibleErrors TODO */ - public CheckCLDR setCldrFileToCheck( + public CheckCLDR handleSetCldrFileToCheck( CLDRFile cldrFileToCheck, Options options, List possibleErrors) { this.cldrFileToCheck = cldrFileToCheck; @@ -678,6 +678,11 @@ public CheckCLDR setCldrFileToCheck( return this; } + public CheckCLDR setCldrFileToCheck( + CLDRFile cldrFileToCheck, Options options, List possibleErrors) { + return handleSetCldrFileToCheck(cldrFileToCheck, options, possibleErrors); + } + /** Status value returned from check */ public static class CheckStatus { public static final Type alertType = Type.Comment, @@ -1361,7 +1366,7 @@ private void addError(List result, CheckCLDR item, Exception e) { } @Override - public CheckCLDR setCldrFileToCheck( + public CheckCLDR handleSetCldrFileToCheck( CLDRFile cldrFileToCheck, Options options, List possibleErrors) { ElapsedTimer testTime = null, testOverallTime = null; if (cldrFileToCheck == null) return this; @@ -1369,7 +1374,7 @@ public CheckCLDR setCldrFileToCheck( setPhase(Phase.forString(options.get(Options.Option.phase))); if (SHOW_TIMES) testOverallTime = new ElapsedTimer("Test setup time for setCldrFileToCheck: {0}"); - super.setCldrFileToCheck(cldrFileToCheck, options, possibleErrors); + super.handleSetCldrFileToCheck(cldrFileToCheck, options, possibleErrors); possibleErrors.clear(); for (Iterator it = filteredCheckList.iterator(); it.hasNext(); ) { @@ -1380,7 +1385,7 @@ public CheckCLDR setCldrFileToCheck( "Test setup time for " + item.getClass().toString() + ": {0}"); try { item.setPhase(getPhase()); - item.setCldrFileToCheck(cldrFileToCheck, options, possibleErrors); + item.handleSetCldrFileToCheck(cldrFileToCheck, options, possibleErrors); if (SHOW_TIMES) { if (item.isSkipTest()) { System.out.println("Disabled : " + testTime); @@ -1408,7 +1413,7 @@ public CompoundCheckCLDR setFilter(Matcher filter) { CheckCLDR item = it.next(); if (filter == null || filter.reset(item.getClass().getName()).matches()) { filteredCheckList.add(item); - item.setCldrFileToCheck(getCldrFileToCheck(), (Options) null, null); + item.handleSetCldrFileToCheck(getCldrFileToCheck(), (Options) null, null); } } return this; diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckCasing.java b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckCasing.java index 652ae6cd926..fa3466f2d30 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckCasing.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckCasing.java @@ -29,10 +29,10 @@ public static Case forString(String input) { BreakIterator breaker = null; @Override - public CheckCLDR setCldrFileToCheck( + public CheckCLDR handleSetCldrFileToCheck( CLDRFile cldrFileToCheck, Options options, List possibleErrors) { if (cldrFileToCheck == null) return this; - super.setCldrFileToCheck(cldrFileToCheck, options, possibleErrors); + super.handleSetCldrFileToCheck(cldrFileToCheck, options, possibleErrors); uLocale = new ULocale(cldrFileToCheck.getLocaleID()); breaker = BreakIterator.getWordInstance(uLocale); return this; diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckChildren.java b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckChildren.java index 99bd685fbd4..4ddb43eaa32 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckChildren.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckChildren.java @@ -63,7 +63,7 @@ public CheckCLDR handleCheck( } @Override - public CheckCLDR setCldrFileToCheck( + public CheckCLDR handleSetCldrFileToCheck( CLDRFile cldrFileToCheck, Options options, List possibleErrors) { if (cldrFileToCheck == null) return this; if (cldrFileToCheck.getLocaleID().equals("root")) @@ -78,7 +78,7 @@ public CheckCLDR setCldrFileToCheck( } List iChildren = new ArrayList<>(); - super.setCldrFileToCheck(cldrFileToCheck, options, possibleErrors); + super.handleSetCldrFileToCheck(cldrFileToCheck, options, possibleErrors); CLDRLocale myLocale = CLDRLocale.getInstance(cldrFileToCheck.getLocaleID()); if (myLocale.getCountry() != null && myLocale.getCountry().length() == 2) { immediateChildren = null; diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckConsistentCasing.java b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckConsistentCasing.java index 523f8cd18c0..a4dcda3f920 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckConsistentCasing.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckConsistentCasing.java @@ -47,10 +47,10 @@ public CheckConsistentCasing(Factory factory) { } @Override - public CheckCLDR setCldrFileToCheck( + public CheckCLDR handleSetCldrFileToCheck( CLDRFile cldrFileToCheck, Options options, List possibleErrors) { if (cldrFileToCheck == null) return this; - super.setCldrFileToCheck(cldrFileToCheck, options, possibleErrors); + super.handleSetCldrFileToCheck(cldrFileToCheck, options, possibleErrors); locale = cldrFileToCheck.getLocaleID(); // get info about casing; note that this is done in two steps since // ScriptMetadata.getInfo() returns null, in some instances. diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckCoverage.java b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckCoverage.java index 92999cf6b69..ae3bb8171ea 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckCoverage.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckCoverage.java @@ -124,7 +124,7 @@ public CheckCLDR handleCheck( } @Override - public CheckCLDR setCldrFileToCheck( + public CheckCLDR handleSetCldrFileToCheck( CLDRFile cldrFileToCheck, Options options, List possibleErrors) { if (cldrFileToCheck == null) return this; setSkipTest(true); @@ -148,7 +148,7 @@ public CheckCLDR setCldrFileToCheck( } if (options != null && options.get(Options.Option.CheckCoverage_skip) != null) return this; - super.setCldrFileToCheck(cldrFileToCheck, options, possibleErrors); + super.handleSetCldrFileToCheck(cldrFileToCheck, options, possibleErrors); if (localeID.equals(LocaleNames.ROOT)) return this; requiredLevel = options.getRequiredLevel(localeID); diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckDates.java b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckDates.java index 21cf228ac84..007657dc192 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckDates.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckDates.java @@ -168,10 +168,10 @@ public CheckDates(Factory factory) { } @Override - public CheckCLDR setCldrFileToCheck( + public CheckCLDR handleSetCldrFileToCheck( CLDRFile cldrFileToCheck, Options options, List possibleErrors) { if (cldrFileToCheck == null) return this; - super.setCldrFileToCheck(cldrFileToCheck, options, possibleErrors); + super.handleSetCldrFileToCheck(cldrFileToCheck, options, possibleErrors); icuServiceBuilder.setCldrFile(getResolvedCldrFileToCheck()); // the following is a hack to work around a bug in ICU4J (the snapshot, not the released diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckDisplayCollisions.java b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckDisplayCollisions.java index 69014ceea11..2a7ca0afcd7 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckDisplayCollisions.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckDisplayCollisions.java @@ -804,10 +804,10 @@ private boolean isCodeFallback(String dpath) { // private Map nameToSubdivisionId = Collections.emptyMap(); @Override - public CheckCLDR setCldrFileToCheck( + public CheckCLDR handleSetCldrFileToCheck( CLDRFile cldrFileToCheck, Options options, List possibleErrors) { if (cldrFileToCheck == null) return this; - super.setCldrFileToCheck(cldrFileToCheck, options, possibleErrors); + super.handleSetCldrFileToCheck(cldrFileToCheck, options, possibleErrors); // pick up the 3 subdivisions // nameToSubdivisionId = // EmojiSubdivisionNames.getNameToSubdivisionPath(cldrFileToCheck.getLocaleID()); diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckExemplars.java b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckExemplars.java index 1da8fdd73d9..9998c60310d 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckExemplars.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckExemplars.java @@ -132,10 +132,10 @@ public CheckExemplars(Factory factory) { // Allowed[:script=common:][:script=inherited:][:alphabetic=false:] @Override - public CheckCLDR setCldrFileToCheck( + public CheckCLDR handleSetCldrFileToCheck( CLDRFile cldrFileToCheck, Options options, List possibleErrors) { if (cldrFileToCheck == null) return this; - super.setCldrFileToCheck(cldrFileToCheck, options, possibleErrors); + super.handleSetCldrFileToCheck(cldrFileToCheck, options, possibleErrors); String locale = cldrFileToCheck.getLocaleID(); isRoot = cldrFileToCheck.getLocaleID().equals("root"); col = ComparatorUtilities.getIcuCollator(new ULocale(locale), Collator.IDENTICAL); diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckForCopy.java b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckForCopy.java index 4de0d596f79..ac6df0364b6 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckForCopy.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckForCopy.java @@ -290,7 +290,7 @@ private void addFailure(List result, Failure failure) { } @Override - public CheckCLDR setCldrFileToCheck( + public CheckCLDR handleSetCldrFileToCheck( CLDRFile cldrFileToCheck, Options options, List possibleErrors) { if (cldrFileToCheck == null) { @@ -316,7 +316,7 @@ public CheckCLDR setCldrFileToCheck( return this; } - super.setCldrFileToCheck(cldrFileToCheck, options, possibleErrors); + super.handleSetCldrFileToCheck(cldrFileToCheck, options, possibleErrors); return this; } } diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckForExemplars.java b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckForExemplars.java index d67f147c7fe..c74c4aa0cb8 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckForExemplars.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckForExemplars.java @@ -185,11 +185,11 @@ public Set transform(String source) { } @Override - public CheckCLDR setCldrFileToCheck( + public CheckCLDR handleSetCldrFileToCheck( CLDRFile cldrFile, Options options, List possibleErrors) { if (cldrFile == null) return this; skip = true; - super.setCldrFileToCheck(cldrFile, options, possibleErrors); + super.handleSetCldrFileToCheck(cldrFile, options, possibleErrors); if (cldrFile.getLocaleID().equals("root")) { return this; } diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckLogicalGroupings.java b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckLogicalGroupings.java index cba03a6999b..a967c062303 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckLogicalGroupings.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckLogicalGroupings.java @@ -33,9 +33,9 @@ public CheckLogicalGroupings(Factory factory) { } @Override - public CheckCLDR setCldrFileToCheck( + public CheckCLDR handleSetCldrFileToCheck( CLDRFile cldrFileToCheck, Options options, List possibleErrors) { - super.setCldrFileToCheck(cldrFileToCheck, options, possibleErrors); + super.handleSetCldrFileToCheck(cldrFileToCheck, options, possibleErrors); // skip the test unless we are at the top level, eg // test root, fr, sr_Latn, ... diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckNew.java b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckNew.java index 67b23f9bb9a..f5c52a9815f 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckNew.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckNew.java @@ -18,12 +18,12 @@ public CheckNew(Factory factory) { } @Override - public CheckCLDR setCldrFileToCheck( + public CheckCLDR handleSetCldrFileToCheck( CLDRFile cldrFileToCheck, Options options, List possibleErrors) { if (cldrFileToCheck == null) { return this; } - super.setCldrFileToCheck(cldrFileToCheck, options, possibleErrors); + super.handleSetCldrFileToCheck(cldrFileToCheck, options, possibleErrors); isRoot = "root".equals(cldrFileToCheck.getLocaleID()); return this; diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckNumbers.java b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckNumbers.java index 31f38688cc2..2e2aba763dd 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckNumbers.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckNumbers.java @@ -84,10 +84,10 @@ public CheckNumbers(Factory factory) { * calling the super. */ @Override - public CheckCLDR setCldrFileToCheck( + public CheckCLDR handleSetCldrFileToCheck( CLDRFile cldrFileToCheck, Options options, List possibleErrors) { if (cldrFileToCheck == null) return this; - super.setCldrFileToCheck(cldrFileToCheck, options, possibleErrors); + super.handleSetCldrFileToCheck(cldrFileToCheck, options, possibleErrors); icuServiceBuilder.setCldrFile(getResolvedCldrFileToCheck()); isPOSIX = cldrFileToCheck.getLocaleID().indexOf("POSIX") >= 0; SupplementalDataInfo supplementalData = diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckPersonNames.java b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckPersonNames.java index 65194916e1b..39c8bc0c585 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckPersonNames.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckPersonNames.java @@ -52,7 +52,7 @@ public class CheckPersonNames extends CheckCLDR { new UnicodeSet("[\\p{sc=Kana}\\p{sc=Hira}]").addAll(HANI).freeze(); @Override - public CheckCLDR setCldrFileToCheck( + public CheckCLDR handleSetCldrFileToCheck( CLDRFile cldrFileToCheck, Options options, List possibleErrors) { String localeId = cldrFileToCheck.getLocaleID(); isRoot = localeId.equals("root"); @@ -72,7 +72,7 @@ public CheckCLDR setCldrFileToCheck( cldrFileToCheck .getStringValue("//ldml/personNames/nativeSpaceReplacement") .isEmpty(); - return super.setCldrFileToCheck(cldrFileToCheck, options, possibleErrors); + return super.handleSetCldrFileToCheck(cldrFileToCheck, options, possibleErrors); } public UnicodeSet getUnicodeSetForScript(String script) { diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckPlaceHolders.java b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckPlaceHolders.java index 90a79058800..ec60d2a82b3 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckPlaceHolders.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckPlaceHolders.java @@ -72,9 +72,9 @@ public class CheckPlaceHolders extends CheckCLDR { private Set allowedModifiers = null; @Override - public CheckCLDR setCldrFileToCheck( + public CheckCLDR handleSetCldrFileToCheck( CLDRFile cldrFileToCheck, Options options, List possibleErrors) { - super.setCldrFileToCheck(cldrFileToCheck, options, possibleErrors); + super.handleSetCldrFileToCheck(cldrFileToCheck, options, possibleErrors); allowedModifiers = Modifier.getAllowedModifiers(cldrFileToCheck.getLocaleID()); return this; } diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckUnits.java b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckUnits.java index ce08aa7fc61..79ac588010a 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckUnits.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckUnits.java @@ -24,9 +24,9 @@ public class CheckUnits extends CheckCLDR { private Collection genders = null; @Override - public CheckCLDR setCldrFileToCheck( + public CheckCLDR handleSetCldrFileToCheck( CLDRFile cldrFileToCheck, Options options, List possibleErrors) { - super.setCldrFileToCheck(cldrFileToCheck, options, possibleErrors); + super.handleSetCldrFileToCheck(cldrFileToCheck, options, possibleErrors); GrammarInfo grammarInfo = CLDRConfig.getInstance() diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckWidths.java b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckWidths.java index 395925b735e..0bb3414e924 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckWidths.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckWidths.java @@ -533,14 +533,14 @@ public CheckCLDR handleCheck( } @Override - public CheckCLDR setCldrFileToCheck( + public CheckCLDR handleSetCldrFileToCheck( CLDRFile cldrFileToCheck, Options options, List possibleErrors) { final String localeID = cldrFileToCheck.getLocaleID(); supplementalData = SupplementalDataInfo.getInstance(cldrFileToCheck.getSupplementalDirectory()); coverageLevel = CoverageLevel2.getInstance(supplementalData, localeID); - super.setCldrFileToCheck(cldrFileToCheck, options, possibleErrors); + super.handleSetCldrFileToCheck(cldrFileToCheck, options, possibleErrors); return this; } diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckZones.java b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckZones.java index 8f2f58563d2..6a15523ceea 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckZones.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckZones.java @@ -27,7 +27,7 @@ public CheckZones(Factory factory) { } @Override - public CheckCLDR setCldrFileToCheck( + public CheckCLDR handleSetCldrFileToCheck( CLDRFile cldrFile, Options options, List possibleErrors) { if (cldrFile == null) return this; // if (Phase.FINAL_TESTING == getPhase()) { @@ -37,7 +37,7 @@ public CheckCLDR setCldrFileToCheck( // return this; // } - super.setCldrFileToCheck(cldrFile, options, possibleErrors); + super.handleSetCldrFileToCheck(cldrFile, options, possibleErrors); try { timezoneFormatter = new TimezoneFormatter(getResolvedCldrFileToCheck()); } catch (RuntimeException e) { diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/test/FactoryCheckCLDR.java b/tools/cldr-code/src/main/java/org/unicode/cldr/test/FactoryCheckCLDR.java index 8a40bb071e0..0b7367ee9a0 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/test/FactoryCheckCLDR.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/test/FactoryCheckCLDR.java @@ -52,9 +52,9 @@ public CLDRFile getResolvedCldrFileToCheck() { } @Override - public CheckCLDR setCldrFileToCheck( + public CheckCLDR handleSetCldrFileToCheck( CLDRFile cldrFileToCheck, Options options, List possibleErrors) { - super.setCldrFileToCheck(cldrFileToCheck, options, possibleErrors); + super.handleSetCldrFileToCheck(cldrFileToCheck, options, possibleErrors); resolvedCldrFileToCheck = null; return this; } diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/util/VettingViewer.java b/tools/cldr-code/src/main/java/org/unicode/cldr/util/VettingViewer.java index d0e46c32ba6..9b81e7df7c3 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/util/VettingViewer.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/util/VettingViewer.java @@ -173,7 +173,7 @@ public Status initErrorStatus(CLDRFile cldrFile) { options = new HashMap<>(); result = new ArrayList<>(); checkCldr = CheckCLDR.getCheckAll(factory, ".*"); - checkCldr.setCldrFileToCheck(cldrFile, new Options(options), result); + checkCldr.handleSetCldrFileToCheck(cldrFile, new Options(options), result); return Status.ok; } From e2f262611532100fc1a67beddb27affbce5d06bd Mon Sep 17 00:00:00 2001 From: "Steven R. Loomis" Date: Tue, 19 Dec 2023 16:12:30 -0600 Subject: [PATCH 3/6] CLDR-17289 lazy setCldrFileToCheck, remove another deprecated fcn --- .../java/org/unicode/cldr/test/CheckCLDR.java | 27 ------------------- .../org/unicode/cldr/tool/ConvertXTB.java | 5 ++-- .../org/unicode/cldr/tool/SearchCLDR.java | 14 ++++++++-- .../unicode/cldr/unittest/TestCheckCLDR.java | 12 ++++----- .../unittest/TestCheckDisplayCollisions.java | 5 ++-- .../cldr/unittest/TestCheckNumbers.java | 4 +-- 6 files changed, 26 insertions(+), 41 deletions(-) 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 e258ecaff2a..2cbda5b4c92 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 @@ -1125,33 +1125,6 @@ public static void appendTitle(StringBuffer htmlMessage) { } } - /** - * Wraps the options in an Options and delegates. - * - * @param path Must be a distinguished path, such as what comes out of CLDRFile.iterator() - * @param fullPath Must be the full path - * @param value the value associated with the path - * @param options A set of test-specific options. Set these with code of the form:
- * options.put("CoverageLevel.localeType", "G0")
- * That is, the key is of the form ., and the value is of the form - * .
- * There is one general option; the following will select only the tests that should be run - * during this phase.
- * options.put("phase", Phase.); It can be used for new data entry. - * @param result - * @return - * @deprecated use CheckCLDR#check(String, String, String, Options, List) - */ - @Deprecated - public final CheckCLDR check( - String path, - String fullPath, - String value, - Map options, - List result) { - return check(path, fullPath, value, new Options(options), result); - } - /** * Checks the path/value in the cldrFileToCheck for correctness, according to some criterion. If * the path is relevant to the check, there is an alert or warning, then a CheckStatus is added diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/tool/ConvertXTB.java b/tools/cldr-code/src/main/java/org/unicode/cldr/tool/ConvertXTB.java index 62aee10f577..55ce86562ed 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/tool/ConvertXTB.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/tool/ConvertXTB.java @@ -17,6 +17,7 @@ import java.util.regex.Pattern; import org.unicode.cldr.test.CheckCLDR; import org.unicode.cldr.test.CheckCLDR.CheckStatus; +import org.unicode.cldr.test.CheckCLDR.CheckStatus.Type; import org.unicode.cldr.test.DisplayAndInputProcessor; import org.unicode.cldr.tool.Option.Options; import org.unicode.cldr.util.CLDRFile; @@ -478,7 +479,7 @@ private void check(XtbInfo xtbInfo) { String xpath = CLDRFile.getDistinguishingXPath(info.xpath, null); String fullPath = cldrFile.getFullXPath(xpath); String value = info.value; - checkCldr.check(xpath, fullPath, value, options, possibleErrors); + checkCldr.check(xpath, fullPath, value, new CheckCLDR.Options(options), possibleErrors); numErrors += displayErrors(locale, info.messageId, xpath, value, possibleErrors); } if (numErrors == 0) System.out.println("No errors found for " + locale); @@ -519,7 +520,7 @@ private int displayErrors( + status.getType() + "\t" + status.getMessage().replace('\t', ' ')); - if (status.getType().equals("Error")) { + if (status.getType().equals(Type.Error)) { numErrors++; } } diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/tool/SearchCLDR.java b/tools/cldr-code/src/main/java/org/unicode/cldr/tool/SearchCLDR.java index 3f4167c3386..a10791a185e 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/tool/SearchCLDR.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/tool/SearchCLDR.java @@ -331,7 +331,12 @@ public static void main(String[] args) { } result.clear(); - checkCldr.check(path, file.getFullXPath(path), value, options, result); + checkCldr.check( + path, + file.getFullXPath(path), + value, + new CheckCLDR.Options(options), + result); if (result.isEmpty()) { continue; } @@ -346,7 +351,12 @@ public static void main(String[] args) { } // for debugging int debug = 0; - checkCldr.check(path, file.getFullXPath(path), value, options, result); + checkCldr.check( + path, + file.getFullXPath(path), + value, + new CheckCLDR.Options(options), + result); } // made it through the sieve diff --git a/tools/cldr-code/src/test/java/org/unicode/cldr/unittest/TestCheckCLDR.java b/tools/cldr-code/src/test/java/org/unicode/cldr/unittest/TestCheckCLDR.java index a0e60f89b92..8383b596f1b 100644 --- a/tools/cldr-code/src/test/java/org/unicode/cldr/unittest/TestCheckCLDR.java +++ b/tools/cldr-code/src/test/java/org/unicode/cldr/unittest/TestCheckCLDR.java @@ -121,13 +121,13 @@ public static void TestCheckConsistentCasing() { Map options = new LinkedHashMap<>(); List possibleErrors = new ArrayList<>(); final CLDRFile english = testInfo.getEnglish(); - c.setCldrFileToCheck(english, options, possibleErrors); + c.setCldrFileToCheck(english, new CheckCLDR.Options(options), possibleErrors); for (String path : english) { c.check( path, english.getFullXPath(path), english.getStringValue(path), - options, + new CheckCLDR.Options(options), possibleErrors); } } @@ -595,7 +595,7 @@ void addExemplars( public void TestCheckNames() { CheckCLDR c = new CheckNames(); - Map options = new LinkedHashMap<>(); + Options options = new CheckCLDR.Options(new LinkedHashMap<>()); List possibleErrors = new ArrayList<>(); final CLDRFile english = testInfo.getEnglish(); c.setCldrFileToCheck(english, options, possibleErrors); @@ -652,7 +652,7 @@ public void checkCheckNew(String locale, String path, String expectedMessage) { CheckCLDR c = new CheckNew(testInfo.getCommonAndSeedAndMainAndAnnotationsFactory()); List result = new ArrayList<>(); - Map options = new HashMap<>(); + final CheckCLDR.Options options = new CheckCLDR.Options(new HashMap<>()); c.setCldrFileToCheck(testInfo.getCLDRFile(locale, true), options, result); c.check(path, path, "foobar", options, result); String actualMessage = ""; @@ -698,8 +698,8 @@ public void TestCheckNewRootFailure() { TestFactory currFactory = makeTestFactory(root, localeSource); CLDRFile cldrFile = currFactory.make(localeSource.getLocaleID(), true); - c.setCldrFileToCheck(cldrFile, options, result); - c.check(path, path, value, options, result); + c.setCldrFileToCheck(cldrFile, new CheckCLDR.Options(options), result); + c.check(path, path, value, new CheckCLDR.Options(options), result); boolean gotOne = false; for (CheckStatus status : result) { if (status.getSubtype() == Subtype.valueMustBeOverridden) { diff --git a/tools/cldr-code/src/test/java/org/unicode/cldr/unittest/TestCheckDisplayCollisions.java b/tools/cldr-code/src/test/java/org/unicode/cldr/unittest/TestCheckDisplayCollisions.java index d23bf840aa6..09cc8f1a22c 100644 --- a/tools/cldr-code/src/test/java/org/unicode/cldr/unittest/TestCheckDisplayCollisions.java +++ b/tools/cldr-code/src/test/java/org/unicode/cldr/unittest/TestCheckDisplayCollisions.java @@ -239,13 +239,14 @@ public void checkDisplayCollisions( cdc.setEnglishFile(CLDRConfig.getInstance().getEnglish()); List possibleErrors = new ArrayList<>(); - cdc.setCldrFileToCheck(factory.make(locale, true), ImmutableMap.of(), possibleErrors); + cdc.setCldrFileToCheck( + factory.make(locale, true), new Options(ImmutableMap.of()), possibleErrors); for (Entry entry : pathValuePairs.entrySet()) { cdc.check( entry.getKey(), entry.getKey(), entry.getValue(), - ImmutableMap.of(), + new Options(ImmutableMap.of()), possibleErrors); assertEquals(entry.toString(), Collections.emptyList(), possibleErrors); } diff --git a/tools/cldr-code/src/test/java/org/unicode/cldr/unittest/TestCheckNumbers.java b/tools/cldr-code/src/test/java/org/unicode/cldr/unittest/TestCheckNumbers.java index 7578ebf9aaa..cf2ab82e60b 100644 --- a/tools/cldr-code/src/test/java/org/unicode/cldr/unittest/TestCheckNumbers.java +++ b/tools/cldr-code/src/test/java/org/unicode/cldr/unittest/TestCheckNumbers.java @@ -3,7 +3,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -import java.util.Map; +import org.unicode.cldr.test.CheckCLDR; import org.unicode.cldr.test.CheckCLDR.CheckStatus; import org.unicode.cldr.test.CheckCLDR.CheckStatus.Subtype; import org.unicode.cldr.test.CheckCLDR.CheckStatus.Type; @@ -51,7 +51,7 @@ public void checkSingularity( xmlSource.setLocaleID(locale); CLDRFile cldrFileToCheck = new CLDRFile(xmlSource); - Map options = Collections.emptyMap(); + final CheckCLDR.Options options = new CheckCLDR.Options(Collections.emptyMap()); List possibleErrors = new ArrayList<>(); checkNumbers.setCldrFileToCheck(cldrFileToCheck, options, possibleErrors); assertEquals("setCldrFileToCheck", Collections.EMPTY_LIST, possibleErrors); From b8715a9c471142b519a137ffff59ff23f92bf13a Mon Sep 17 00:00:00 2001 From: "Steven R. Loomis" Date: Tue, 19 Dec 2023 17:42:30 -0600 Subject: [PATCH 4/6] CLDR-17289 lazy setCldrFileToCheck, first pass of adding accept() calls --- .../java/org/unicode/cldr/test/CheckAlt.java | 2 + .../org/unicode/cldr/test/CheckAltOnly.java | 1 + .../unicode/cldr/test/CheckAnnotations.java | 1 + .../cldr/test/CheckAttributeValues.java | 1 + .../java/org/unicode/cldr/test/CheckCLDR.java | 94 +++++++++++++++---- .../org/unicode/cldr/test/CheckCasing.java | 1 + .../org/unicode/cldr/test/CheckChildren.java | 3 +- .../cldr/test/CheckConsistentCasing.java | 1 + .../org/unicode/cldr/test/CheckCoverage.java | 4 +- .../unicode/cldr/test/CheckCurrencies.java | 2 +- .../org/unicode/cldr/test/CheckDates.java | 2 + .../cldr/test/CheckDisplayCollisions.java | 1 + .../org/unicode/cldr/test/CheckExemplars.java | 1 + .../org/unicode/cldr/test/CheckForCopy.java | 1 + .../unicode/cldr/test/CheckForExemplars.java | 1 + .../cldr/test/CheckForInheritanceMarkers.java | 1 + .../cldr/test/CheckLogicalGroupings.java | 1 + .../org/unicode/cldr/test/CheckMetazones.java | 1 + .../org/unicode/cldr/test/CheckNames.java | 1 + .../java/org/unicode/cldr/test/CheckNew.java | 1 + .../org/unicode/cldr/test/CheckNumbers.java | 3 + .../unicode/cldr/test/CheckPersonNames.java | 1 + .../unicode/cldr/test/CheckPlaceHolders.java | 2 + .../org/unicode/cldr/test/CheckQuotes.java | 2 + .../org/unicode/cldr/test/CheckUnits.java | 1 + .../org/unicode/cldr/test/CheckWidths.java | 1 + .../org/unicode/cldr/test/CheckZones.java | 5 +- 27 files changed, 111 insertions(+), 25 deletions(-) diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckAlt.java b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckAlt.java index 292c80f7266..226f84d8e36 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckAlt.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckAlt.java @@ -26,6 +26,8 @@ public CheckCLDR handleCheck( return this; } + if (!accept(result)) return this; + String strippedPath = CLDRFile.getNondraftNonaltXPath(path); if (strippedPath.equals(path)) { return this; // paths equal, skip diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckAltOnly.java b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckAltOnly.java index b573f576643..164b7fa2c1c 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckAltOnly.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckAltOnly.java @@ -40,6 +40,7 @@ public CheckCLDR handleCheck( if (file.getConstructedValue(nonAltPath) != null) { return this; } + if (!accept(result)) return this; /* * If the source locale is not code-fallback, it's not an error. * getSourceLocaleIdExtended with skipInheritanceMarker = false means that if the diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckAnnotations.java b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckAnnotations.java index 08510fdc8f9..7d346f33a9f 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckAnnotations.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckAnnotations.java @@ -18,6 +18,7 @@ public CheckCLDR handleCheck( || !getCldrFileToCheck().isNotRoot(path)) { return this; } + if (!accept(result)) return this; final String ecode = hasAnnotationECode(value); if (ecode != null) { diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckAttributeValues.java b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckAttributeValues.java index 0aee3d6f553..6b3c99805c8 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckAttributeValues.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckAttributeValues.java @@ -93,6 +93,7 @@ public CheckCLDR handleCheck( if (!getCldrFileToCheck().getLocaleID().equals(locale)) { return this; } + if (!accept(result)) return this; XPathParts parts = XPathParts.getFrozenInstance(fullPath); for (int i = 0; i < parts.size(); ++i) { if (parts.getAttributeCount(i) == 0) { 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 2cbda5b4c92..24d396b18ec 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 @@ -439,6 +439,7 @@ public Options() { public Options(Options options2) { this.options = Arrays.copyOf(options2.options, options2.options.length); this.key = options2.key; + this.locale = options2.locale; } public Options( @@ -650,17 +651,39 @@ public final CLDRFile getCldrFileToCheck() { } /** - * Set the CLDRFile. Must be done before calling check. If null is called, just skip Often - * subclassed for initializing. If so, make the first 2 lines: if (cldrFileToCheck == null) - * return this; super.handleSetCldrFileToCheck(cldrFileToCheck); do stuff + * Often subclassed for initializing. If so, make the first 2 lines: if (cldrFileToCheck == + * null) return this; super.handleSetCldrFileToCheck(cldrFileToCheck); do stuff + * + *

Called late via accept(). * * @param cldrFileToCheck - * @param options (not currently used) - * @param possibleErrors TODO + * @param options + * @param possibleErrors any deferred possibleErrors can be set here. They will be appended to + * every handleCheck() call. + * @return */ public CheckCLDR handleSetCldrFileToCheck( CLDRFile cldrFileToCheck, Options options, List possibleErrors) { + + // nothing by default + return this; + } + + /** + * Set the CLDRFile. Must be done before calling check. + * + * @param cldrFileToCheck + * @param options (not currently used) + * @param possibleErrors + */ + public CheckCLDR setCldrFileToCheck( + CLDRFile cldrFileToCheck, Options options, List possibleErrors) { this.cldrFileToCheck = cldrFileToCheck; + initted = false; + // clear the *cached* possible Errors. Not counting any set immediately by subclasses. + cachedPossibleErrors.clear(); + cachedOptions = new Options(options); + // we must load filters here, as they are used by check() // Shortlist error filters for this locale. loadFilters(); @@ -675,14 +698,52 @@ public CheckCLDR handleSetCldrFileToCheck( } xpaths.add(filter.get2()); } + + // hook for checks that want to set possibleErrors early + handleCheckPossibleErrors(cldrFileToCheck, options, possibleErrors); + return this; } - public CheckCLDR setCldrFileToCheck( + protected void handleCheckPossibleErrors( CLDRFile cldrFileToCheck, Options options, List possibleErrors) { - return handleSetCldrFileToCheck(cldrFileToCheck, options, possibleErrors); + // nothing by default. } + /** + * Subclasses must call this, after any skip calculation to indicate that an xpath is relevant + * to them. + * + * @param result out-parameter to contain any deferred errors + * @return false if test is skipped and should exit + */ + protected boolean accept(List result) { + if (!initted) { + if (this.cldrFileToCheck == null) { + throw new NullPointerException("accept() was called before setCldrFileToCheck()"); + } + // clear this again. + cachedPossibleErrors.clear(); + // call into the subclass + handleSetCldrFileToCheck(this.cldrFileToCheck, cachedOptions, cachedPossibleErrors); + initted = true; + } + // unconditionally append all cached possible errors + result.addAll(cachedPossibleErrors); + if (isSkipTest()) { + return false; + } + return true; + } + + /** has accept() been called since setCldrFileToCheck() was called? */ + boolean initted = false; + + /** cache of possible errors, for handleSetCldrFileToCheck */ + List cachedPossibleErrors = new ArrayList<>(); + + Options cachedOptions = null; + /** Status value returned from check */ public static class CheckStatus { public static final Type alertType = Type.Comment, @@ -1212,9 +1273,10 @@ protected CheckCLDR handleGetExamples( } /** - * This is what the subclasses override. If they ever use pathParts or fullPathParts, they need - * to call initialize() with the respective path. Otherwise they must NOT change pathParts or - * fullPathParts. + * This is what the subclasses override. + * + *

If a path is not applicable, exit early with return this; Once a path is + * applicable, call accept(result); to add deferred possible problems. * *

If something is found, a CheckStatus is added to result. This can be done multiple times * in one call, if multiple errors or warnings are found. The CheckStatus may return warnings, @@ -1227,8 +1289,6 @@ protected CheckCLDR handleGetExamples( * .setType(CheckStatus.errorType) * .setMessage("Value should be {0}", new Object[] { pattern })); * - * - * @param options TODO */ public abstract CheckCLDR handleCheck( String path, String fullPath, String value, Options options, List result); @@ -1267,6 +1327,9 @@ public CheckCLDR handleCheck( Options options, List result) { result.clear(); + + if (!accept(result)) return this; + // If we're being asked to run tests for an inheritance marker, then we need to change // it // to the "real" value first before running tests. Testing the value @@ -1339,15 +1402,15 @@ private void addError(List result, CheckCLDR item, Exception e) { } @Override - public CheckCLDR handleSetCldrFileToCheck( + public void handleCheckPossibleErrors( CLDRFile cldrFileToCheck, Options options, List possibleErrors) { ElapsedTimer testTime = null, testOverallTime = null; - if (cldrFileToCheck == null) return this; + if (cldrFileToCheck == null) return; boolean SHOW_TIMES = options.contains(Options.Option.SHOW_TIMES); setPhase(Phase.forString(options.get(Options.Option.phase))); if (SHOW_TIMES) testOverallTime = new ElapsedTimer("Test setup time for setCldrFileToCheck: {0}"); - super.handleSetCldrFileToCheck(cldrFileToCheck, options, possibleErrors); + super.handleCheckPossibleErrors(cldrFileToCheck, options, possibleErrors); possibleErrors.clear(); for (Iterator it = filteredCheckList.iterator(); it.hasNext(); ) { @@ -1372,7 +1435,6 @@ public CheckCLDR handleSetCldrFileToCheck( } } if (SHOW_TIMES) System.out.println("Overall: " + testOverallTime + ": {0}"); - return this; } public Matcher getFilter() { diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckCasing.java b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckCasing.java index fa3466f2d30..c7adff47949 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckCasing.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckCasing.java @@ -46,6 +46,7 @@ public CheckCLDR handleCheck( if (fullPath == null) return this; // skip paths that we don't have if (fullPath.indexOf("casing") < 0) return this; + if (!accept(result)) return this; // pick up the casing attributes from the full path XPathParts parts = XPathParts.getFrozenInstance(fullPath); diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckChildren.java b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckChildren.java index 4ddb43eaa32..5b770e822a3 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckChildren.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckChildren.java @@ -23,14 +23,13 @@ public CheckChildren(Factory factory) { public CheckCLDR handleCheck( String path, String fullPath, String value, Options options, List result) { if (immediateChildren == null) return this; // skip - test isn't even relevant - if (isSkipTest()) return this; // disabled if (fullPath == null) return this; // skip paths that we don't have if (value == null) return this; // skip null values String winningValue = this.getCldrFileToCheck().getWinningValue(fullPath); if (!value.equals(winningValue)) { return this; // only run this test against winning values. } - + if (!accept(result)) return this; // String current = getResolvedCldrFileToCheck().getStringValue(path); tempSet.clear(); for (int i = 0; i < immediateChildren.length; ++i) { diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckConsistentCasing.java b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckConsistentCasing.java index a4dcda3f920..e5743ed4c63 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckConsistentCasing.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckConsistentCasing.java @@ -89,6 +89,7 @@ public CheckCLDR handleCheck( String path, String fullPath, String value, Options options, List result) { // it helps performance to have a quick reject of most paths if (fullPath == null) return this; // skip paths that we don't have + if (!accept(result)) return this; // causes hasCasingInfo to be calculated if (!hasCasingInfo) return this; String locale2 = getCldrFileToCheck().getSourceLocaleID(path, null); diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckCoverage.java b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckCoverage.java index ae3bb8171ea..a85603abd54 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckCoverage.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckCoverage.java @@ -53,9 +53,7 @@ public CheckCoverage(Factory factory) { public CheckCLDR handleCheck( String path, String fullPath, String value, Options options, List result) { - if (isSkipTest()) { - return this; - } + if (!accept(result)) return this; CLDRFile resolvedCldrFileToCheck = getResolvedCldrFileToCheck(); diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckCurrencies.java b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckCurrencies.java index 29620471258..07e3f4bce54 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckCurrencies.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckCurrencies.java @@ -16,7 +16,7 @@ public CheckCLDR handleCheck( // it helps performance to have a quick reject of most paths if (fullPath == null) return this; // skip paths that we don't have if (path.indexOf("/currency") < 0 || path.indexOf("/symbol") < 0) return this; - + if (!accept(result)) return this; // parts.set(path); // normally you have to parse out a path to get the exact one, but in // this case the quick // reject suffices diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckDates.java b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckDates.java index 007657dc192..05508b39a4a 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckDates.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckDates.java @@ -339,6 +339,8 @@ public CheckCLDR handleCheck( return this; } + if (!accept(result)) return this; + String sourceLocale = getCldrFileToCheck().getSourceLocaleID(path, status); if (!path.equals(status.pathWhereFound) diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckDisplayCollisions.java b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckDisplayCollisions.java index 2a7ca0afcd7..9a8635548be 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckDisplayCollisions.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckDisplayCollisions.java @@ -334,6 +334,7 @@ public CheckCLDR handleCheck( || value.equals(CldrUtility.INHERITANCE_MARKER)) { return this; } + if (!accept(result)) return this; // find my type; bail if I don't have one. Type myType = Type.getType(path); diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckExemplars.java b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckExemplars.java index 9998c60310d..bcaee5c1a65 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckExemplars.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckExemplars.java @@ -173,6 +173,7 @@ public CheckCLDR handleCheck( } return this; } + if (!accept(result)) return this; XPathParts oparts = XPathParts.getFrozenInstance(path); final String exemplarString = oparts.findAttributeValue("exemplarCharacters", "type"); ExemplarType type = diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckForCopy.java b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckForCopy.java index ac6df0364b6..398d0db0b70 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckForCopy.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckForCopy.java @@ -87,6 +87,7 @@ public CheckCLDR handleCheck( if (fullPath == null || path == null || value == null) { return this; // skip root, and paths that we don't have } + if (!accept(result)) return this; Failure failure = sameAsCodeOrEnglish(value, path, unresolvedFile, getCldrFileToCheck(), false); addFailure(result, failure); diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckForExemplars.java b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckForExemplars.java index c74c4aa0cb8..b7379b3f176 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckForExemplars.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckForExemplars.java @@ -295,6 +295,7 @@ public CheckCLDR handleCheck( String path, String fullPath, String value, Options options, List result) { if (fullPath == null) return this; // skip paths that we don't have if (value == null) return this; // skip values that we don't have ? + if (!accept(result)) return this; if (skip) return this; if (path == null) { throw new InternalCldrException("Empty path!"); diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckForInheritanceMarkers.java b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckForInheritanceMarkers.java index 63018cc4271..d8e7d016543 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckForInheritanceMarkers.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckForInheritanceMarkers.java @@ -12,6 +12,7 @@ public CheckCLDR handleCheck( if (value == null) { return this; } + if (!accept(result)) return this; if (value.contains(CldrUtility.INHERITANCE_MARKER)) { result.add( diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckLogicalGroupings.java b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckLogicalGroupings.java index a967c062303..5d325393333 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckLogicalGroupings.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckLogicalGroupings.java @@ -61,6 +61,7 @@ public CheckCLDR handleCheck( if (LogicalGrouping.isOptional(getCldrFileToCheck(), path)) { return this; } + if (!accept(result)) return this; new LogicalGroupChecker(this, path, value, result).run(); return this; } diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckMetazones.java b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckMetazones.java index d929dc18150..815978f7d35 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckMetazones.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckMetazones.java @@ -18,6 +18,7 @@ public CheckCLDR handleCheck( if (fullPath == null) return this; // skip paths that we don't have if (value == null) return this; // skip empty values if (path.indexOf("/metazone") < 0) return this; + if (!accept(result)) return this; // we're simply going to test to make sure that metazone values don't contain any digits if (value.matches(".*\\p{Nd}.*")) { diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckNames.java b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckNames.java index 5497d50acd0..81c0a40db85 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckNames.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckNames.java @@ -20,6 +20,7 @@ public CheckCLDR handleCheck( if (!YEARS_NOT_ALLOWED.matcher(path).matches() || !getCldrFileToCheck().isNotRoot(path)) { return this; } + if (!accept(result)) return this; Matcher matcher = RegexUtilities.PATTERN_3_OR_4_DIGITS.matcher(value); if (matcher.find()) { // If same as the code-fallback value (territories) then no error diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckNew.java b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckNew.java index f5c52a9815f..cf5193a1110 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckNew.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckNew.java @@ -36,6 +36,7 @@ public CheckCLDR handleCheck( CLDRFile cldrFileToCheck = getCldrFileToCheck(); // don't check inherited values // first see if the value is inherited or not + if (!accept(result)) return this; if (!isRoot && value != null && AnnotationUtil.pathIsAnnotation(path) diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckNumbers.java b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckNumbers.java index 2e2aba763dd..50c20121e39 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckNumbers.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckNumbers.java @@ -130,6 +130,9 @@ public CheckCLDR handleCheck( if (fullPath == null || value == null) return this; // skip paths that we don't have + // TODO: could exclude more paths + if (!accept(result)) return this; + // Do a quick check on the currencyMatch, to make sure that it is a proper UnicodeSet if (path.indexOf("/currencyMatch") >= 0) { try { diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckPersonNames.java b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckPersonNames.java index 39c8bc0c585..46f521d841d 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckPersonNames.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckPersonNames.java @@ -98,6 +98,7 @@ public CheckCLDR handleCheck( if (isRoot || !path.startsWith("//ldml/personNames/")) { return this; } + if (!accept(result)) return this; XPathParts parts = XPathParts.getFrozenInstance(path); switch (parts.getElement(2)) { diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckPlaceHolders.java b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckPlaceHolders.java index ec60d2a82b3..ee20a6fcbdb 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckPlaceHolders.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckPlaceHolders.java @@ -85,6 +85,8 @@ public CheckCLDR handleCheck( if (value == null || path.endsWith("/alias") || SKIP_PATH_LIST.matcher(path).matches()) { return this; } + // TODO: more skips here + if (!accept(result)) return this; if (path.contains("/personNames")) { XPathParts parts = XPathParts.getFrozenInstance(path); diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckQuotes.java b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckQuotes.java index 07c3fa06a44..68347c3e90e 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckQuotes.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckQuotes.java @@ -31,6 +31,7 @@ public CheckCLDR handleCheck( } if (UNITS.matcher(path).matches()) { + if (!accept(result)) return this; Matcher matcher = ASCII_QUOTES.matcher(value); CheckStatus.Type type = CheckStatus.warningType; if (this.getCldrFileToCheck().getLocaleID().equals("en")) { @@ -47,6 +48,7 @@ public CheckCLDR handleCheck( } } if (DELIMITERS.matcher(path).matches()) { + if (!accept(result)) return this; if (!VALID_DELIMITERS.contains(value)) { result.add( new CheckStatus() diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckUnits.java b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckUnits.java index 79ac588010a..f7587652c08 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckUnits.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckUnits.java @@ -50,6 +50,7 @@ public CheckCLDR handleCheck( if (value == null || !path.startsWith("//ldml/units")) { return this; } + if (!accept(result)) return this; final XPathParts parts = XPathParts.getFrozenInstance(path); String finalElement = parts.getElement(-1); diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckWidths.java b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckWidths.java index 0bb3414e924..110bc377688 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckWidths.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckWidths.java @@ -497,6 +497,7 @@ public CheckCLDR handleCheck( if (value == null) { return this; // skip } + if (!accept(result)) return this; // String testPrefix = "//ldml/units/unitLength[@type=\"narrow\"]"; // if (path.startsWith(testPrefix)) { // int i = 0; diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckZones.java b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckZones.java index 6a15523ceea..4ecb81ee784 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckZones.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckZones.java @@ -60,10 +60,9 @@ public CheckCLDR handleCheck( String path, String fullPath, String value, Options options, List result) { if (fullPath == null) return this; // skip paths that we don't have if (path.indexOf("timeZoneNames") < 0 || path.indexOf("usesMetazone") < 0) return this; + if (!accept(result)) return this; if (timezoneFormatter == null) { - if (true) return this; - throw new InternalCldrException( - "This should not occur: setCldrFileToCheck must create a TimezoneFormatter."); + return this; // error thrown above } XPathParts parts = XPathParts.getFrozenInstance(path); From c6ec472cd477e212392c3b4aef50b65f6b67bace Mon Sep 17 00:00:00 2001 From: "Steven R. Loomis" Date: Tue, 19 Dec 2023 17:56:42 -0600 Subject: [PATCH 5/6] CLDR-17289 lazy setCldrFileToCheck, second pass of adding accept() calls --- .../src/main/java/org/unicode/cldr/test/CheckCLDR.java | 2 +- .../src/main/java/org/unicode/cldr/test/CheckChildren.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) 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 24d396b18ec..68b1496b5b0 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 @@ -1421,7 +1421,7 @@ public void handleCheckPossibleErrors( "Test setup time for " + item.getClass().toString() + ": {0}"); try { item.setPhase(getPhase()); - item.handleSetCldrFileToCheck(cldrFileToCheck, options, possibleErrors); + item.setCldrFileToCheck(cldrFileToCheck, options, possibleErrors); if (SHOW_TIMES) { if (item.isSkipTest()) { System.out.println("Disabled : " + testTime); diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckChildren.java b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckChildren.java index 5b770e822a3..a6048ae2b9e 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckChildren.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckChildren.java @@ -22,14 +22,14 @@ public CheckChildren(Factory factory) { @Override public CheckCLDR handleCheck( String path, String fullPath, String value, Options options, List result) { - if (immediateChildren == null) return this; // skip - test isn't even relevant if (fullPath == null) return this; // skip paths that we don't have if (value == null) return this; // skip null values + if (!accept(result)) return this; + if (immediateChildren == null) return this; // skip - test isn't even relevant String winningValue = this.getCldrFileToCheck().getWinningValue(fullPath); if (!value.equals(winningValue)) { return this; // only run this test against winning values. } - if (!accept(result)) return this; // String current = getResolvedCldrFileToCheck().getStringValue(path); tempSet.clear(); for (int i = 0; i < immediateChildren.length; ++i) { From 7a4b0fef21a37fbee9d36b4df51686728d1670c1 Mon Sep 17 00:00:00 2001 From: "Steven R. Loomis" Date: Wed, 20 Dec 2023 10:51:20 -0600 Subject: [PATCH 6/6] CLDR-17289 lazy setCldrFileToCheck: add a reset() override, fixup CheckChildren --- .../src/main/java/org/unicode/cldr/test/CheckCLDR.java | 8 +++++++- .../main/java/org/unicode/cldr/test/CheckChildren.java | 9 ++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) 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 68b1496b5b0..1a7c35d8421 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 @@ -679,7 +679,7 @@ public CheckCLDR handleSetCldrFileToCheck( public CheckCLDR setCldrFileToCheck( CLDRFile cldrFileToCheck, Options options, List possibleErrors) { this.cldrFileToCheck = cldrFileToCheck; - initted = false; + reset(); // clear the *cached* possible Errors. Not counting any set immediately by subclasses. cachedPossibleErrors.clear(); cachedOptions = new Options(options); @@ -705,11 +705,17 @@ public CheckCLDR setCldrFileToCheck( return this; } + /** override this if you want to return errors immediately when setCldrFileToCheck is called */ protected void handleCheckPossibleErrors( CLDRFile cldrFileToCheck, Options options, List possibleErrors) { // nothing by default. } + /** override this if you want to reset state immediately when setCldrFileToCheck is called */ + protected void reset() { + initted = false; + } + /** * Subclasses must call this, after any skip calculation to indicate that an xpath is relevant * to them. diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckChildren.java b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckChildren.java index a6048ae2b9e..7e8ff509c05 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckChildren.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckChildren.java @@ -11,7 +11,7 @@ import org.unicode.cldr.util.CldrUtility; import org.unicode.cldr.util.Factory; -public class CheckChildren extends FactoryCheckCLDR { +public class CheckChildren extends FactoryCheckCLDR { CLDRFile[] immediateChildren; Map tempSet = new HashMap<>(); @@ -61,6 +61,13 @@ public CheckCLDR handleCheck( return this; } + @Override + public void reset() { + super.reset(); + immediateChildren = null; // reset this beforehand + tempSet.clear(); + } + @Override public CheckCLDR handleSetCldrFileToCheck( CLDRFile cldrFileToCheck, Options options, List possibleErrors) {