Skip to content

Commit

Permalink
CLDR-7646 Use TestCache in VettingViewer
Browse files Browse the repository at this point in the history
- add a constructor to CheckCLDR that takes just a CLDRLocale
  • Loading branch information
srl295 committed Jan 5, 2024
1 parent 5dc06d8 commit d120cc8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -158,7 +157,7 @@ Status getErrorStatus(
private static class DefaultErrorStatus implements ErrorChecker {

private CheckCLDR checkCldr;
private HashMap<String, String> options = new HashMap<>();
private CheckCLDR.Options options = null;
private ArrayList<CheckStatus> result = new ArrayList<>();
private CLDRFile cldrFile;
private final Factory factory;
Expand All @@ -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<CheckStatus> getErrorCheckStatus(String path, String value) {
String fullPath = cldrFile.getFullXPath(path);
ArrayList<CheckStatus> result2 = new ArrayList<>();
checkCldr.check(path, fullPath, value, new CheckCLDR.Options(options), result2);
factory.getTestCache().getBundle(options).check(path, result2, value);
return result2;
}

Expand All @@ -198,8 +195,7 @@ public Status getErrorStatus(
EnumSet<Subtype> 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();
/*
Expand Down

0 comments on commit d120cc8

Please sign in to comment.