From 732d67c87b51eedf7f30e1fd6279a6894bfcfa76 Mon Sep 17 00:00:00 2001 From: Bob Nystrom Date: Fri, 13 Jul 2018 14:13:27 -0700 Subject: [PATCH] Fix to use Dart 2 core library lowercase constant names. --- changelog.md | 7 +++++-- lib/src/common.dart | 2 +- pubspec.yaml | 4 ++-- tool/lib/gen_apis.dart | 2 +- tool/lib/json_parser.dart | 2 +- tool/lib/overrides.dart | 2 +- tool/src/googlesource.dart | 3 ++- tool/src/simple_http_client.dart | 2 +- tool/test/googlesource_test.dart | 2 +- tool/test/model_json_test.dart | 10 +++++----- 10 files changed, 20 insertions(+), 16 deletions(-) diff --git a/changelog.md b/changelog.md index be21c4ad..f00cde1a 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,8 @@ # Changelog - chrome.dart +## 0.10.2 2018-07-13 +- change core library constants to lowercase. + ## 0.10.1 2018-05-02 - fix missing classes on generated `app.dart` file. @@ -98,11 +101,11 @@ ## 0.5.2 2014-02-14 (SDK 1.3.0-dev.3.2 r33495) -- Updated to use docgen for api documentation +- Updated to use docgen for api documentation - Make the window close event sync instead of async - Clean up warnings in unit tests - Add app/ to drone_io.sh script -- Add a chrome pub transformer +- Add a chrome pub transformer - Fix an issue w/ the hand-overridden API - Use a getter to fetch the JsObject for an API each time it is needed diff --git a/lib/src/common.dart b/lib/src/common.dart index 1da1bcbb..4353939a 100644 --- a/lib/src/common.dart +++ b/lib/src/common.dart @@ -42,7 +42,7 @@ List listify(JsObject obj, [Function transformer = null]) { Map mapify(JsObject obj) { if (obj == null) return null; - return JSON.decode(_jsJSON.callMethod('stringify', [obj])); + return jsonDecode(_jsJSON.callMethod('stringify', [obj])); } dynamic jsify(dynamic obj) { diff --git a/pubspec.yaml b/pubspec.yaml index 16e91447..3b820c03 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,8 +1,8 @@ name: chrome -version: 0.10.1 +version: 0.10.2 authors: - Adam Bender -- Ben Holtz +- Ben Holtz description: A library for accessing the Chrome APIs in a packaged app or extension. homepage: https://github.com/dart-gde/chrome.dart environment: diff --git a/tool/lib/gen_apis.dart b/tool/lib/gen_apis.dart index 8a0bf7a8..ef201873 100644 --- a/tool/lib/gen_apis.dart +++ b/tool/lib/gen_apis.dart @@ -49,7 +49,7 @@ class GenApis { void generate() { _logger.info("reading ${apisFile.path}..."); - var apisInfo = JSON.decode(apisFile.readAsStringSync()); + var apisInfo = jsonDecode(apisFile.readAsStringSync()); _generateApi('app', apisInfo['packaged_app'], includeAppSrc: true); _generateApi('ext', apisInfo['extension'], alreadyWritten: apisInfo['packaged_app']); diff --git a/tool/lib/json_parser.dart b/tool/lib/json_parser.dart index 93802739..47b1d9b6 100644 --- a/tool/lib/json_parser.dart +++ b/tool/lib/json_parser.dart @@ -30,7 +30,7 @@ JsonNamespace parse(String jsonText) { } }); - return _parseJson(JSON.decode(newLines.join('\n'))); + return _parseJson(jsonDecode(newLines.join('\n'))); } JsonNamespace _parseJson(dynamic json) { diff --git a/tool/lib/overrides.dart b/tool/lib/overrides.dart index b41bd219..c01a6657 100644 --- a/tool/lib/overrides.dart +++ b/tool/lib/overrides.dart @@ -21,7 +21,7 @@ class Overrides { } Overrides.fromFile(File file) { - _init(JSON.decode(file.readAsStringSync())); + _init(jsonDecode(file.readAsStringSync())); } void _init(Map m) { diff --git a/tool/src/googlesource.dart b/tool/src/googlesource.dart index 4a9b3da8..7d9568fc 100644 --- a/tool/src/googlesource.dart +++ b/tool/src/googlesource.dart @@ -23,7 +23,8 @@ abstract class GoogleSourceEntity { class GoogleSourceFile extends GoogleSourceEntity { static const _encodedCharacters = const ['\'', '&', '<', '>', '\"']; static final encodings = - new Map.fromIterable(_encodedCharacters, key: HTML_ESCAPE.convert); + new Map.fromIterable(_encodedCharacters, + key: htmlEscape.convert); GoogleSourceFile(rawHtml, url) : super(rawHtml, url); diff --git a/tool/src/simple_http_client.dart b/tool/src/simple_http_client.dart index 37940d9a..46a95d43 100644 --- a/tool/src/simple_http_client.dart +++ b/tool/src/simple_http_client.dart @@ -16,6 +16,6 @@ class SimpleHttpClient { HttpClientRequest request = await _client.getUrl(uri); request.close(); HttpClientResponse response = await request.done; - return await response.transform(UTF8.decoder).join(''); + return await response.transform(utf8.decoder).join(''); } } \ No newline at end of file diff --git a/tool/test/googlesource_test.dart b/tool/test/googlesource_test.dart index 3a649d34..b898d3b7 100644 --- a/tool/test/googlesource_test.dart +++ b/tool/test/googlesource_test.dart @@ -35,7 +35,7 @@ void defineTests() { test('unescapes files', () { var testEscapeString = 'this & that is <\"\'>'; var escapedHtmlFile = '
' - '${HTML_ESCAPE.convert(testEscapeString)}
'; + '${htmlEscape.convert(testEscapeString)}'; file = new GoogleSourceFile(escapedHtmlFile, 'www.example.com'); expect(file.fileContents, testEscapeString); diff --git a/tool/test/model_json_test.dart b/tool/test/model_json_test.dart index 714fcabd..493d2589 100644 --- a/tool/test/model_json_test.dart +++ b/tool/test/model_json_test.dart @@ -76,7 +76,7 @@ void main() { "description": "A simple enum with two values", "enum": ["firstVal", "secondVal"] }]'''; - var jsonEnum = json_model.JsonEnum.parse(JSON.decode(data)).single; + var jsonEnum = json_model.JsonEnum.parse(jsonDecode(data)).single; expect(jsonEnum.name, 'simpleEnum'); expect(jsonEnum.values.length, 2); @@ -98,7 +98,7 @@ void main() { "description": "A very simple enum with one value", "enum": ["onlyVal"] }]'''; - var jsonEnums = json_model.JsonEnum.parse(JSON.decode(data)); + var jsonEnums = json_model.JsonEnum.parse(jsonDecode(data)); expect(jsonEnums.length, 2); expect(jsonEnums[0].name, 'simpleEnum'); @@ -124,7 +124,7 @@ void main() { "description": "A very simple enum with one value", "enum": ["onlyVal"] }]'''; - var jsonEnums = json_model.JsonEnum.parse(JSON.decode(data)); + var jsonEnums = json_model.JsonEnum.parse(jsonDecode(data)); expect(jsonEnums.length, 2); expect(jsonEnums[0].name, 'simpleEnum'); @@ -147,7 +147,7 @@ void main() { } ] }]'''; - var jsonEnum = json_model.JsonEnum.parse(JSON.decode(data)).single; + var jsonEnum = json_model.JsonEnum.parse(jsonDecode(data)).single; expect(jsonEnum.name, 'describedEnum'); expect(jsonEnum.values.length, 2); @@ -211,7 +211,7 @@ void main() { }]"""; List functions = - json_model.JsonFunction.parse(JSON.decode(data)); + json_model.JsonFunction.parse(jsonDecode(data)); expect(functions, isNotNull); expect(functions, hasLength(1)); json_model.JsonFunction function = functions[0];