Remove dependency on package:charcode. (#2705)
* Remove dependency on package:charcode.
* Remember to add the new file.
* Silence a lint, $_ is a good name for that constant.
diff --git a/lib/src/formatter.dart b/lib/src/formatter.dart
index 139b36c..e252023 100644
--- a/lib/src/formatter.dart
+++ b/lib/src/formatter.dart
@@ -6,9 +6,9 @@
import 'dart:math';
import 'package:analyzer/error/error.dart';
-import 'package:charcode/ascii.dart' show $pipe, $backslash;
import 'analyzer.dart';
+import 'util/charcodes.dart' show $pipe, $backslash;
import 'util/score_utils.dart';
// Number of times to perform linting to get stable benchmarks.
diff --git a/lib/src/util/ascii_utils.dart b/lib/src/util/ascii_utils.dart
index 5dbfe6a..9038b90 100644
--- a/lib/src/util/ascii_utils.dart
+++ b/lib/src/util/ascii_utils.dart
@@ -8,7 +8,7 @@
/// See: https://github.com/dart-lang/linter/issues/1828
library ascii_utils;
-import 'package:charcode/ascii.dart';
+import "charcodes.dart";
/// Return `true` if the given [character] is the ASCII '.' character.
bool isDot(int character) => character == $dot;
diff --git a/lib/src/util/charcodes.dart b/lib/src/util/charcodes.dart
new file mode 100644
index 0000000..5613dc5
--- /dev/null
+++ b/lib/src/util/charcodes.dart
@@ -0,0 +1,28 @@
+// Copyright (c) 2021, 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.
+
+/// Character `.`.
+const int $dot = 0x2e;
+
+/// Character `0`.
+const int $0 = 0x30;
+
+/// Character `9`.
+const int $9 = 0x39;
+
+/// Character `\`.
+const int $backslash = 0x5c;
+
+/// Character `_`.
+// ignore: constant_identifier_names
+const int $_ = 0x5f;
+
+/// Character `a`.
+const int $a = 0x61;
+
+/// Character `z`.
+const int $z = 0x7a;
+
+/// Character `|`.
+const int $pipe = 0x7c;
diff --git a/pubspec.yaml b/pubspec.yaml
index 939d815..3413249 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -14,7 +14,6 @@
dependencies:
analyzer: ^1.7.0
args: ^2.0.0
- charcode: ^1.2.0
collection: ^1.15.0
glob: ^2.0.0
http: ^0.13.0
diff --git a/test/integration/directives_ordering.dart b/test/integration/directives_ordering.dart
index 74f2238..ed5f22d 100644
--- a/test/integration/directives_ordering.dart
+++ b/test/integration/directives_ordering.dart
@@ -107,7 +107,7 @@
'Sort directive sections alphabetically.',
"import 'dart:convert'; // LINT",
'Sort directive sections alphabetically.',
- "import 'package:charcode/ascii.dart'; // LINT",
+ "import 'package:collection/collection.dart'; // LINT",
'Sort directive sections alphabetically.',
"import 'package:async/async.dart'; // LINT",
'Sort directive sections alphabetically.',
@@ -121,7 +121,7 @@
'Sort directive sections alphabetically.',
"export 'dart:convert'; // LINT",
'Sort directive sections alphabetically.',
- "export 'package:charcode/ascii.dart'; // LINT",
+ "export 'package:collection/collection.dart'; // LINT",
'Sort directive sections alphabetically.',
"export 'package:async/async.dart'; // LINT",
'Sort directive sections alphabetically.',
diff --git a/test_data/integration/directives_ordering/sort_directive_sections_alphabetically/bad.dart b/test_data/integration/directives_ordering/sort_directive_sections_alphabetically/bad.dart
index 7b20362..d43c923 100644
--- a/test_data/integration/directives_ordering/sort_directive_sections_alphabetically/bad.dart
+++ b/test_data/integration/directives_ordering/sort_directive_sections_alphabetically/bad.dart
@@ -9,7 +9,7 @@
import 'package:async/src/async_cache.dart'; // OK
import 'package:yaml/yaml.dart'; // OK
-import 'package:charcode/ascii.dart'; // LINT
+import 'package:collection/collection.dart'; // LINT
import 'package:async/async.dart'; // LINT
import 'package:linter/src/analyzer.dart'; // OK
@@ -32,7 +32,7 @@
export 'package:async/src/async_cache.dart'; // OK
export 'package:yaml/yaml.dart'; // OK
-export 'package:charcode/ascii.dart'; // LINT
+export 'package:collection/collection.dart'; // LINT
export 'package:async/async.dart'; // LINT
export 'package:linter/src/analyzer.dart'; // OK