From 9bf348d4d99ff91a5d21e369cd891f5e2447ca6a Mon Sep 17 00:00:00 2001 From: Mihai Nita Date: Wed, 18 Sep 2024 10:06:31 -0700 Subject: [PATCH] ICU-22893 Remove support for Unsupported, Private & Reserved constructs - Matching PR #883 in the message-format-wg repo. - Also removes some unused imports --- .../com/ibm/icu/message2/MFDataModel.java | 62 +----------- .../icu/message2/MFDataModelFormatter.java | 34 +++---- .../java/com/ibm/icu/message2/MFParser.java | 94 +++---------------- .../com/ibm/icu/message2/MFSerializer.java | 42 --------- .../com/ibm/icu/message2/StringUtils.java | 22 ----- .../ibm/icu/dev/test/message2/CoreTest.java | 3 - .../test/message2/DefaultTestProperties.java | 4 - .../ibm/icu/dev/test/message2/MF2Test.java | 4 - .../com/ibm/icu/dev/test/message2/Param.java | 4 - .../dev/test/message2/ParserSmokeTest.java | 7 -- .../dev/test/message2/SerializationTest.java | 3 - .../ibm/icu/dev/test/message2/Sources.java | 3 - .../test/message2/StringToListAdapter.java | 3 +- .../com/ibm/icu/dev/test/message2/Unit.java | 1 - testdata/message2/icu-parser-tests.json | 8 +- 15 files changed, 30 insertions(+), 264 deletions(-) diff --git a/icu4j/main/core/src/main/java/com/ibm/icu/message2/MFDataModel.java b/icu4j/main/core/src/main/java/com/ibm/icu/message2/MFDataModel.java index b459404c834f..7cbf42dbfaf0 100644 --- a/icu4j/main/core/src/main/java/com/ibm/icu/message2/MFDataModel.java +++ b/icu4j/main/core/src/main/java/com/ibm/icu/message2/MFDataModel.java @@ -87,7 +87,7 @@ public SelectMessage( */ @Deprecated public interface Declaration { - // Provides a common type for InputDeclaration, LocalDeclaration, and UnsupportedStatement. + // Provides a common type for InputDeclaration, and LocalDeclaration } /** @@ -130,28 +130,6 @@ public LocalDeclaration(String name, Expression value) { } } - /** - * @internal ICU 72 technology preview - * @deprecated This API is for technology preview only. - */ - @Deprecated - public static class UnsupportedStatement implements Declaration { - public final String keyword; - public final String body; - public final List expressions; - - /** - * @internal ICU 72 technology preview - * @deprecated This API is for technology preview only. - */ - @Deprecated - public UnsupportedStatement(String keyword, String body, List expressions) { - this.keyword = keyword; - this.body = body; - this.expressions = expressions; - } - } - /** * @internal ICU 72 technology preview * @deprecated This API is for technology preview only. @@ -312,26 +290,6 @@ public FunctionExpression(FunctionAnnotation annotation, List attribu } } - /** - * @internal ICU 72 technology preview - * @deprecated This API is for technology preview only. - */ - @Deprecated - public static class UnsupportedExpression implements Expression { - public final UnsupportedAnnotation annotation; - public final List attributes; - - /** - * @internal ICU 72 technology preview - * @deprecated This API is for technology preview only. - */ - @Deprecated - public UnsupportedExpression(UnsupportedAnnotation annotation, List attributes) { - this.annotation = annotation; - this.attributes = attributes; - } - } - /** * @internal ICU 72 technology preview * @deprecated This API is for technology preview only. @@ -441,24 +399,6 @@ public Option(String name, LiteralOrVariableRef value) { } } - /** - * @internal ICU 72 technology preview - * @deprecated This API is for technology preview only. - */ - @Deprecated - public static class UnsupportedAnnotation implements Annotation { - public final String source; - - /** - * @internal ICU 72 technology preview - * @deprecated This API is for technology preview only. - */ - @Deprecated - public UnsupportedAnnotation(String source) { - this.source = source; - } - } - // Markup /** diff --git a/icu4j/main/core/src/main/java/com/ibm/icu/message2/MFDataModelFormatter.java b/icu4j/main/core/src/main/java/com/ibm/icu/message2/MFDataModelFormatter.java index 2ba70854d093..89c424c09707 100644 --- a/icu4j/main/core/src/main/java/com/ibm/icu/message2/MFDataModelFormatter.java +++ b/icu4j/main/core/src/main/java/com/ibm/icu/message2/MFDataModelFormatter.java @@ -28,8 +28,6 @@ import com.ibm.icu.message2.MFDataModel.Pattern; import com.ibm.icu.message2.MFDataModel.SelectMessage; import com.ibm.icu.message2.MFDataModel.StringPart; -import com.ibm.icu.message2.MFDataModel.UnsupportedAnnotation; -import com.ibm.icu.message2.MFDataModel.UnsupportedExpression; import com.ibm.icu.message2.MFDataModel.VariableRef; import com.ibm.icu.message2.MFDataModel.Variant; import com.ibm.icu.util.Calendar; @@ -104,7 +102,8 @@ String format(Map arguments) { variables = resolveDeclarations(sm.declarations, arguments); patternToRender = findBestMatchingPattern(sm, variables, arguments); } else { - formattingError(""); + fatalFormattingError("Unknown message type."); + // formattingError throws, so the return does not actually happen return "ERROR!"; } @@ -123,10 +122,8 @@ String format(Map arguments) { result.append(formattedExpression.getFormattedValue().toString()); } else if (part instanceof MFDataModel.Markup) { // Ignore - } else if (part instanceof MFDataModel.UnsupportedExpression) { - // Ignore } else { - formattingError("Unknown part type: " + part); + fatalFormattingError("Unknown part type: " + part); } } return result.toString(); @@ -217,7 +214,7 @@ private Pattern findBestMatchingPattern( // spec: Append `ks` as the last element of the list `keys`. keys.add(ks); } else { - formattingError("Literal expected, but got " + key); + fatalFormattingError("Literal expected, but got " + key); } } // spec: Let `rv` be the resolved value at index `i` of `res`. @@ -249,7 +246,7 @@ private Pattern findBestMatchingPattern( } // spec: Assert that `key` is a _literal_. if (!(key instanceof Literal)) { - formattingError("Literal expected"); + fatalFormattingError("Literal expected"); } // spec: Let `ks` be the resolved value of `key`. String ks = ((Literal) key).value; @@ -304,7 +301,7 @@ private Pattern findBestMatchingPattern( if (!(key instanceof CatchallKey)) { // spec: Assert that `key` is a _literal_. if (!(key instanceof Literal)) { - formattingError("Literal expected"); + fatalFormattingError("Literal expected"); } // spec: Let `ks` be the resolved value of `key`. String ks = ((Literal) key).value; @@ -356,7 +353,7 @@ private static int sortVariants(IntVarTuple o1, IntVarTuple o2) { List v1 = o1.variant.keys; List v2 = o1.variant.keys; if (v1.size() != v2.size()) { - formattingError("The number of keys is not equal."); + fatalFormattingError("The number of keys is not equal."); } for (int i = 0; i < v1.size(); i++) { LiteralOrCatchallKey k1 = v1.get(i); @@ -399,7 +396,7 @@ public ResolvedSelector( } } - private static void formattingError(String message) { + private static void fatalFormattingError(String message) { throw new IllegalArgumentException(message); } @@ -512,24 +509,23 @@ private FormattedPlaceholder formatExpression( // No output on markup, for now (we only format to string) return new FormattedPlaceholder(expression, new PlainStringFormattedValue("")); } else { - UnsupportedExpression ue = (UnsupportedExpression) expression; - char sigil = ue.annotation.source.charAt(0); - return new FormattedPlaceholder( - expression, new PlainStringFormattedValue("{" + sigil + "}")); + if (expression == null) { + fatalFormattingError("unexpected null expression"); + } else { + fatalFormattingError("unknown expression type " + + expression.getClass().getName()); + } } if (annotation instanceof FunctionAnnotation) { FunctionAnnotation fa = (FunctionAnnotation) annotation; if (functionName != null && !functionName.equals(fa.name)) { - formattingError( + fatalFormattingError( "invalid function overrides, '" + functionName + "' <> '" + fa.name + "'"); } functionName = fa.name; Map newOptions = convertOptions(fa.options, variables, arguments); options.putAll(newOptions); - } else if (annotation instanceof UnsupportedAnnotation) { - // We don't know how to format unsupported annotations - return new FormattedPlaceholder(expression, new PlainStringFormattedValue(fallbackString)); } FormatterFactory funcFactory = getFormattingFunctionFactoryByName(toFormat, functionName); diff --git a/icu4j/main/core/src/main/java/com/ibm/icu/message2/MFParser.java b/icu4j/main/core/src/main/java/com/ibm/icu/message2/MFParser.java index a5c826f87397..8ba50d055c37 100644 --- a/icu4j/main/core/src/main/java/com/ibm/icu/message2/MFParser.java +++ b/icu4j/main/core/src/main/java/com/ibm/icu/message2/MFParser.java @@ -147,13 +147,13 @@ private String getText() { // abnf: placeholder = expression / markup // abnf: expression = literal-expression - // abnf: / variable-expression - // abnf: / annotation-expression + // abnf: / variable-expression + // abnf: / annotation-expression // abnf: literal-expression = "{" [s] literal [s annotation] *(s attribute) [s] "}" // abnf: variable-expression = "{" [s] variable [s annotation] *(s attribute) [s] "}" // abnf: annotation-expression = "{" [s] annotation *(s attribute) [s] "}" // abnf: markup = "{" [s] "#" identifier *(s option) *(s attribute) [s] ["/"] "}" ; open and standalone - // abnf: / "{" [s] "/" identifier *(s option) *(s attribute) [s] "}" ; close + // abnf: / "{" [s] "/" identifier *(s option) *(s attribute) [s] "}" ; close private MFDataModel.Expression getPlaceholder() throws MFParseException { int cp = input.peekChar(); if (cp != '{') { @@ -168,9 +168,7 @@ private MFDataModel.Expression getPlaceholder() throws MFParseException { result = getMarkup(); } else if (cp == '$') { result = getVariableExpression(); - } else if (StringUtils.isFunctionSigil(cp) - || StringUtils.isPrivateAnnotationSigil(cp) - || StringUtils.isReservedAnnotationSigil(cp)) { + } else if (StringUtils.isFunctionSigil(cp)) { result = getAnnotationExpression(); } else { result = getLiteralExpression(); @@ -214,16 +212,8 @@ private MFDataModel.Annotation getAnnotation(boolean whitespaceRequired) throws checkCondition(identifier != null, "Annotation / function name missing"); Map options = getOptions(); return new MFDataModel.FunctionAnnotation(identifier, options); - default: // reserved && private - if (StringUtils.isReservedAnnotationSigil(cp) - || StringUtils.isPrivateAnnotationSigil(cp)) { - cp = input.readCodePoint(); - // The sigil is part of the body. - // Safe to cast to char, the code point is in BMP - identifier = (char) cp + getIdentifier(); - String body = getReservedBody(); - return new MFDataModel.UnsupportedAnnotation(identifier + body); - } + default: + // OK to continue and return null, it is an error. } input.gotoPosition(position); return null; @@ -246,7 +236,7 @@ private MFDataModel.Annotation getMarkupAnnotation() throws MFParseException { Map options = getOptions(); return new MFDataModel.FunctionAnnotation(identifier, options); default: - // reserved, private, function, something else, + // function or something else, return null; } } @@ -290,9 +280,6 @@ private MFDataModel.Expression getAnnotationExpression() throws MFParseException if (annotation instanceof MFDataModel.FunctionAnnotation) { return new MFDataModel.FunctionExpression( (MFDataModel.FunctionAnnotation) annotation, attributes); - } else if (annotation instanceof MFDataModel.UnsupportedAnnotation) { - return new MFDataModel.UnsupportedExpression( - (MFDataModel.UnsupportedAnnotation) annotation, attributes); } else { error("Unexpected annotation : " + annotation); } @@ -300,7 +287,7 @@ private MFDataModel.Expression getAnnotationExpression() throws MFParseException } // abnf: markup = "{" [s] "#" identifier *(s option) *(s attribute) [s] ["/"] "}" ; open and standalone - // abnf: / "{" [s] "/" identifier *(s option) *(s attribute) [s] "}" ; close + // abnf: / "{" [s] "/" identifier *(s option) *(s attribute) [s] "}" ; close private MFDataModel.Markup getMarkup() throws MFParseException { int cp = input.peekChar(); // consume the '{' checkCondition(cp == '#' || cp == '/', "Should not happen. Expecting a markup."); @@ -370,39 +357,6 @@ private MFDataModel.Attribute getAttribute() throws MFParseException { return null; } - // abnf: reserved-body = *([s] 1*(reserved-char / reserved-escape / quoted)) - // abnf: reserved-escape = backslash ( backslash / "{" / "|" / "}" ) - private String getReservedBody() throws MFParseException { - int spaceCount = skipWhitespaces(); - StringBuilder result = new StringBuilder(); - while (true) { - int cp = input.readCodePoint(); - if (StringUtils.isReservedChar(cp)) { - result.appendCodePoint(cp); - } else if (cp == '\\') { - cp = input.readCodePoint(); - checkCondition( - cp == '{' || cp == '|' || cp == '}', - "Invalid escape sequence. Only \\{, \\| and \\} are valid here."); - result.append(cp); - } else if (cp == '|') { - input.backup(1); - MFDataModel.Literal quoted = getQuotedLiteral(); - result.append(quoted.value); - } else if (cp == EOF) { - return result.toString(); - } else { - if (result.length() == 0) { - input.backup(spaceCount + 1); - return ""; - } else { - input.backup(1); - return result.toString(); - } - } - } - } - // abnf: identifier = [namespace ":"] name // abnf: namespace = name // abnf: name = name-start *name-char @@ -650,7 +604,7 @@ private MFDataModel.SelectMessage getMatch(List declara // abnf: key = literal / "*" private MFDataModel.Variant getVariant() throws MFParseException { List keys = new ArrayList<>(); - // abnf variant = key *(s key) [s] quoted-pattern + // abnf: variant = key *(s key) [s] quoted-pattern while (true) { // Space is required between keys MFDataModel.LiteralOrCatchallKey key = getKey(!keys.isEmpty()); @@ -705,8 +659,6 @@ private static class MatchDeclaration implements MFDataModel.Declaration { // abnf: input-declaration = input [s] variable-expression // abnf: local-declaration = local s variable [s] "=" [s] expression - // abnf: reserved-statement = reserved-keyword [s reserved-body] 1*([s] expression) - // abnf: reserved-keyword = "." name private MFDataModel.Declaration getDeclaration() throws MFParseException { int position = input.getPosition(); skipOptionalWhitespaces(); @@ -745,32 +697,8 @@ private MFDataModel.Declaration getDeclaration() throws MFParseException { break; case "match": return new MatchDeclaration(); - default: // abnf: reserved-statement = reserved-keyword [s reserved-body] 1*([s] expression) - skipOptionalWhitespaces(); - String body = getReservedBody(); - List expressions = new ArrayList<>(); - while (true) { - skipOptionalWhitespaces(); - // Look ahead to detect the end of the unsupported statement - // (next token either begins a placeholder or begins a complex body) - cp = input.readCodePoint(); - int cp1 = input.readCodePoint(); - if (cp == '{' && cp1 == '{') { - // End of unsupported statement - input.backup(2); - break; - } else { - input.backup(2); - } - expression = getPlaceholder(); - // This also covers != null - if (expression instanceof MFDataModel.VariableExpression) { - expressions.add(expression); - } else { - break; - } - } - return new MFDataModel.UnsupportedStatement(declName, body, expressions); + default: + // OK to continue and return null, it is an error. } return null; } diff --git a/icu4j/main/core/src/main/java/com/ibm/icu/message2/MFSerializer.java b/icu4j/main/core/src/main/java/com/ibm/icu/message2/MFSerializer.java index 58fcf81cba88..4ce31109f4f2 100644 --- a/icu4j/main/core/src/main/java/com/ibm/icu/message2/MFSerializer.java +++ b/icu4j/main/core/src/main/java/com/ibm/icu/message2/MFSerializer.java @@ -27,9 +27,6 @@ import com.ibm.icu.message2.MFDataModel.PatternPart; import com.ibm.icu.message2.MFDataModel.SelectMessage; import com.ibm.icu.message2.MFDataModel.StringPart; -import com.ibm.icu.message2.MFDataModel.UnsupportedAnnotation; -import com.ibm.icu.message2.MFDataModel.UnsupportedExpression; -import com.ibm.icu.message2.MFDataModel.UnsupportedStatement; import com.ibm.icu.message2.MFDataModel.VariableExpression; import com.ibm.icu.message2.MFDataModel.VariableRef; import com.ibm.icu.message2.MFDataModel.Variant; @@ -123,20 +120,11 @@ private void expressionToString(Expression expression) { functionExpressionToString((FunctionExpression) expression); } else if (expression instanceof Markup) { markupToString((Markup) expression); - } else if (expression instanceof UnsupportedExpression) { - unsupportedExpressionToString((UnsupportedExpression) expression); } else { errorType("Expression", expression); } } - private void unsupportedExpressionToString(UnsupportedExpression ue) { - result.append('{'); - annotationToString(ue.annotation); - attributesToString(ue.attributes); - result.append('}'); - } - private void markupToString(Markup markup) { result.append('{'); if (markup.kind == Markup.Kind.CLOSE) { @@ -193,16 +181,6 @@ private void annotationToString(Annotation annotation) { result.append(":"); result.append(((FunctionAnnotation) annotation).name); optionsToString(((FunctionAnnotation) annotation).options); - } else if (annotation instanceof UnsupportedAnnotation) { - addSpaceIfNeeded(); - String value = ((UnsupportedAnnotation) annotation).source; - for (int i = 0; i < value.length(); i++) { - char c = value.charAt(i); - if (c == '\\' || c == '{' || c == '}') { - result.append('\\'); - } - result.append(c); - } } else { errorType("Annotation", annotation); } @@ -304,32 +282,12 @@ private void declarationsToString(List declarations) { localDeclarationToString((LocalDeclaration) declaration); } else if (declaration instanceof InputDeclaration) { inputDeclarationToString((InputDeclaration) declaration); - } else if (declaration instanceof UnsupportedStatement) { - unsupportedStatementToString((UnsupportedStatement) declaration); } else { errorType("Declaration", declaration); } } } - private void unsupportedStatementToString(UnsupportedStatement declaration) { - addSpaceIfNeeded(); - result.append('.'); - result.append(declaration.keyword); - if (!declaration.body.isEmpty()) { - result.append(' '); - } - result.append('|'); - result.append(declaration.body); - result.append('|'); - needSpace = true; - for (Expression expression : declaration.expressions) { - addSpaceIfNeeded(); - expressionToString(expression); - needSpace = true; - } - } - private void inputDeclarationToString(InputDeclaration declaration) { addSpaceIfNeeded(); result.append(".input "); diff --git a/icu4j/main/core/src/main/java/com/ibm/icu/message2/StringUtils.java b/icu4j/main/core/src/main/java/com/ibm/icu/message2/StringUtils.java index ff89d12c1abe..d90c4dc8d483 100644 --- a/icu4j/main/core/src/main/java/com/ibm/icu/message2/StringUtils.java +++ b/icu4j/main/core/src/main/java/com/ibm/icu/message2/StringUtils.java @@ -84,11 +84,6 @@ static boolean isNameChar(int cp) { || (cp >= 0x203F && cp <= 0x2040); } - // abnf: private-start = "^" / "&" - static boolean isPrivateStart(int cp) { - return cp == '^' || cp == '&'; - } - // abnf: quoted-char = content-char / s / "." / "@" / "{" / "}" static boolean isQuotedChar(int cp) { return isContentChar(cp) @@ -99,11 +94,6 @@ static boolean isQuotedChar(int cp) { || cp == '}'; } - // abnf: reserved-char = content-char / "." - static boolean isReservedChar(int cp) { - return isContentChar(cp) || cp == '.'; - } - static boolean isSimpleStartChar(int cp) { return StringUtils.isContentChar(cp) || StringUtils.isWhitespace(cp) @@ -127,16 +117,4 @@ static boolean isDigit(int cp) { static boolean isFunctionSigil(int cp) { return cp == ':'; } - - // abnf: private-start = "^" / "&" - static boolean isPrivateAnnotationSigil(int cp) { - return cp == '^' || cp == '&'; - } - - // abnf: reserved-annotation-start = "!" / "%" / "*" / "+" / "<" / ">" / "?" / "~" - private static final String RESERVED_ANNOTATION_SIGILS = "!%*+<>?~"; - - static boolean isReservedAnnotationSigil(int cp) { - return RESERVED_ANNOTATION_SIGILS.indexOf(cp) != -1; - } } diff --git a/icu4j/main/core/src/test/java/com/ibm/icu/dev/test/message2/CoreTest.java b/icu4j/main/core/src/test/java/com/ibm/icu/dev/test/message2/CoreTest.java index 0dd3bf6be59c..a0ec7c2fe3d1 100644 --- a/icu4j/main/core/src/test/java/com/ibm/icu/dev/test/message2/CoreTest.java +++ b/icu4j/main/core/src/test/java/com/ibm/icu/dev/test/message2/CoreTest.java @@ -4,14 +4,11 @@ package com.ibm.icu.dev.test.message2; import java.io.Reader; -import java.lang.reflect.Type; -import java.util.Map; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import com.google.gson.reflect.TypeToken; import com.ibm.icu.dev.test.CoreTestFmwk; @SuppressWarnings({"static-method", "javadoc"}) diff --git a/icu4j/main/core/src/test/java/com/ibm/icu/dev/test/message2/DefaultTestProperties.java b/icu4j/main/core/src/test/java/com/ibm/icu/dev/test/message2/DefaultTestProperties.java index d0b463baf1f3..21cc5a363a32 100644 --- a/icu4j/main/core/src/test/java/com/ibm/icu/dev/test/message2/DefaultTestProperties.java +++ b/icu4j/main/core/src/test/java/com/ibm/icu/dev/test/message2/DefaultTestProperties.java @@ -3,10 +3,6 @@ package com.ibm.icu.dev.test.message2; -import java.util.List; -import java.util.Map; -import java.util.StringJoiner; - // See https://github.com/unicode-org/conformance/blob/main/schema/message_fmt2/testgen_schema.json // Class corresponding to the json test files. diff --git a/icu4j/main/core/src/test/java/com/ibm/icu/dev/test/message2/MF2Test.java b/icu4j/main/core/src/test/java/com/ibm/icu/dev/test/message2/MF2Test.java index 502fde2a6093..9223d51eee42 100644 --- a/icu4j/main/core/src/test/java/com/ibm/icu/dev/test/message2/MF2Test.java +++ b/icu4j/main/core/src/test/java/com/ibm/icu/dev/test/message2/MF2Test.java @@ -3,10 +3,6 @@ package com.ibm.icu.dev.test.message2; -import java.util.List; -import java.util.Map; -import java.util.StringJoiner; - // See https://github.com/unicode-org/conformance/blob/main/schema/message_fmt2/testgen_schema.json // Class corresponding to the json test files. diff --git a/icu4j/main/core/src/test/java/com/ibm/icu/dev/test/message2/Param.java b/icu4j/main/core/src/test/java/com/ibm/icu/dev/test/message2/Param.java index 9c77fe73443b..fea1daaa466c 100644 --- a/icu4j/main/core/src/test/java/com/ibm/icu/dev/test/message2/Param.java +++ b/icu4j/main/core/src/test/java/com/ibm/icu/dev/test/message2/Param.java @@ -3,10 +3,6 @@ package com.ibm.icu.dev.test.message2; -import java.util.List; -import java.util.Map; -import java.util.StringJoiner; - // See https://github.com/unicode-org/conformance/blob/main/schema/message_fmt2/testgen_schema.json // Class corresponding to the json test files. diff --git a/icu4j/main/core/src/test/java/com/ibm/icu/dev/test/message2/ParserSmokeTest.java b/icu4j/main/core/src/test/java/com/ibm/icu/dev/test/message2/ParserSmokeTest.java index 638b38521b27..db17330c8bd4 100644 --- a/icu4j/main/core/src/test/java/com/ibm/icu/dev/test/message2/ParserSmokeTest.java +++ b/icu4j/main/core/src/test/java/com/ibm/icu/dev/test/message2/ParserSmokeTest.java @@ -3,16 +3,10 @@ package com.ibm.icu.dev.test.message2; -import java.io.Reader; -import java.lang.reflect.Type; -import java.util.Map; -import java.util.Map.Entry; - import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import com.google.gson.reflect.TypeToken; import com.ibm.icu.dev.test.CoreTestFmwk; import com.ibm.icu.message2.MFParser; @@ -22,7 +16,6 @@ @RunWith(JUnit4.class) @SuppressWarnings({"static-method", "javadoc"}) public class ParserSmokeTest extends CoreTestFmwk { - private static final String JSON_FILE = "icu-parser-tests.json"; @Test(expected = IllegalArgumentException.class) public void testNullInput() throws Exception { diff --git a/icu4j/main/core/src/test/java/com/ibm/icu/dev/test/message2/SerializationTest.java b/icu4j/main/core/src/test/java/com/ibm/icu/dev/test/message2/SerializationTest.java index 2655d42569fe..465b7cae8131 100644 --- a/icu4j/main/core/src/test/java/com/ibm/icu/dev/test/message2/SerializationTest.java +++ b/icu4j/main/core/src/test/java/com/ibm/icu/dev/test/message2/SerializationTest.java @@ -19,14 +19,12 @@ public class SerializationTest extends CoreTestFmwk { @Test public void test() throws Exception { String[] testStrings = { - "Hello {$count &something}", "Hello world!", "{{.Hello world!}}", "Hello {userName}", "Hello {$userName}", "Hello {|-12345.12+e10|}", "Hello {$count :something max=10 min=1.1416 opt1=someString opt2=|a b \\| c| @a1 @a2=|| @a3=|str|}", - "Hello {$count &something}", ".input {$a :number} {{Hello world!}}", ".local $b = {$a :number} {{Hello world!}}", ".local $c = {1 :number} {{Hello {userName}}}", @@ -57,7 +55,6 @@ public void test() throws Exception { + ".match {$c}\n" + "one {{{$c} dollar}}\n" + "* {{{$c} dollars}}", - ".local $c = {$count} .foobar |asd asd asd asd| {$bar1} {$bar2} {$bar3} .local $b = {$bar} {{Foo bar}}", ".local $c = {1 :number minimumFractionDigits=2}\n" + ".match {$c}\n" + "one {{{$c} dollar}}\n" diff --git a/icu4j/main/core/src/test/java/com/ibm/icu/dev/test/message2/Sources.java b/icu4j/main/core/src/test/java/com/ibm/icu/dev/test/message2/Sources.java index 39a931a5a589..fe8136509452 100644 --- a/icu4j/main/core/src/test/java/com/ibm/icu/dev/test/message2/Sources.java +++ b/icu4j/main/core/src/test/java/com/ibm/icu/dev/test/message2/Sources.java @@ -3,10 +3,7 @@ package com.ibm.icu.dev.test.message2; -import java.util.ArrayList; import java.util.List; -import java.util.Map; -import java.util.StringJoiner; // Class corresponding to the json test files. // See Unit.java and StringToListAdapter.java for how this is used. diff --git a/icu4j/main/core/src/test/java/com/ibm/icu/dev/test/message2/StringToListAdapter.java b/icu4j/main/core/src/test/java/com/ibm/icu/dev/test/message2/StringToListAdapter.java index facc9f00c2df..bfe4be2cc260 100644 --- a/icu4j/main/core/src/test/java/com/ibm/icu/dev/test/message2/StringToListAdapter.java +++ b/icu4j/main/core/src/test/java/com/ibm/icu/dev/test/message2/StringToListAdapter.java @@ -5,12 +5,11 @@ import java.io.IOException; import java.util.ArrayList; -import java.util.List; import com.google.gson.TypeAdapter; import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; import com.google.gson.stream.JsonToken; +import com.google.gson.stream.JsonWriter; // Helper class that converts a single String to a List // so that the `src` property can be either a single string or an array of strings. diff --git a/icu4j/main/core/src/test/java/com/ibm/icu/dev/test/message2/Unit.java b/icu4j/main/core/src/test/java/com/ibm/icu/dev/test/message2/Unit.java index 810594f29253..ff90ce0ccf9a 100644 --- a/icu4j/main/core/src/test/java/com/ibm/icu/dev/test/message2/Unit.java +++ b/icu4j/main/core/src/test/java/com/ibm/icu/dev/test/message2/Unit.java @@ -4,7 +4,6 @@ package com.ibm.icu.dev.test.message2; import java.util.List; -import java.util.Map; import java.util.StringJoiner; // Class corresponding to the json test files. diff --git a/testdata/message2/icu-parser-tests.json b/testdata/message2/icu-parser-tests.json index a28cfc61687f..0eb54b266514 100644 --- a/testdata/message2/icu-parser-tests.json +++ b/testdata/message2/icu-parser-tests.json @@ -41,8 +41,6 @@ { "src": "Hello world {$exp @valid @attr=a @attrb=123 @atrn=|foo bar|}" }, { "src": "Hello world {$exp :date @valid @attr=aaaa @attrb=123 @atrn=|foo bar|}" }, { "src": "Hello world {$exp :date year=numeric month=long day=numeric int=12 @valid @attr=a @attrb=123 @atrn=|foo bar|}" }, - { "src": "Reserved {$exp &foo |something more protected|} and more" }, - { "src": "Reserved {$exp %foo |something quoted \\| inside|} and more" }, { "src": "{{.starting with dot is OK here}}" }, { "src": "{{Some string pattern \\}, with {$foo} and {$exp :date style=long}!}}" }, { "src": ".input {$pi :number} {{}}" }, @@ -51,11 +49,9 @@ { "src": ".local $foo = {$exp :date} {{}}" }, { "src": ".local $foo = {$exp :date year=numeric month=long day=numeric} {{}}" }, { "src": ".local $bar = {$foo :date month=medium} {{}}" }, - { "src": ".something |reserved=| {$foo :date} {{}}" }, { "src": ".input {$a :date} .local $exp = {$a :date style=full} {{Your card expires on {$exp}!}}" }, - { "src": ".input {$a :date} .local $b = {$a :date year=numeric month=long day=numeric} .local $c = {$b :date month=medium} .someting |reserved = \\| and more| {$x :date} {$y :date} {$z :number} {{}}" }, + { "src": ".input {$a :date} .local $b = {$a :date year=numeric month=long day=numeric} .local $c = {$b :date month=medium} {{}}" }, { "src": ".input {$x :number} {{_}}" }, - { "src": ".local $foo = {|1|} {{_}}" }, - { "src": ".unsupported |statement| {$x :number} {{_}}" } + { "src": ".local $foo = {|1|} {{_}}" } ] }