From 6ceb6ea8b5e482b0a149f0fed0405038aa52d4b9 Mon Sep 17 00:00:00 2001 From: David Beaumont Date: Thu, 5 Sep 2019 15:37:44 +0200 Subject: [PATCH] ICU-20693 No arbitrary ordering in path/value visitation for new API --- .../org/unicode/icu/tool/cldrtoicu/mapper/Bcp47Mapper.java | 4 ++-- .../icu/tool/cldrtoicu/mapper/BreakIteratorMapper.java | 3 +-- .../unicode/icu/tool/cldrtoicu/mapper/CollationMapper.java | 6 +++--- .../unicode/icu/tool/cldrtoicu/mapper/DayPeriodsMapper.java | 4 ++-- .../icu/tool/cldrtoicu/mapper/PluralRangesMapper.java | 4 ++-- .../unicode/icu/tool/cldrtoicu/mapper/PluralsMapper.java | 6 +++--- .../icu/tool/cldrtoicu/mapper/SupplementalMapper.java | 4 ++-- 7 files changed, 15 insertions(+), 16 deletions(-) diff --git a/tools/cldr/cldr-to-icu/src/main/java/org/unicode/icu/tool/cldrtoicu/mapper/Bcp47Mapper.java b/tools/cldr/cldr-to-icu/src/main/java/org/unicode/icu/tool/cldrtoicu/mapper/Bcp47Mapper.java index c8654bd32b7..1ba305ae4cc 100644 --- a/tools/cldr/cldr-to-icu/src/main/java/org/unicode/icu/tool/cldrtoicu/mapper/Bcp47Mapper.java +++ b/tools/cldr/cldr-to-icu/src/main/java/org/unicode/icu/tool/cldrtoicu/mapper/Bcp47Mapper.java @@ -7,7 +7,7 @@ import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkState; import static org.unicode.cldr.api.AttributeKey.keyOf; -import static org.unicode.cldr.api.CldrData.PathOrder.ARBITRARY; +import static org.unicode.cldr.api.CldrData.PathOrder.DTD; import static org.unicode.cldr.api.CldrDataType.BCP47; import java.util.LinkedHashMap; @@ -88,7 +88,7 @@ public final class Bcp47Mapper { @VisibleForTesting // It's easier to supply a fake data instance than a fake supplier. static ImmutableList process(CldrData cldrData) { Bcp47Visitor visitor = new Bcp47Visitor(); - cldrData.accept(ARBITRARY, visitor); + cldrData.accept(DTD, visitor); visitor.addKeyMapValues(); return ImmutableList.of(visitor.keyTypeData.icuData, visitor.tzData.icuData); } diff --git a/tools/cldr/cldr-to-icu/src/main/java/org/unicode/icu/tool/cldrtoicu/mapper/BreakIteratorMapper.java b/tools/cldr/cldr-to-icu/src/main/java/org/unicode/icu/tool/cldrtoicu/mapper/BreakIteratorMapper.java index a016cd238de..fc6fe5984ae 100644 --- a/tools/cldr/cldr-to-icu/src/main/java/org/unicode/icu/tool/cldrtoicu/mapper/BreakIteratorMapper.java +++ b/tools/cldr/cldr-to-icu/src/main/java/org/unicode/icu/tool/cldrtoicu/mapper/BreakIteratorMapper.java @@ -3,7 +3,6 @@ package org.unicode.icu.tool.cldrtoicu.mapper; import static org.unicode.cldr.api.AttributeKey.keyOf; -import static org.unicode.cldr.api.CldrData.PathOrder.ARBITRARY; import static org.unicode.cldr.api.CldrData.PathOrder.DTD; import static org.unicode.cldr.api.CldrDataSupplier.CldrResolution.UNRESOLVED; @@ -68,7 +67,7 @@ public final class BreakIteratorMapper { @VisibleForTesting // It's easier to supply a fake data instance than a fake supplier. static IcuData process(String localeId, CldrData cldrData, Optional icuSpecialData) { BreakIteratorMapper mapper = new BreakIteratorMapper(localeId); - icuSpecialData.ifPresent(s -> s.accept(ARBITRARY, mapper::addSpecials)); + icuSpecialData.ifPresent(s -> s.accept(DTD, mapper::addSpecials)); cldrData.accept(DTD, mapper::addSuppression); return mapper.icuData; } diff --git a/tools/cldr/cldr-to-icu/src/main/java/org/unicode/icu/tool/cldrtoicu/mapper/CollationMapper.java b/tools/cldr/cldr-to-icu/src/main/java/org/unicode/icu/tool/cldrtoicu/mapper/CollationMapper.java index 2de90b12360..385cadd3cbd 100644 --- a/tools/cldr/cldr-to-icu/src/main/java/org/unicode/icu/tool/cldrtoicu/mapper/CollationMapper.java +++ b/tools/cldr/cldr-to-icu/src/main/java/org/unicode/icu/tool/cldrtoicu/mapper/CollationMapper.java @@ -4,7 +4,7 @@ package org.unicode.icu.tool.cldrtoicu.mapper; import static com.google.common.base.Preconditions.checkArgument; import static org.unicode.cldr.api.AttributeKey.keyOf; -import static org.unicode.cldr.api.CldrData.PathOrder.ARBITRARY; +import static org.unicode.cldr.api.CldrData.PathOrder.DTD; import static org.unicode.cldr.api.CldrDataSupplier.CldrResolution.UNRESOLVED; import java.util.Optional; @@ -75,8 +75,8 @@ public final class CollationMapper { @VisibleForTesting // It's easier to supply a fake data instance than a fake supplier. static IcuData process(String localeId, CldrData cldrData, Optional icuSpecialData) { CollationVisitor visitor = new CollationVisitor(localeId); - icuSpecialData.ifPresent(s -> s.accept(ARBITRARY, visitor)); - cldrData.accept(ARBITRARY, visitor); + icuSpecialData.ifPresent(s -> s.accept(DTD, visitor)); + cldrData.accept(DTD, visitor); return visitor.icuData; } diff --git a/tools/cldr/cldr-to-icu/src/main/java/org/unicode/icu/tool/cldrtoicu/mapper/DayPeriodsMapper.java b/tools/cldr/cldr-to-icu/src/main/java/org/unicode/icu/tool/cldrtoicu/mapper/DayPeriodsMapper.java index e09fe5f141b..ef0e2966c32 100644 --- a/tools/cldr/cldr-to-icu/src/main/java/org/unicode/icu/tool/cldrtoicu/mapper/DayPeriodsMapper.java +++ b/tools/cldr/cldr-to-icu/src/main/java/org/unicode/icu/tool/cldrtoicu/mapper/DayPeriodsMapper.java @@ -3,7 +3,7 @@ package org.unicode.icu.tool.cldrtoicu.mapper; import static org.unicode.cldr.api.AttributeKey.keyOf; -import static org.unicode.cldr.api.CldrData.PathOrder.ARBITRARY; +import static org.unicode.cldr.api.CldrData.PathOrder.NESTED_GROUPING; import static org.unicode.cldr.api.CldrDataType.SUPPLEMENTAL; import java.util.Optional; @@ -54,7 +54,7 @@ public final class DayPeriodsMapper { @VisibleForTesting // It's easier to supply a fake data instance than a fake supplier. static IcuData process(CldrData data) { RuleSetVisitor mapper = new RuleSetVisitor(); - data.accept(ARBITRARY, mapper); + data.accept(NESTED_GROUPING, mapper); return mapper.icuData; } diff --git a/tools/cldr/cldr-to-icu/src/main/java/org/unicode/icu/tool/cldrtoicu/mapper/PluralRangesMapper.java b/tools/cldr/cldr-to-icu/src/main/java/org/unicode/icu/tool/cldrtoicu/mapper/PluralRangesMapper.java index 2bed54a01c6..c811a8e1c39 100644 --- a/tools/cldr/cldr-to-icu/src/main/java/org/unicode/icu/tool/cldrtoicu/mapper/PluralRangesMapper.java +++ b/tools/cldr/cldr-to-icu/src/main/java/org/unicode/icu/tool/cldrtoicu/mapper/PluralRangesMapper.java @@ -4,7 +4,7 @@ package org.unicode.icu.tool.cldrtoicu.mapper; import static com.google.common.base.Preconditions.checkState; import static org.unicode.cldr.api.AttributeKey.keyOf; -import static org.unicode.cldr.api.CldrData.PathOrder.ARBITRARY; +import static org.unicode.cldr.api.CldrData.PathOrder.NESTED_GROUPING; import static org.unicode.cldr.api.CldrDataType.SUPPLEMENTAL; import org.unicode.cldr.api.AttributeKey; @@ -59,7 +59,7 @@ public final class PluralRangesMapper { @VisibleForTesting // It's easier to supply a fake data instance than a fake supplier. static IcuData process(CldrData data) { PluralRangesVisitor visitor = new PluralRangesVisitor(); - data.accept(ARBITRARY, visitor); + data.accept(NESTED_GROUPING, visitor); return visitor.icuData; } diff --git a/tools/cldr/cldr-to-icu/src/main/java/org/unicode/icu/tool/cldrtoicu/mapper/PluralsMapper.java b/tools/cldr/cldr-to-icu/src/main/java/org/unicode/icu/tool/cldrtoicu/mapper/PluralsMapper.java index 4e125c4e387..dd517817709 100644 --- a/tools/cldr/cldr-to-icu/src/main/java/org/unicode/icu/tool/cldrtoicu/mapper/PluralsMapper.java +++ b/tools/cldr/cldr-to-icu/src/main/java/org/unicode/icu/tool/cldrtoicu/mapper/PluralsMapper.java @@ -5,7 +5,7 @@ package org.unicode.icu.tool.cldrtoicu.mapper; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkState; import static org.unicode.cldr.api.AttributeKey.keyOf; -import static org.unicode.cldr.api.CldrData.PathOrder.ARBITRARY; +import static org.unicode.cldr.api.CldrData.PathOrder.NESTED_GROUPING; import static org.unicode.cldr.api.CldrDataType.SUPPLEMENTAL; import java.util.ArrayList; @@ -65,8 +65,8 @@ public final class PluralsMapper { // affects the set indices we generate during processing. Ideally this would all be immune // to ordering (or just enforce DTD ordering) but right now it's very dependent on // mimicking the order of the existing code to get identical output. - data.accept(ARBITRARY, visitor.setType("cardinal")); - data.accept(ARBITRARY, visitor.setType("ordinal")); + data.accept(NESTED_GROUPING, visitor.setType("cardinal")); + data.accept(NESTED_GROUPING, visitor.setType("ordinal")); return visitor.icuData; } diff --git a/tools/cldr/cldr-to-icu/src/main/java/org/unicode/icu/tool/cldrtoicu/mapper/SupplementalMapper.java b/tools/cldr/cldr-to-icu/src/main/java/org/unicode/icu/tool/cldrtoicu/mapper/SupplementalMapper.java index c8b81007702..ae6f12c3ee8 100644 --- a/tools/cldr/cldr-to-icu/src/main/java/org/unicode/icu/tool/cldrtoicu/mapper/SupplementalMapper.java +++ b/tools/cldr/cldr-to-icu/src/main/java/org/unicode/icu/tool/cldrtoicu/mapper/SupplementalMapper.java @@ -53,8 +53,8 @@ public final class SupplementalMapper extends AbstractPathValueMapper { @Override void addResults() { - // DTD and NESTED_GROUPING order differ because of how the magic label works (it - // basically enforces "encounter order" onto things in unlabeled sequences, which matches + // NESTED_GROUPING and DTD order differ because of how the magic label works (it + // basically enforces "encounter order" onto things in unlabelled sequences, which matches // the old behaviour). If it wouldn't break anything, it might be worth moving to DTD order // to remove any lingering implicit dependencies on the CLDR data behaviour. getCldrData().accept(NESTED_GROUPING, this::visit); -- 2.40.0