Skip to content

Commit 2cac2a5

Browse files
authored
CLDR-17599 Path descriptions: fix static init references bug; remove … (#5085)
1 parent ae79266 commit 2cac2a5

File tree

4 files changed

+214
-212
lines changed

4 files changed

+214
-212
lines changed

tools/cldr-code/src/main/java/org/unicode/cldr/util/PathDescription.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,12 @@ public enum ErrorHandling {
5353
private static final Map<String, String> ZONE2COUNTRY =
5454
STANDARD_CODES.zoneParser.getZoneToCountry();
5555

56-
/** <Description, Markdown> */
57-
private static final PathDescriptionParser parser = new PathDescriptionParser();
58-
59-
private static final PathDescriptionParser hintsParser = new PathDescriptionParser();
60-
6156
private static RegexLookup<Pair<String, String>> pathHandling = null;
6257

6358
private static RegexLookup<Pair<String, String>> pathHintsHandling = null;
6459

65-
/** markdown to append */
66-
private static final String references = parser.getReferences();
60+
/** Markdown to append from PathDescriptions.md. Initialized in getPathHandling */
61+
private static String references = null;
6762

6863
/** for tests, returns the big string */
6964
static String getBigString(String fileName) {
@@ -77,17 +72,22 @@ static String getBigString(String fileName) {
7772
}
7873
}
7974

80-
/** for tests */
75+
/** Public for tests */
8176
public static RegexLookup<Pair<String, String>> getPathHandling() {
8277
if (pathHandling == null) {
78+
PathDescriptionParser parser = new PathDescriptionParser();
8379
pathHandling = parser.parse(pathDescriptionFileName);
80+
references = parser.getReferences();
8481
}
8582
return pathHandling;
8683
}
8784

8885
private static RegexLookup<Pair<String, String>> getPathHintsHandling() {
8986
if (pathHintsHandling == null) {
87+
PathDescriptionParser hintsParser = new PathDescriptionParser();
9088
pathHintsHandling = hintsParser.parse(pathDescriptionHintsFileName);
89+
// Note: Hints currently use no references. If they did, they could be
90+
// initialized here by hintReferences = hintsParser.getReferences()
9191
}
9292
return pathHintsHandling;
9393
}
@@ -143,7 +143,6 @@ public String getRawDescription(String path, Object context) {
143143
}
144144

145145
public String getHintRawDescription(String path, Object context) {
146-
147146
status.clear();
148147
final Pair<String, String> entry = getPathHintsHandling().get(path, context, pathArguments);
149148
if (entry == null) {

tools/cldr-code/src/main/java/org/unicode/cldr/util/PathDescriptionParser.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ public RegexLookup<Pair<String, String>> parse(String fileName) {
3636
"Failed parsing " + fileName + ":" + n + ": at " + section + "#" + description,
3737
t);
3838
}
39-
4039
return lookup;
4140
}
4241

@@ -160,6 +159,10 @@ private void end() {
160159
if (!inReferences()) {
161160
throw new IllegalArgumentException("End of lines when not in # " + REFERENCES);
162161
}
162+
if (getReferences().isEmpty()) {
163+
throw new IllegalArgumentException(
164+
"No references were found in section: " + REFERENCES);
165+
}
163166
// no need to call endHeader here as there isn't anything to terminate in references.
164167
}
165168

0 commit comments

Comments
 (0)