From d120cc89a6a906e00cb80038146f439ccd074d91 Mon Sep 17 00:00:00 2001 From: "Steven R. Loomis" Date: Fri, 5 Jan 2024 14:02:30 -0600 Subject: [PATCH] CLDR-7646 Use TestCache in VettingViewer - add a constructor to CheckCLDR that takes just a CLDRLocale --- .../main/java/org/unicode/cldr/test/CheckCLDR.java | 9 +++++++++ .../java/org/unicode/cldr/util/VettingViewer.java | 14 +++++--------- 2 files changed, 14 insertions(+), 9 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 7e70dddf0cb..9b9eabcf4fb 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 @@ -447,6 +447,15 @@ public Options(Options options2) { this.locale = options2.locale; } + public Options(CLDRLocale locale) { + this.locale = locale; + options = new String[Option.values().length]; + set(Option.locale, locale.getBaseName()); + StringBuilder sb = new StringBuilder(); + sb.append(locale.getBaseName()).append('/'); + key = sb.toString().intern(); + } + public Options( CLDRLocale locale, CheckCLDR.Phase testPhase, 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 745c9274cee..6696998312d 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 @@ -29,7 +29,6 @@ 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.Options; import org.unicode.cldr.test.CheckCoverage; import org.unicode.cldr.test.CheckNew; import org.unicode.cldr.test.CoverageLevel2; @@ -158,7 +157,7 @@ Status getErrorStatus( private static class DefaultErrorStatus implements ErrorChecker { private CheckCLDR checkCldr; - private HashMap options = new HashMap<>(); + private CheckCLDR.Options options = null; private ArrayList result = new ArrayList<>(); private CLDRFile cldrFile; private final Factory factory; @@ -170,18 +169,16 @@ private DefaultErrorStatus(Factory cldrFactory) { @Override public Status initErrorStatus(CLDRFile cldrFile) { this.cldrFile = cldrFile; - options = new HashMap<>(); + options = new CheckCLDR.Options(CLDRLocale.getInstance(cldrFile.getLocaleID())); result = new ArrayList<>(); - checkCldr = CheckCLDR.getCheckAll(factory, ".*"); - checkCldr.setCldrFileToCheck(cldrFile, new Options(options), result); + // test initialization is handled by TestCache return Status.ok; } @Override public List getErrorCheckStatus(String path, String value) { - String fullPath = cldrFile.getFullXPath(path); ArrayList result2 = new ArrayList<>(); - checkCldr.check(path, fullPath, value, new CheckCLDR.Options(options), result2); + factory.getTestCache().getBundle(options).check(path, result2, value); return result2; } @@ -198,8 +195,7 @@ public Status getErrorStatus( EnumSet outputSubtypes) { Status result0 = Status.ok; StringBuilder errorMessage = new StringBuilder(); - String fullPath = cldrFile.getFullXPath(path); - checkCldr.check(path, fullPath, value, new CheckCLDR.Options(options), result); + factory.getTestCache().getBundle(options).check(path, result, value); for (CheckStatus checkStatus : result) { final CheckCLDR cause = checkStatus.getCause(); /*