diff --git a/CHANGELOG.md b/CHANGELOG.md index c9070fb..673df14 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 0.17.10 + * Update petitparser dependency. + ## 0.17.9 * Fix pub complaint trying to precompile a library file in bin by moving that file to lib/src. diff --git a/lib/src/icu_parser.dart b/lib/src/icu_parser.dart index 4e55b12..3cd9c04 100644 --- a/lib/src/icu_parser.dart +++ b/lib/src/icu_parser.dart @@ -14,68 +14,72 @@ import 'package:petitparser/petitparser.dart'; /// The "parse" method will return a Success or Failure object which responds /// to "value". class IcuParser { - get openCurly => char("{"); - - get closeCurly => char("}"); - get quotedCurly => (string("'{'") | string("'}'")).map((x) => x[1]); - - get icuEscapedText => quotedCurly | twoSingleQuotes; - get curly => (openCurly | closeCurly); - get notAllowedInIcuText => curly | char("<"); - get icuText => notAllowedInIcuText.neg(); - get notAllowedInNormalText => char("{"); - get normalText => notAllowedInNormalText.neg(); - get messageText => (icuEscapedText | icuText).plus().map((x) => x.join()); - get nonIcuMessageText => normalText.plus().map((x) => x.join()); - get twoSingleQuotes => string("''").map((x) => "'"); - get number => digit().plus().flatten().trim().map(int.parse); - get id => (letter() & (word() | char("_")).star()).flatten().trim(); - get comma => char(",").trim(); + Parser get openCurly => char('{'); + + Parser get closeCurly => char('}'); + Parser get quotedCurly => (string("'{'") | string("'}'")).map((x) => x[1]); + + Parser get icuEscapedText => quotedCurly | twoSingleQuotes; + Parser get curly => (openCurly | closeCurly); + Parser get notAllowedInIcuText => curly | char('<'); + Parser get icuText => notAllowedInIcuText.neg(); + Parser get notAllowedInNormalText => char('{'); + Parser get normalText => notAllowedInNormalText.neg(); + Parser get messageText => + (icuEscapedText | icuText).plus().map((x) => x.join()); + Parser get nonIcuMessageText => normalText.plus().map((x) => x.join()); + Parser get twoSingleQuotes => string("''").map((x) => "'"); + Parser get number => digit().plus().flatten().trim().map(int.parse); + Parser get id => (letter() & (word() | char('_')).star()).flatten().trim(); + Parser get comma => char(',').trim(); /// Given a list of possible keywords, return a rule that accepts any of them. /// e.g., given ["male", "female", "other"], accept any of them. - asKeywords(list) => list.map(string).reduce((a, b) => a | b).flatten().trim(); + Parser asKeywords(List list) => + list.map(string).cast().reduce((a, b) => a | b).flatten().trim(); - get pluralKeyword => asKeywords( - ["=0", "=1", "=2", "zero", "one", "two", "few", "many", "other"]); - get genderKeyword => asKeywords(["female", "male", "other"]); + Parser get pluralKeyword => asKeywords( + ['=0', '=1', '=2', 'zero', 'one', 'two', 'few', 'many', 'other']); + Parser get genderKeyword => asKeywords(['female', 'male', 'other']); var interiorText = undefined(); - get preface => (openCurly & id & comma).map((values) => values[1]); + Parser get preface => (openCurly & id & comma).map((values) => values[1]); - get pluralLiteral => string("plural"); - get pluralClause => (pluralKeyword & openCurly & interiorText & closeCurly) - .trim() - .map((result) => [result[0], result[2]]); - get plural => + Parser get pluralLiteral => string('plural'); + Parser get pluralClause => + (pluralKeyword & openCurly & interiorText & closeCurly) + .trim() + .map((result) => [result[0], result[2]]); + Parser get plural => preface & pluralLiteral & comma & pluralClause.plus() & closeCurly; - get intlPlural => - plural.map((values) => new Plural.from(values.first, values[3], null)); - - get selectLiteral => string("select"); - get genderClause => (genderKeyword & openCurly & interiorText & closeCurly) - .trim() - .map((result) => [result[0], result[2]]); - get gender => + Parser get intlPlural => + plural.map((values) => Plural.from(values.first, values[3], null)); + + Parser get selectLiteral => string('select'); + Parser get genderClause => + (genderKeyword & openCurly & interiorText & closeCurly) + .trim() + .map((result) => [result[0], result[2]]); + Parser get gender => preface & selectLiteral & comma & genderClause.plus() & closeCurly; - get intlGender => - gender.map((values) => new Gender.from(values.first, values[3], null)); - get selectClause => + Parser get intlGender => + gender.map((values) => Gender.from(values.first, values[3], null)); + Parser get selectClause => (id & openCurly & interiorText & closeCurly).map((x) => [x.first, x[2]]); - get generalSelect => + Parser get generalSelect => preface & selectLiteral & comma & selectClause.plus() & closeCurly; - get intlSelect => generalSelect - .map((values) => new Select.from(values.first, values[3], null)); + Parser get intlSelect => + generalSelect.map((values) => Select.from(values.first, values[3], null)); - get pluralOrGenderOrSelect => intlPlural | intlGender | intlSelect; + Parser get pluralOrGenderOrSelect => intlPlural | intlGender | intlSelect; - get contents => pluralOrGenderOrSelect | parameter | messageText; - get simpleText => (nonIcuMessageText | parameter | openCurly).plus(); - get empty => epsilon().map((_) => ''); + Parser get contents => pluralOrGenderOrSelect | parameter | messageText; + Parser get simpleText => (nonIcuMessageText | parameter | openCurly).plus(); + Parser get empty => epsilon().map((_) => ''); - get parameter => (openCurly & id & closeCurly) - .map((param) => new VariableSubstitution.named(param[1], null)); + Parser get parameter => (openCurly & id & closeCurly) + .map((param) => VariableSubstitution.named(param[1], null)); /// The primary entry point for parsing. Accepts a string and produces /// a parsed representation of it as a Message. @@ -87,7 +91,7 @@ class IcuParser { Parser get nonIcuMessage => (simpleText | empty).map((chunk) => Message.from(chunk, null)); - get stuff => (pluralOrGenderOrSelect | empty) + Parser get stuff => (pluralOrGenderOrSelect | empty) .map((chunk) => Message.from(chunk, null)); IcuParser() { diff --git a/pubspec.yaml b/pubspec.yaml index 8fc3ad4..31e1426 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: intl_translation -version: 0.17.9 +version: 0.17.10 author: Dart Team description: >- Contains code to deal with internationalized/localized messages, @@ -8,7 +8,7 @@ description: >- homepage: https://github.com/dart-lang/intl_translation environment: - sdk: '>=2.0.0 <3.0.0' + sdk: '>=2.7.0 <3.0.0' dependencies: analyzer: '>=0.36.0 <0.40.0' @@ -16,6 +16,6 @@ dependencies: dart_style: ^1.0.0 intl: '>=0.15.3 <0.17.0' path: '>=0.9.0 <2.0.0' - petitparser: '>=1.1.3 < 3.0.0' + petitparser: ^3.0.0 dev_dependencies: test: ^1.2.0 diff --git a/test/message_extraction/embedded_plural_text_after_test.dart b/test/message_extraction/embedded_plural_text_after_test.dart index 3b207a0..b5434b2 100644 --- a/test/message_extraction/embedded_plural_text_after_test.dart +++ b/test/message_extraction/embedded_plural_text_after_test.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +@Timeout(const Duration(seconds: 180)) + library embedded_plural_text_after_test; import "failed_extraction_test.dart"; diff --git a/test/message_extraction/embedded_plural_text_before_test.dart b/test/message_extraction/embedded_plural_text_before_test.dart index bd7c510..3bb3df7 100644 --- a/test/message_extraction/embedded_plural_text_before_test.dart +++ b/test/message_extraction/embedded_plural_text_before_test.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +@Timeout(const Duration(seconds: 180)) + library embedded_plural_text_before_test; import "failed_extraction_test.dart"; diff --git a/test/message_extraction/examples_parsing_test.dart b/test/message_extraction/examples_parsing_test.dart index b2d84cb..0db0480 100644 --- a/test/message_extraction/examples_parsing_test.dart +++ b/test/message_extraction/examples_parsing_test.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +@Timeout(const Duration(seconds: 180)) + /// Test for parsing the examples argument from an Intl.message call. Very /// minimal so far. import 'package:test/test.dart'; diff --git a/test/message_extraction/failed_extraction_test.dart b/test/message_extraction/failed_extraction_test.dart index d7f653f..c50cd8d 100644 --- a/test/message_extraction/failed_extraction_test.dart +++ b/test/message_extraction/failed_extraction_test.dart @@ -1,6 +1,9 @@ // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. + +@Timeout(const Duration(seconds: 180)) + library failed_extraction_test; import "message_extraction_test.dart"; diff --git a/test/message_extraction/find_messages_test.dart b/test/message_extraction/find_messages_test.dart index 031cda5..d3871c1 100644 --- a/test/message_extraction/find_messages_test.dart +++ b/test/message_extraction/find_messages_test.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +@Timeout(const Duration(seconds: 180)) + import 'package:intl_translation/extract_messages.dart'; import 'package:intl_translation/src/message_rewriter.dart'; import 'package:test/test.dart'; diff --git a/test/message_extraction/message_extraction_json_test.dart b/test/message_extraction/message_extraction_json_test.dart index bd23aab..fa17b5f 100644 --- a/test/message_extraction/message_extraction_json_test.dart +++ b/test/message_extraction/message_extraction_json_test.dart @@ -2,10 +2,11 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +@Timeout(const Duration(seconds: 180)) + /// A test for message extraction and code generation using generated /// JSON rather than functions -@Timeout(const Duration(seconds: 60)) import 'package:test/test.dart'; import 'message_extraction_test.dart' as main_test; diff --git a/test/message_extraction/message_extraction_no_deferred_test.dart b/test/message_extraction/message_extraction_no_deferred_test.dart index 255c7df..1b9af0d 100644 --- a/test/message_extraction/message_extraction_no_deferred_test.dart +++ b/test/message_extraction/message_extraction_no_deferred_test.dart @@ -2,9 +2,10 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +@Timeout(const Duration(seconds: 180)) + /// A test for message extraction and code generation not using deferred /// loading for the generated code. -@Timeout(const Duration(seconds: 60)) library message_extraction_no_deferred_test; import 'package:test/test.dart'; diff --git a/test/message_extraction/message_extraction_test.dart b/test/message_extraction/message_extraction_test.dart index 17628f1..d62d9d5 100644 --- a/test/message_extraction/message_extraction_test.dart +++ b/test/message_extraction/message_extraction_test.dart @@ -2,7 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -@Timeout(const Duration(seconds: 60)) +@Timeout(const Duration(seconds: 180)) + library message_extraction_test; import 'package:test/test.dart'; diff --git a/test/message_extraction/really_fail_extraction_test.dart b/test/message_extraction/really_fail_extraction_test.dart index 830d791..4ed0387 100644 --- a/test/message_extraction/really_fail_extraction_test.dart +++ b/test/message_extraction/really_fail_extraction_test.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +@Timeout(const Duration(seconds: 180)) + library really_fail_extraction_test; import "failed_extraction_test.dart";