dart:core: optional-new/const, named-default-separator, function-typedefs
dartfmt -w --fix-optional-new --fix-optional-const --fix-named-default-separator --fix-function-typedefs .
Change-Id: I9b1d6b8a604384afed0ece35a9a7f849edba46df
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/97563
Auto-Submit: Kevin Moore <kevmoo@google.com>
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
Commit-Queue: Kevin Moore <kevmoo@google.com>
diff --git a/sdk/lib/core/annotations.dart b/sdk/lib/core/annotations.dart
index 4034456..2d30f1c 100644
--- a/sdk/lib/core/annotations.dart
+++ b/sdk/lib/core/annotations.dart
@@ -80,7 +80,7 @@
/**
* Marks a feature as [Deprecated] until the next release.
*/
-const Deprecated deprecated = const Deprecated("next release");
+const Deprecated deprecated = Deprecated("next release");
class _Override {
const _Override();
@@ -111,7 +111,7 @@
* For example, the annotation is intentionally not used in the Dart platform
* libraries, since they only depend on themselves.
*/
-const Object override = const _Override();
+const Object override = _Override();
/**
* An annotation class that was used during development of Dart 2.
@@ -184,7 +184,7 @@
* types.
*/
@deprecated
-const Object proxy = const _Proxy();
+const Object proxy = _Proxy();
/**
* A hint to tools.
diff --git a/sdk/lib/core/bool.dart b/sdk/lib/core/bool.dart
index e3014bb..5ed1065 100644
--- a/sdk/lib/core/bool.dart
+++ b/sdk/lib/core/bool.dart
@@ -47,7 +47,7 @@
//ignore: const_constructor_with_body
//ignore: const_factory
external const factory bool.fromEnvironment(String name,
- {bool defaultValue: false});
+ {bool defaultValue = false});
external int get hashCode;
diff --git a/sdk/lib/core/comparable.dart b/sdk/lib/core/comparable.dart
index bbb334f..835aa34 100644
--- a/sdk/lib/core/comparable.dart
+++ b/sdk/lib/core/comparable.dart
@@ -18,7 +18,7 @@
* * zero if [a] is equal to [b], and
* * a positive integer if [a] is greater than [b].
*/
-typedef int Comparator<T>(T a, T b);
+typedef Comparator<T> = int Function(T a, T b);
/**
* Interface used by types that have an intrinsic ordering.
diff --git a/sdk/lib/core/date_time.dart b/sdk/lib/core/date_time.dart
index 90608670..00ea5a4 100644
--- a/sdk/lib/core/date_time.dart
+++ b/sdk/lib/core/date_time.dart
@@ -329,11 +329,11 @@
int value = _brokenDownDateToValue(years, month, day, hour, minute,
second, millisecond, microsecond, isUtc);
if (value == null) {
- throw new FormatException("Time out of range", formattedString);
+ throw FormatException("Time out of range", formattedString);
}
- return new DateTime._withValue(value, isUtc: isUtc);
+ return DateTime._withValue(value, isUtc: isUtc);
} else {
- throw new FormatException("Invalid date format", formattedString);
+ throw FormatException("Invalid date format", formattedString);
}
}
@@ -365,7 +365,7 @@
* time zone (local or UTC).
*/
external DateTime.fromMillisecondsSinceEpoch(int millisecondsSinceEpoch,
- {bool isUtc: false});
+ {bool isUtc = false});
/**
* Constructs a new [DateTime] instance
@@ -378,7 +378,7 @@
* time zone (local or UTC).
*/
external DateTime.fromMicrosecondsSinceEpoch(int microsecondsSinceEpoch,
- {bool isUtc: false});
+ {bool isUtc = false});
/**
* Constructs a new [DateTime] instance with the given value.
@@ -389,11 +389,11 @@
if (millisecondsSinceEpoch.abs() > _maxMillisecondsSinceEpoch ||
(millisecondsSinceEpoch.abs() == _maxMillisecondsSinceEpoch &&
microsecond != 0)) {
- throw new ArgumentError(
+ throw ArgumentError(
"DateTime is outside valid range: $millisecondsSinceEpoch");
}
if (isUtc == null) {
- throw new ArgumentError("'isUtc' flag may not be 'null'");
+ throw ArgumentError("'isUtc' flag may not be 'null'");
}
}
@@ -505,7 +505,7 @@
*/
DateTime toLocal() {
if (isUtc) {
- return new DateTime._withValue(_value, isUtc: false);
+ return DateTime._withValue(_value, isUtc: false);
}
return this;
}
@@ -523,7 +523,7 @@
*/
DateTime toUtc() {
if (isUtc) return this;
- return new DateTime._withValue(_value, isUtc: true);
+ return DateTime._withValue(_value, isUtc: true);
}
static String _fourDigits(int n) {
@@ -866,7 +866,7 @@
* timezone ::= 'z' | 'Z' | sign digit{2} timezonemins_opt
* timezonemins_opt ::= <empty> | colon_opt digit{2}
*/
- static final RegExp _parseFormat = new RegExp(
+ static final RegExp _parseFormat = RegExp(
r'^([+-]?\d{4,6})-?(\d\d)-?(\d\d)' // Day part.
r'(?:[ T](\d\d)(?::?(\d\d)(?::?(\d\d)(?:[.,](\d{1,6}))?)?)?' // Time part.
r'( ?[zZ]| ?([-+])(\d\d)(?::?(\d\d))?)?)?$'); // Timezone part.
diff --git a/sdk/lib/core/duration.dart b/sdk/lib/core/duration.dart
index 52bfc29..914f05a 100644
--- a/sdk/lib/core/duration.dart
+++ b/sdk/lib/core/duration.dart
@@ -73,7 +73,7 @@
static const int minutesPerDay = minutesPerHour * hoursPerDay;
- static const Duration zero = const Duration(seconds: 0);
+ static const Duration zero = Duration(seconds: 0);
/*
* The value of this Duration object in microseconds.
@@ -91,12 +91,12 @@
* All arguments are 0 by default.
*/
const Duration(
- {int days: 0,
- int hours: 0,
- int minutes: 0,
- int seconds: 0,
- int milliseconds: 0,
- int microseconds: 0})
+ {int days = 0,
+ int hours = 0,
+ int minutes = 0,
+ int seconds = 0,
+ int milliseconds = 0,
+ int microseconds = 0})
: this._microseconds(microsecondsPerDay * days +
microsecondsPerHour * hours +
microsecondsPerMinute * minutes +
@@ -113,7 +113,7 @@
* returns the sum as a new Duration object.
*/
Duration operator +(Duration other) {
- return new Duration._microseconds(_duration + other._duration);
+ return Duration._microseconds(_duration + other._duration);
}
/**
@@ -121,7 +121,7 @@
* returns the difference as a new Duration object.
*/
Duration operator -(Duration other) {
- return new Duration._microseconds(_duration - other._duration);
+ return Duration._microseconds(_duration - other._duration);
}
/**
@@ -132,7 +132,7 @@
* 53 bits, precision is lost because of double-precision arithmetic.
*/
Duration operator *(num factor) {
- return new Duration._microseconds((_duration * factor).round());
+ return Duration._microseconds((_duration * factor).round());
}
/**
@@ -144,8 +144,8 @@
Duration operator ~/(int quotient) {
// By doing the check here instead of relying on "~/" below we get the
// exception even with dart2js.
- if (quotient == 0) throw new IntegerDivisionByZeroException();
- return new Duration._microseconds(_duration ~/ quotient);
+ if (quotient == 0) throw IntegerDivisionByZeroException();
+ return Duration._microseconds(_duration ~/ quotient);
}
/**
@@ -280,7 +280,7 @@
* The returned `Duration` has the same length as this one, but is always
* positive.
*/
- Duration abs() => new Duration._microseconds(_duration.abs());
+ Duration abs() => Duration._microseconds(_duration.abs());
/**
* Returns a new `Duration` representing this `Duration` negated.
@@ -289,5 +289,5 @@
* opposite sign of this one.
*/
// Using subtraction helps dart2js avoid negative zeros.
- Duration operator -() => new Duration._microseconds(0 - _duration);
+ Duration operator -() => Duration._microseconds(0 - _duration);
}
diff --git a/sdk/lib/core/errors.dart b/sdk/lib/core/errors.dart
index 1bd829d..53f3d35 100644
--- a/sdk/lib/core/errors.dart
+++ b/sdk/lib/core/errors.dart
@@ -278,7 +278,7 @@
static void checkValueInInterval(int value, int minValue, int maxValue,
[String name, String message]) {
if (value < minValue || value > maxValue) {
- throw new RangeError.range(value, minValue, maxValue, name, message);
+ throw RangeError.range(value, minValue, maxValue, name, message);
}
}
@@ -299,7 +299,7 @@
// Comparing with `0` as receiver produces better dart2js type inference.
if (0 > index || index >= length) {
name ??= "index";
- throw new RangeError.index(index, indexable, name, message, length);
+ throw RangeError.index(index, indexable, name, message, length);
}
}
@@ -325,12 +325,12 @@
// Ditto `start > end` below.
if (0 > start || start > length) {
startName ??= "start";
- throw new RangeError.range(start, 0, length, startName, message);
+ throw RangeError.range(start, 0, length, startName, message);
}
if (end != null) {
if (start > end || end > length) {
endName ??= "end";
- throw new RangeError.range(end, start, length, endName, message);
+ throw RangeError.range(end, start, length, endName, message);
}
return end;
}
@@ -343,7 +343,7 @@
* Throws if the value is negative.
*/
static void checkNotNegative(int value, [String name, String message]) {
- if (value < 0) throw new RangeError.range(value, 0, null, name, message);
+ if (value < 0) throw RangeError.range(value, 0, null, name, message);
}
String get _errorName => "RangeError";
diff --git a/sdk/lib/core/exceptions.dart b/sdk/lib/core/exceptions.dart
index 103940c..2e137e5 100644
--- a/sdk/lib/core/exceptions.dart
+++ b/sdk/lib/core/exceptions.dart
@@ -18,7 +18,7 @@
* until the actual exceptions used by a library are done.
*/
abstract class Exception {
- factory Exception([var message]) => new _Exception(message);
+ factory Exception([var message]) => _Exception(message);
}
/** Default implementation of [Exception] which carries a message. */
diff --git a/sdk/lib/core/invocation.dart b/sdk/lib/core/invocation.dart
index 3cae040..e9ea57e 100644
--- a/sdk/lib/core/invocation.dart
+++ b/sdk/lib/core/invocation.dart
@@ -23,8 +23,7 @@
factory Invocation.method(
Symbol memberName, Iterable<Object> positionalArguments,
[Map<Symbol, Object> namedArguments]) =>
- new _Invocation.method(
- memberName, null, positionalArguments, namedArguments);
+ _Invocation.method(memberName, null, positionalArguments, namedArguments);
/**
* Creates an invocation corresponding to a generic method invocation.
@@ -38,7 +37,7 @@
factory Invocation.genericMethod(Symbol memberName,
Iterable<Type> typeArguments, Iterable<Object> positionalArguments,
[Map<Symbol, Object> namedArguments]) =>
- new _Invocation.method(
+ _Invocation.method(
memberName, typeArguments, positionalArguments, namedArguments);
/**
@@ -123,7 +122,7 @@
_positional = _makeUnmodifiable<Object>(positional) ?? const <Object>[],
_named = (named == null || named.isEmpty)
? const <Symbol, Object>{}
- : new Map<Symbol, Object>.unmodifiable(named);
+ : Map<Symbol, Object>.unmodifiable(named);
_Invocation.getter(this.memberName)
: typeArguments = const <Type>[],
@@ -132,7 +131,7 @@
_Invocation.setter(this.memberName, Object argument)
: typeArguments = const <Type>[],
- _positional = new List<Object>.unmodifiable([argument]),
+ _positional = List<Object>.unmodifiable([argument]),
_named = null;
List<dynamic> get positionalArguments => _positional ?? const <Object>[];
@@ -149,7 +148,7 @@
if (types == null) return const <Type>[];
for (int i = 0; i < types.length; i++) {
if (types[i] == null) {
- throw new ArgumentError(
+ throw ArgumentError(
"Type arguments must be non-null, was null at index $i.");
}
}
@@ -158,6 +157,6 @@
static List<T> _makeUnmodifiable<T>(Iterable<T> elements) {
if (elements == null) return null;
- return new List<T>.unmodifiable(elements);
+ return List<T>.unmodifiable(elements);
}
}
diff --git a/sdk/lib/core/iterable.dart b/sdk/lib/core/iterable.dart
index 7283bd6..0744937 100644
--- a/sdk/lib/core/iterable.dart
+++ b/sdk/lib/core/iterable.dart
@@ -100,8 +100,8 @@
* `const [0, ..., n - 1].map(generator)`.
*/
factory Iterable.generate(int count, [E generator(int index)]) {
- if (count <= 0) return new EmptyIterable<E>();
- return new _GeneratorIterable<E>(count, generator);
+ if (count <= 0) return EmptyIterable<E>();
+ return _GeneratorIterable<E>(count, generator);
}
/**
@@ -121,7 +121,7 @@
* are accessed, then the resulting iterable can be used as an `Iterable<T>`.
*/
static Iterable<T> castFrom<S, T>(Iterable<S> source) =>
- new CastIterable<S, T>(source);
+ CastIterable<S, T>(source);
/**
* Returns a new `Iterator` that allows iterating the elements of this
@@ -173,9 +173,9 @@
*/
Iterable<E> followedBy(Iterable<E> other) {
if (this is EfficientLengthIterable<E>) {
- return new FollowedByIterable<E>.firstEfficient(this, other);
+ return FollowedByIterable<E>.firstEfficient(this, other);
}
- return new FollowedByIterable<E>(this, other);
+ return FollowedByIterable<E>(this, other);
}
/**
@@ -192,7 +192,7 @@
* on any element where the result isn't needed.
* For example, [elementAt] may call `f` only once.
*/
- Iterable<T> map<T>(T f(E e)) => new MappedIterable<E, T>(this, f);
+ Iterable<T> map<T>(T f(E e)) => MappedIterable<E, T>(this, f);
/**
* Returns a new lazy [Iterable] with all elements that satisfy the
@@ -208,7 +208,7 @@
* the returned [Iterable] may invoke the supplied
* function [test] multiple times on the same element.
*/
- Iterable<E> where(bool test(E element)) => new WhereIterable<E>(this, test);
+ Iterable<E> where(bool test(E element)) => WhereIterable<E>(this, test);
/**
* Returns a new lazy [Iterable] with all elements that have type [T].
@@ -221,7 +221,7 @@
* the returned [Iterable] may yield different results,
* if the underlying elements change between iterations.
*/
- Iterable<T> whereType<T>() => new WhereTypeIterable<T>(this);
+ Iterable<T> whereType<T>() => WhereTypeIterable<T>(this);
/**
* Expands each element of this [Iterable] into zero or more elements.
@@ -244,7 +244,7 @@
*
*/
Iterable<T> expand<T>(Iterable<T> f(E element)) =>
- new ExpandIterable<E, T>(this, f);
+ ExpandIterable<E, T>(this, f);
/**
* Returns true if the collection contains an element equal to [element].
@@ -360,7 +360,7 @@
String join([String separator = ""]) {
Iterator<E> iterator = this.iterator;
if (!iterator.moveNext()) return "";
- StringBuffer buffer = new StringBuffer();
+ StringBuffer buffer = StringBuffer();
if (separator == null || separator == "") {
do {
buffer.write("${iterator.current}");
@@ -394,8 +394,8 @@
* The elements are in iteration order.
* The list is fixed-length if [growable] is false.
*/
- List<E> toList({bool growable: true}) {
- return new List<E>.from(this, growable: growable);
+ List<E> toList({bool growable = true}) {
+ return List<E>.from(this, growable: growable);
}
/**
@@ -407,7 +407,7 @@
* The order of the elements in the set is not guaranteed to be the same
* as for the iterable.
*/
- Set<E> toSet() => new Set<E>.from(this);
+ Set<E> toSet() => Set<E>.from(this);
/**
* Returns the number of elements in [this].
@@ -452,7 +452,7 @@
* The `count` must not be negative.
*/
Iterable<E> take(int count) {
- return new TakeIterable<E>(this, count);
+ return TakeIterable<E>(this, count);
}
/**
@@ -466,7 +466,7 @@
* the returned iterable stops (its `moveNext()` returns false).
*/
Iterable<E> takeWhile(bool test(E value)) {
- return new TakeWhileIterable<E>(this, test);
+ return TakeWhileIterable<E>(this, test);
}
/**
@@ -486,7 +486,7 @@
* The [count] must not be negative.
*/
Iterable<E> skip(int count) {
- return new SkipIterable<E>(this, count);
+ return SkipIterable<E>(this, count);
}
/**
@@ -502,7 +502,7 @@
* starting with the first element for which `test(element)` returns `false`.
*/
Iterable<E> skipWhile(bool test(E value)) {
- return new SkipWhileIterable<E>(this, test);
+ return SkipWhileIterable<E>(this, test);
}
/**
@@ -645,7 +645,7 @@
if (index == elementIndex) return element;
elementIndex++;
}
- throw new RangeError.index(index, this, "index", null, elementIndex);
+ throw RangeError.index(index, this, "index", null, elementIndex);
}
/**
@@ -667,7 +667,7 @@
String toString() => IterableBase.iterableToShortString(this, '(', ')');
}
-typedef E _Generator<E>(int index);
+typedef _Generator<E> = E Function(int index);
class _GeneratorIterable<E> extends ListIterable<E> {
/// The length of the generated iterable.
diff --git a/sdk/lib/core/list.dart b/sdk/lib/core/list.dart
index 66de4e5..fff3d7a 100644
--- a/sdk/lib/core/list.dart
+++ b/sdk/lib/core/list.dart
@@ -108,7 +108,7 @@
* print(unique); // => [[499], [], []]
* ```
*/
- external factory List.filled(int length, E fill, {bool growable: false});
+ external factory List.filled(int length, E fill, {bool growable = false});
/**
* Creates a list containing all [elements].
@@ -127,7 +127,7 @@
* This constructor creates a growable list when [growable] is true;
* otherwise, it returns a fixed-length list.
*/
- external factory List.from(Iterable elements, {bool growable: true});
+ external factory List.from(Iterable elements, {bool growable = true});
/**
* Creates a list from [elements].
@@ -137,8 +137,8 @@
* This constructor creates a growable list when [growable] is true;
* otherwise, it returns a fixed-length list.
*/
- factory List.of(Iterable<E> elements, {bool growable: true}) =>
- new List<E>.from(elements, growable: growable);
+ factory List.of(Iterable<E> elements, {bool growable = true}) =>
+ List<E>.from(elements, growable: growable);
/**
* Generates a list of values.
@@ -152,12 +152,12 @@
* The created list is fixed-length unless [growable] is true.
*/
factory List.generate(int length, E generator(int index),
- {bool growable: true}) {
+ {bool growable = true}) {
List<E> result;
if (growable) {
result = <E>[]..length = length;
} else {
- result = new List<E>(length);
+ result = List<E>(length);
}
for (int i = 0; i < length; i++) {
result[i] = generator(i);
@@ -190,7 +190,7 @@
* of [S],
* then the returned list can be used as a `List<T>`.
*/
- static List<T> castFrom<S, T>(List<S> source) => new CastList<S, T>(source);
+ static List<T> castFrom<S, T>(List<S> source) => CastList<S, T>(source);
/**
* Copy a range of one list into another list.
@@ -214,7 +214,7 @@
end = RangeError.checkValidRange(start, end, source.length);
int length = end - start;
if (target.length < at + length) {
- throw new ArgumentError.value(target, "target",
+ throw ArgumentError.value(target, "target",
"Not big enough to hold $length elements at position $at");
}
if (!identical(source, target) || start >= at) {
@@ -247,7 +247,7 @@
int targetLength = target.length;
for (var element in source) {
if (index == targetLength) {
- throw new IndexError(targetLength, target);
+ throw IndexError(targetLength, target);
}
target[index] = element;
index++;
diff --git a/sdk/lib/core/map.dart b/sdk/lib/core/map.dart
index 0c2f586..f914fe1 100644
--- a/sdk/lib/core/map.dart
+++ b/sdk/lib/core/map.dart
@@ -170,7 +170,7 @@
* then the returned map can be used as a `Map<K2, V2>`.
*/
static Map<K2, V2> castFrom<K, V, K2, V2>(Map<K, V> source) =>
- new CastMap<K, V, K2, V2>(source);
+ CastMap<K, V, K2, V2>(source);
/**
* Creates a new map and adds all entries.
diff --git a/sdk/lib/core/null.dart b/sdk/lib/core/null.dart
index 212fb47..af7d86d 100644
--- a/sdk/lib/core/null.dart
+++ b/sdk/lib/core/null.dart
@@ -14,7 +14,7 @@
@pragma("vm:entry-point")
class Null {
factory Null._uninstantiable() {
- throw new UnsupportedError('class Null cannot be instantiated');
+ throw UnsupportedError('class Null cannot be instantiated');
}
external int get hashCode;
diff --git a/sdk/lib/core/num.dart b/sdk/lib/core/num.dart
index 33b8177..e04112c 100644
--- a/sdk/lib/core/num.dart
+++ b/sdk/lib/core/num.dart
@@ -471,7 +471,7 @@
static num parse(String input, [@deprecated num onError(String input)]) {
num result = tryParse(input);
if (result != null) return result;
- if (onError == null) throw new FormatException(input);
+ if (onError == null) throw FormatException(input);
return onError(input);
}
diff --git a/sdk/lib/core/regexp.dart b/sdk/lib/core/regexp.dart
index 757bb81..c0bd153 100644
--- a/sdk/lib/core/regexp.dart
+++ b/sdk/lib/core/regexp.dart
@@ -60,7 +60,7 @@
* interpolation is required.
*/
external factory RegExp(String source,
- {bool multiLine: false, bool caseSensitive: true});
+ {bool multiLine = false, bool caseSensitive = true});
/**
* Returns a regular expression that matches [text].
diff --git a/sdk/lib/core/set.dart b/sdk/lib/core/set.dart
index 7b477df..e57d974 100644
--- a/sdk/lib/core/set.dart
+++ b/sdk/lib/core/set.dart
@@ -111,7 +111,7 @@
* then the returned set can be used as a `Set<T>`.
*/
static Set<T> castFrom<S, T>(Set<S> source, {Set<R> Function<R>() newSet}) =>
- new CastSet<S, T>(source, newSet);
+ CastSet<S, T>(source, newSet);
/**
* Provides a view of this set as a set of [R] instances.
diff --git a/sdk/lib/core/stopwatch.dart b/sdk/lib/core/stopwatch.dart
index cdecaca..45d71ca 100644
--- a/sdk/lib/core/stopwatch.dart
+++ b/sdk/lib/core/stopwatch.dart
@@ -96,7 +96,7 @@
* The [elapsedTicks] counter converted to a [Duration].
*/
Duration get elapsed {
- return new Duration(microseconds: elapsedMicroseconds);
+ return Duration(microseconds: elapsedMicroseconds);
}
/**
diff --git a/sdk/lib/core/string.dart b/sdk/lib/core/string.dart
index 0c81f28..c611bd5 100644
--- a/sdk/lib/core/string.dart
+++ b/sdk/lib/core/string.dart
@@ -639,11 +639,11 @@
final String string;
Runes(this.string);
- RuneIterator get iterator => new RuneIterator(string);
+ RuneIterator get iterator => RuneIterator(string);
int get last {
if (string.length == 0) {
- throw new StateError('No elements.');
+ throw StateError('No elements.');
}
int length = string.length;
int code = string.codeUnitAt(length - 1);
@@ -716,7 +716,7 @@
index < string.length &&
_isLeadSurrogate(string.codeUnitAt(index - 1)) &&
_isTrailSurrogate(string.codeUnitAt(index))) {
- throw new ArgumentError('Index inside surrogate pair: $index');
+ throw ArgumentError('Index inside surrogate pair: $index');
}
}
diff --git a/sdk/lib/core/symbol.dart b/sdk/lib/core/symbol.dart
index 025aa85..a46ec97 100644
--- a/sdk/lib/core/symbol.dart
+++ b/sdk/lib/core/symbol.dart
@@ -7,7 +7,7 @@
/// Opaque name used by mirrors, invocations and [Function.apply].
abstract class Symbol {
/** The symbol corresponding to the name of the unary minus operator. */
- static const Symbol unaryMinus = const Symbol("unary-");
+ static const Symbol unaryMinus = Symbol("unary-");
/**
* The empty symbol.
@@ -15,7 +15,7 @@
* The empty symbol is the name of libraries with no library declaration,
* and the base-name of the unnamed constructor.
*/
- static const Symbol empty = const Symbol("");
+ static const Symbol empty = Symbol("");
/**
* Constructs a new [Symbol] representing the provided name.
diff --git a/sdk/lib/core/uri.dart b/sdk/lib/core/uri.dart
index 0c431b7..2c7d918 100644
--- a/sdk/lib/core/uri.dart
+++ b/sdk/lib/core/uri.dart
@@ -300,8 +300,8 @@
{String mimeType,
Encoding encoding,
Map<String, String> parameters,
- bool base64: false}) {
- UriData data = new UriData.fromString(content,
+ bool base64 = false}) {
+ UriData data = UriData.fromString(content,
mimeType: mimeType,
encoding: encoding,
parameters: parameters,
@@ -326,10 +326,10 @@
* encoded.
*/
factory Uri.dataFromBytes(List<int> bytes,
- {mimeType: "application/octet-stream",
+ {mimeType = "application/octet-stream",
Map<String, String> parameters,
- percentEncoded: false}) {
- UriData data = new UriData.fromBytes(bytes,
+ percentEncoded = false}) {
+ UriData data = UriData.fromBytes(bytes,
mimeType: mimeType,
parameters: parameters,
percentEncoded: percentEncoded);
@@ -804,7 +804,7 @@
// The following index-normalization belongs with the scanning, but is
// easier to do here because we already have extracted variables from the
// indices list.
- var indices = new List<int>(8);
+ var indices = List<int>(8);
// Set default values for each position.
// The value will either be correct in some cases where it isn't set
@@ -1012,11 +1012,11 @@
queryStart -= start;
fragmentStart -= start;
}
- return new _SimpleUri(uri, schemeEnd, hostStart, portStart, pathStart,
+ return _SimpleUri(uri, schemeEnd, hostStart, portStart, pathStart,
queryStart, fragmentStart, scheme);
}
- return new _Uri.notSimple(uri, start, end, schemeEnd, hostStart, portStart,
+ return _Uri.notSimple(uri, start, end, schemeEnd, hostStart, portStart,
pathStart, queryStart, fragmentStart, scheme);
}
@@ -1096,7 +1096,7 @@
* details.
*/
static String encodeQueryComponent(String component,
- {Encoding encoding: utf8}) {
+ {Encoding encoding = utf8}) {
return _Uri._uriEncode(_Uri._unreservedTable, component, encoding, true);
}
@@ -1127,7 +1127,7 @@
* UTF-8.
*/
static String decodeQueryComponent(String encodedComponent,
- {Encoding encoding: utf8}) {
+ {Encoding encoding = utf8}) {
return _Uri._uriDecode(
encodedComponent, 0, encodedComponent.length, encoding, true);
}
@@ -1171,7 +1171,7 @@
* is UTF-8.
*/
static Map<String, String> splitQueryString(String query,
- {Encoding encoding: utf8}) {
+ {Encoding encoding = utf8}) {
return query.split("&").fold({}, (map, element) {
int index = element.indexOf("=");
if (index == -1) {
@@ -1201,10 +1201,10 @@
/// Implementation of [parseIPv4Address] that can work on a substring.
static List<int> _parseIPv4Address(String host, int start, int end) {
void error(String msg, int position) {
- throw new FormatException('Illegal IPv4 address, $msg', host, position);
+ throw FormatException('Illegal IPv4 address, $msg', host, position);
}
- var result = new Uint8List(4);
+ var result = Uint8List(4);
int partIndex = 0;
int partStart = start;
for (int i = start; i < end; i++) {
@@ -1268,7 +1268,7 @@
// Helper function for reporting a badly formatted IPv6 address.
void error(String msg, [position]) {
- throw new FormatException('Illegal IPv6 address, $msg', host, position);
+ throw FormatException('Illegal IPv6 address, $msg', host, position);
}
// Parse a hex block.
@@ -1339,7 +1339,7 @@
} else if (parts.length != 8) {
error('an address without a wildcard must contain exactly 8 parts');
}
- List<int> bytes = new Uint8List(16);
+ List<int> bytes = Uint8List(16);
for (int i = 0, index = 0; i < parts.length; i++) {
int value = parts[i];
if (value == -1) {
@@ -1476,7 +1476,7 @@
if (portStart + 1 < pathStart) {
// Should throw because invalid.
port = int.parse(uri.substring(portStart + 1, pathStart), onError: (_) {
- throw new FormatException("Invalid port", uri, portStart + 1);
+ throw FormatException("Invalid port", uri, portStart + 1);
});
port = _makePort(port, scheme);
}
@@ -1491,8 +1491,7 @@
if (fragmentStart < end) {
fragment = _makeFragment(uri, fragmentStart + 1, end);
}
- return new _Uri._internal(
- scheme, userInfo, host, port, path, query, fragment);
+ return _Uri._internal(scheme, userInfo, host, port, path, query, fragment);
}
/// Implementation of [Uri.Uri].
@@ -1530,8 +1529,7 @@
if (host == null && path.startsWith("//")) {
host = "";
}
- return new _Uri._internal(
- scheme, userInfo, host, port, path, query, fragment);
+ return _Uri._internal(scheme, userInfo, host, port, path, query, fragment);
}
/// Implementation of [Uri.http].
@@ -1548,7 +1546,7 @@
String get authority {
if (!hasAuthority) return "";
- var sb = new StringBuffer();
+ var sb = StringBuffer();
_writeAuthority(sb);
return sb.toString();
}
@@ -1619,7 +1617,7 @@
// Report a parse failure.
static void _fail(String uri, int index, String message) {
- throw new FormatException(message, uri, index);
+ throw FormatException(message, uri, index);
}
static Uri _makeHttpUri(String scheme, String authority, String unencodedPath,
@@ -1649,15 +1647,14 @@
if (authority.codeUnitAt(hostEnd) == _RIGHT_BRACKET) break;
}
if (hostEnd == authority.length) {
- throw new FormatException(
+ throw FormatException(
"Invalid IPv6 host entry.", authority, hostStart);
}
Uri.parseIPv6Address(authority, hostStart + 1, hostEnd);
hostEnd++; // Skip the closing bracket.
if (hostEnd != authority.length &&
authority.codeUnitAt(hostEnd) != _COLON) {
- throw new FormatException(
- "Invalid end of authority", authority, hostEnd);
+ throw FormatException("Invalid end of authority", authority, hostEnd);
}
}
// Split host and port.
@@ -1672,7 +1669,7 @@
}
host = authority.substring(hostStart, hostEnd);
}
- return new Uri(
+ return Uri(
scheme: scheme,
userInfo: userInfo,
host: host,
@@ -1703,9 +1700,9 @@
segments.forEach((segment) {
if (segment.contains("/")) {
if (argumentError) {
- throw new ArgumentError("Illegal path character $segment");
+ throw ArgumentError("Illegal path character $segment");
} else {
- throw new UnsupportedError("Illegal path character $segment");
+ throw UnsupportedError("Illegal path character $segment");
}
}
});
@@ -1715,11 +1712,11 @@
List<String> segments, bool argumentError,
[int firstSegment = 0]) {
for (var segment in segments.skip(firstSegment)) {
- if (segment.contains(new RegExp(r'["*/:<>?\\|]'))) {
+ if (segment.contains(RegExp(r'["*/:<>?\\|]'))) {
if (argumentError) {
- throw new ArgumentError("Illegal character in path");
+ throw ArgumentError("Illegal character in path");
} else {
- throw new UnsupportedError("Illegal character in path: $segment");
+ throw UnsupportedError("Illegal character in path: $segment");
}
}
}
@@ -1731,11 +1728,11 @@
return;
}
if (argumentError) {
- throw new ArgumentError(
- "Illegal drive letter " + new String.fromCharCode(charCode));
+ throw ArgumentError(
+ "Illegal drive letter " + String.fromCharCode(charCode));
} else {
- throw new UnsupportedError(
- "Illegal drive letter " + new String.fromCharCode(charCode));
+ throw UnsupportedError(
+ "Illegal drive letter " + String.fromCharCode(charCode));
}
}
@@ -1747,10 +1744,10 @@
}
if (path.startsWith(sep)) {
// Absolute file:// URI.
- return new Uri(scheme: "file", pathSegments: segments);
+ return Uri(scheme: "file", pathSegments: segments);
} else {
// Relative URI.
- return new Uri(pathSegments: segments);
+ return Uri(pathSegments: segments);
}
}
@@ -1763,7 +1760,7 @@
if (path.length < 3 ||
path.codeUnitAt(1) != _COLON ||
path.codeUnitAt(2) != _BACKSLASH) {
- throw new ArgumentError(
+ throw ArgumentError(
r"Windows paths with \\?\ prefix must be absolute");
}
}
@@ -1774,8 +1771,7 @@
if (path.length > 1 && path.codeUnitAt(1) == _COLON) {
_checkWindowsDriveLetter(path.codeUnitAt(0), true);
if (path.length == 2 || path.codeUnitAt(2) != _BACKSLASH) {
- throw new ArgumentError(
- "Windows paths with drive letter must be absolute");
+ throw ArgumentError("Windows paths with drive letter must be absolute");
}
// Absolute file://C:/ URI.
var pathSegments = path.split(sep);
@@ -1783,7 +1779,7 @@
pathSegments.add(""); // Extra separator at end.
}
_checkWindowsPathReservedCharacters(pathSegments, true, 1);
- return new Uri(scheme: "file", pathSegments: pathSegments);
+ return Uri(scheme: "file", pathSegments: pathSegments);
}
if (path.startsWith(sep)) {
@@ -1798,8 +1794,7 @@
if (slashTerminated && pathSegments.last.isNotEmpty) {
pathSegments.add(""); // Extra separator at end.
}
- return new Uri(
- scheme: "file", host: hostPart, pathSegments: pathSegments);
+ return Uri(scheme: "file", host: hostPart, pathSegments: pathSegments);
} else {
// Absolute file:// URI.
var pathSegments = path.split(sep);
@@ -1807,7 +1802,7 @@
pathSegments.add(""); // Extra separator at end.
}
_checkWindowsPathReservedCharacters(pathSegments, true);
- return new Uri(scheme: "file", pathSegments: pathSegments);
+ return Uri(scheme: "file", pathSegments: pathSegments);
}
} else {
// Relative URI.
@@ -1818,7 +1813,7 @@
pathSegments.last.isNotEmpty) {
pathSegments.add(""); // Extra separator at end.
}
- return new Uri(pathSegments: pathSegments);
+ return Uri(pathSegments: pathSegments);
}
}
@@ -1889,14 +1884,12 @@
fragment = this._fragment;
}
- return new _Uri._internal(
- scheme, userInfo, host, port, path, query, fragment);
+ return _Uri._internal(scheme, userInfo, host, port, path, query, fragment);
}
Uri removeFragment() {
if (!this.hasFragment) return this;
- return new _Uri._internal(
- scheme, _userInfo, _host, _port, path, _query, null);
+ return _Uri._internal(scheme, _userInfo, _host, _port, path, _query, null);
}
List<String> get pathSegments {
@@ -1909,7 +1902,7 @@
}
result = (pathToSplit == "")
? const <String>[]
- : new List<String>.unmodifiable(
+ : List<String>.unmodifiable(
pathToSplit.split("/").map(Uri.decodeComponent));
_pathSegments = result;
return result;
@@ -1917,7 +1910,7 @@
Map<String, String> get queryParameters {
_queryParameters ??=
- new UnmodifiableMapView<String, String>(Uri.splitQueryString(query));
+ UnmodifiableMapView<String, String>(Uri.splitQueryString(query));
return _queryParameters;
}
@@ -1926,10 +1919,10 @@
Map queryParameterLists = _splitQueryStringAll(query);
for (var key in queryParameterLists.keys) {
queryParameterLists[key] =
- new List<String>.unmodifiable(queryParameterLists[key]);
+ List<String>.unmodifiable(queryParameterLists[key]);
}
_queryParameterLists =
- new Map<String, List<String>>.unmodifiable(queryParameterLists);
+ Map<String, List<String>>.unmodifiable(queryParameterLists);
}
return _queryParameterLists;
}
@@ -2009,7 +2002,7 @@
index += 3;
continue;
}
- buffer ??= new StringBuffer();
+ buffer ??= StringBuffer();
String slice = host.substring(sectionStart, index);
if (!isNormalized) slice = slice.toLowerCase();
buffer.write(slice);
@@ -2027,7 +2020,7 @@
} else if (_isRegNameChar(char)) {
if (isNormalized && _UPPER_CASE_A <= char && _UPPER_CASE_Z >= char) {
// Put initial slice in buffer and continue in non-normalized mode
- buffer ??= new StringBuffer();
+ buffer ??= StringBuffer();
if (sectionStart < index) {
buffer.write(host.substring(sectionStart, index));
sectionStart = index;
@@ -2046,7 +2039,7 @@
sourceLength = 2;
}
}
- buffer ??= new StringBuffer();
+ buffer ??= StringBuffer();
String slice = host.substring(sectionStart, index);
if (!isNormalized) slice = slice.toLowerCase();
buffer.write(slice);
@@ -2112,7 +2105,7 @@
bool ensureLeadingSlash = isFile || hasAuthority;
if (path == null && pathSegments == null) return isFile ? "/" : "";
if (path != null && pathSegments != null) {
- throw new ArgumentError('Both path and pathSegments specified');
+ throw ArgumentError('Both path and pathSegments specified');
}
String result;
if (path != null) {
@@ -2148,14 +2141,14 @@
Map<String, dynamic /*String|Iterable<String>*/ > queryParameters) {
if (query != null) {
if (queryParameters != null) {
- throw new ArgumentError('Both query and queryParameters specified');
+ throw ArgumentError('Both query and queryParameters specified');
}
return _normalizeOrSubstring(query, start, end, _queryCharTable,
escapeDelimiters: true);
}
if (queryParameters == null) return null;
- var result = new StringBuffer();
+ var result = StringBuffer();
var separator = "";
void writeParameter(String key, String value) {
@@ -2217,7 +2210,7 @@
if (lowerCase && _UPPER_CASE_A <= value && _UPPER_CASE_Z >= value) {
value |= 0x20;
}
- return new String.fromCharCode(value);
+ return String.fromCharCode(value);
}
if (firstDigit >= _LOWER_CASE_A || secondDigit >= _LOWER_CASE_A) {
// Either digit is lower case.
@@ -2233,7 +2226,7 @@
List<int> codeUnits;
if (char < 0x80) {
// ASCII, a single percent encoded sequence.
- codeUnits = new List(3);
+ codeUnits = List(3);
codeUnits[0] = _PERCENT;
codeUnits[1] = _hexDigits.codeUnitAt(char >> 4);
codeUnits[2] = _hexDigits.codeUnitAt(char & 0xf);
@@ -2249,7 +2242,7 @@
flag = 0xf0;
}
}
- codeUnits = new List(3 * encodedBytes);
+ codeUnits = List(3 * encodedBytes);
int index = 0;
while (--encodedBytes >= 0) {
int byte = ((char >> (6 * encodedBytes)) & 0x3f) | flag;
@@ -2260,7 +2253,7 @@
flag = 0x80; // Following bytes have only high bit set.
}
}
- return new String.fromCharCodes(codeUnits);
+ return String.fromCharCodes(codeUnits);
}
/**
@@ -2333,7 +2326,7 @@
}
replacement = _escapeChar(char);
}
- buffer ??= new StringBuffer();
+ buffer ??= StringBuffer();
buffer.write(component.substring(sectionStart, index));
buffer.write(replacement);
index += sourceLength;
@@ -2578,8 +2571,8 @@
}
}
String fragment = reference.hasFragment ? reference.fragment : null;
- return new _Uri._internal(targetScheme, targetUserInfo, targetHost,
- targetPort, targetPath, targetQuery, fragment);
+ return _Uri._internal(targetScheme, targetUserInfo, targetHost, targetPort,
+ targetPath, targetQuery, fragment);
}
bool get hasScheme => scheme.isNotEmpty;
@@ -2598,14 +2591,14 @@
String get origin {
if (scheme == "") {
- throw new StateError("Cannot use origin without a scheme: $this");
+ throw StateError("Cannot use origin without a scheme: $this");
}
if (scheme != "http" && scheme != "https") {
- throw new StateError(
+ throw StateError(
"Origin is only applicable schemes http and https: $this");
}
if (_host == null || _host == "") {
- throw new StateError(
+ throw StateError(
"A $scheme: URI should have a non-empty host name: $this");
}
if (_port == null) return "$scheme://$_host";
@@ -2614,15 +2607,14 @@
String toFilePath({bool windows}) {
if (scheme != "" && scheme != "file") {
- throw new UnsupportedError(
- "Cannot extract a file path from a $scheme URI");
+ throw UnsupportedError("Cannot extract a file path from a $scheme URI");
}
if (query != "") {
- throw new UnsupportedError(
+ throw UnsupportedError(
"Cannot extract a file path from a URI with a query component");
}
if (fragment != "") {
- throw new UnsupportedError(
+ throw UnsupportedError(
"Cannot extract a file path from a URI with a fragment component");
}
windows ??= _isWindows;
@@ -2631,14 +2623,14 @@
String _toFilePath() {
if (hasAuthority && host != "") {
- throw new UnsupportedError(
+ throw UnsupportedError(
"Cannot extract a non-Windows file path from a file URI "
"with an authority");
}
// Use path segments to have any escapes unescaped.
var pathSegments = this.pathSegments;
_checkNonWindowsPathReservedCharacters(pathSegments, false);
- var result = new StringBuffer();
+ var result = StringBuffer();
if (hasAbsolutePath) result.write("/");
result.writeAll(pathSegments, "/");
return result.toString();
@@ -2656,7 +2648,7 @@
} else {
_checkWindowsPathReservedCharacters(segments, false, 0);
}
- var result = new StringBuffer();
+ var result = StringBuffer();
if (uri.hasAbsolutePath && !hasDriveLetter) result.write(r"\");
if (uri.hasAuthority) {
var host = uri.host;
@@ -2695,7 +2687,7 @@
* The [UriData] object can be used to access the media type and data
* of a `data:` URI.
*/
- UriData get data => (scheme == "data") ? new UriData.fromUri(this) : null;
+ UriData get data => (scheme == "data") ? UriData.fromUri(this) : null;
String toString() {
return _text ??= _initializeText();
@@ -2703,7 +2695,7 @@
String _initializeText() {
assert(_text == null);
- StringBuffer sb = new StringBuffer();
+ StringBuffer sb = StringBuffer();
if (scheme.isNotEmpty) sb..write(scheme)..write(":");
if (hasAuthority || (scheme == "file")) {
// File URIS always have the authority, even if it is empty.
@@ -2739,7 +2731,7 @@
static List<String> _createList() => <String>[];
static Map<String, List<String>> _splitQueryStringAll(String query,
- {Encoding encoding: utf8}) {
+ {Encoding encoding = utf8}) {
var result = <String, List<String>>{};
int i = 0;
int start = 0;
@@ -2793,7 +2785,7 @@
if (0x61 <= charCode && charCode <= 0x66) {
byte = byte * 16 + charCode - 0x57;
} else {
- throw new ArgumentError("Invalid URL encoding");
+ throw ArgumentError("Invalid URL encoding");
}
}
}
@@ -2837,15 +2829,15 @@
bytes = text.substring(start, end).codeUnits;
}
} else {
- bytes = new List();
+ bytes = List();
for (int i = start; i < end; i++) {
var codeUnit = text.codeUnitAt(i);
if (codeUnit > 127) {
- throw new ArgumentError("Illegal percent encoding in URI");
+ throw ArgumentError("Illegal percent encoding in URI");
}
if (codeUnit == _PERCENT) {
if (i + 3 > text.length) {
- throw new ArgumentError('Truncated URI');
+ throw ArgumentError('Truncated URI');
}
bytes.add(_hexCharPairToByte(text, i + 1));
i += 2;
@@ -2874,7 +2866,7 @@
// be escaped or not.
// The unreserved characters of RFC 3986.
- static const _unreservedTable = const <int>[
+ static const _unreservedTable = <int>[
// LSB MSB
// | |
0x0000, // 0x00 - 0x0f 0000000000000000
@@ -2894,7 +2886,7 @@
];
// The unreserved characters of RFC 2396.
- static const _unreserved2396Table = const <int>[
+ static const _unreserved2396Table = <int>[
// LSB MSB
// | |
0x0000, // 0x00 - 0x0f 0000000000000000
@@ -2914,7 +2906,7 @@
];
// Table of reserved characters specified by ECMAScript 5.
- static const _encodeFullTable = const <int>[
+ static const _encodeFullTable = <int>[
// LSB MSB
// | |
0x0000, // 0x00 - 0x0f 0000000000000000
@@ -2934,7 +2926,7 @@
];
// Characters allowed in the scheme.
- static const _schemeTable = const <int>[
+ static const _schemeTable = <int>[
// LSB MSB
// | |
0x0000, // 0x00 - 0x0f 0000000000000000
@@ -2954,7 +2946,7 @@
];
// Characters allowed in scheme except for upper case letters.
- static const _schemeLowerTable = const <int>[
+ static const _schemeLowerTable = <int>[
// LSB MSB
// | |
0x0000, // 0x00 - 0x0f 0000000000000000
@@ -2978,7 +2970,7 @@
// / "*" / "+" / "," / ";" / "="
// RFC 3986 section 2.3.
// unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
- static const _subDelimitersTable = const <int>[
+ static const _subDelimitersTable = <int>[
// LSB MSB
// | |
0x0000, // 0x00 - 0x0f 0000000000000000
@@ -3000,7 +2992,7 @@
// General delimiter characters, RFC 3986 section 2.2.
// gen-delims = ":" / "/" / "?" / "#" / "[" / "]" / "@"
//
- static const _genDelimitersTable = const <int>[
+ static const _genDelimitersTable = <int>[
// LSB MSB
// | |
0x0000, // 0x00 - 0x0f 0000000000000000
@@ -3022,7 +3014,7 @@
// Characters allowed in the userinfo as of RFC 3986.
// RFC 3986 Appendix A
// userinfo = *( unreserved / pct-encoded / sub-delims / ':')
- static const _userinfoTable = const <int>[
+ static const _userinfoTable = <int>[
// LSB MSB
// | |
0x0000, // 0x00 - 0x0f 0000000000000000
@@ -3044,7 +3036,7 @@
// Characters allowed in the reg-name as of RFC 3986.
// RFC 3986 Appendix A
// reg-name = *( unreserved / pct-encoded / sub-delims )
- static const _regNameTable = const <int>[
+ static const _regNameTable = <int>[
// LSB MSB
// | |
0x0000, // 0x00 - 0x0f 0000000000000000
@@ -3066,7 +3058,7 @@
// Characters allowed in the path as of RFC 3986.
// RFC 3986 section 3.3.
// pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
- static const _pathCharTable = const <int>[
+ static const _pathCharTable = <int>[
// LSB MSB
// | |
0x0000, // 0x00 - 0x0f 0000000000000000
@@ -3087,7 +3079,7 @@
// Characters allowed in the path as of RFC 3986.
// RFC 3986 section 3.3 *and* slash.
- static const _pathCharOrSlashTable = const [
+ static const _pathCharOrSlashTable = [
// LSB MSB
// | |
0x0000, // 0x00 - 0x0f 0000000000000000
@@ -3110,7 +3102,7 @@
// Characters allowed in the query as of RFC 3986.
// RFC 3986 section 3.4.
// query = *( pchar / "/" / "?" )
- static const _queryCharTable = const [
+ static const _queryCharTable = [
// LSB MSB
// | |
0x0000, // 0x00 - 0x0f 0000000000000000
@@ -3197,8 +3189,8 @@
{String mimeType,
Encoding encoding,
Map<String, String> parameters,
- bool base64: false}) {
- StringBuffer buffer = new StringBuffer();
+ bool base64 = false}) {
+ StringBuffer buffer = StringBuffer();
List<int> indices = [_noScheme];
String charsetName;
String encodingName;
@@ -3222,7 +3214,7 @@
buffer.write(',');
_uriEncodeBytes(_uricTable, encoding.encode(content), buffer);
}
- return new UriData._(buffer.toString(), indices, null);
+ return UriData._(buffer.toString(), indices, null);
}
/**
@@ -3232,10 +3224,10 @@
* be more efficient if the [uri] itself isn't used.
*/
factory UriData.fromBytes(List<int> bytes,
- {mimeType: "application/octet-stream",
+ {mimeType = "application/octet-stream",
Map<String, String> parameters,
- percentEncoded: false}) {
- StringBuffer buffer = new StringBuffer();
+ percentEncoded = false}) {
+ StringBuffer buffer = StringBuffer();
List<int> indices = [_noScheme];
_writeUri(mimeType, null, parameters, buffer, indices);
indices.add(buffer.length);
@@ -3246,12 +3238,11 @@
buffer.write(';base64,');
indices.add(buffer.length - 1);
_base64.encoder
- .startChunkedConversion(
- new StringConversionSink.fromStringSink(buffer))
+ .startChunkedConversion(StringConversionSink.fromStringSink(buffer))
.addSlice(bytes, 0, bytes.length, true);
}
- return new UriData._(buffer.toString(), indices, null);
+ return UriData._(buffer.toString(), indices, null);
}
/**
@@ -3263,14 +3254,13 @@
*/
factory UriData.fromUri(Uri uri) {
if (uri.scheme != "data") {
- throw new ArgumentError.value(uri, "uri", "Scheme must be 'data'");
+ throw ArgumentError.value(uri, "uri", "Scheme must be 'data'");
}
if (uri.hasAuthority) {
- throw new ArgumentError.value(
- uri, "uri", "Data uri must not have authority");
+ throw ArgumentError.value(uri, "uri", "Data uri must not have authority");
}
if (uri.hasFragment) {
- throw new ArgumentError.value(
+ throw ArgumentError.value(
uri, "uri", "Data uri must not have a fragment part");
}
if (!uri.hasQuery) {
@@ -3298,8 +3288,7 @@
} else {
int slashIndex = _validateMimeType(mimeType);
if (slashIndex < 0) {
- throw new ArgumentError.value(
- mimeType, "mimeType", "Invalid MIME type");
+ throw ArgumentError.value(mimeType, "mimeType", "Invalid MIME type");
}
buffer.write(_Uri._uriEncode(
_tokenCharTable, mimeType.substring(0, slashIndex), utf8, false));
@@ -3316,10 +3305,10 @@
}
parameters?.forEach((key, value) {
if (key.isEmpty) {
- throw new ArgumentError.value("", "Parameter names must not be empty");
+ throw ArgumentError.value("", "Parameter names must not be empty");
}
if (value.isEmpty) {
- throw new ArgumentError.value(
+ throw ArgumentError.value(
"", "Parameter values must not be empty", 'parameters["$key"]');
}
if (indices != null) indices.add(buffer.length);
@@ -3396,7 +3385,7 @@
return _parse(uri.substring(5), 0, null);
}
}
- throw new FormatException("Does not start with 'data:'", uri, 0);
+ throw FormatException("Does not start with 'data:'", uri, 0);
}
/**
@@ -3419,7 +3408,7 @@
}
path = _Uri._normalizeOrSubstring(
_text, colonIndex + 1, end, _Uri._pathCharOrSlashTable);
- _uriCache = new _DataUri(this, path, query);
+ _uriCache = _DataUri(this, path, query);
return _uriCache;
}
@@ -3519,7 +3508,7 @@
}
}
// Fill result array.
- Uint8List result = new Uint8List(length);
+ Uint8List result = Uint8List(length);
if (length == text.length) {
result.setRange(0, length, text.codeUnits, start);
return result;
@@ -3538,7 +3527,7 @@
continue;
}
}
- throw new FormatException("Invalid percent escape", text, i);
+ throw FormatException("Invalid percent escape", text, i);
}
}
assert(index == result.length);
@@ -3564,7 +3553,7 @@
var charset = this.charset; // Returns "US-ASCII" if not present.
encoding = Encoding.getByName(charset);
if (encoding == null) {
- throw new UnsupportedError("Unknown charset: $charset");
+ throw UnsupportedError("Unknown charset: $charset");
}
}
String text = _text;
@@ -3624,13 +3613,13 @@
slashIndex = i;
continue;
}
- throw new FormatException("Invalid MIME type", text, i);
+ throw FormatException("Invalid MIME type", text, i);
}
}
if (slashIndex < 0 && i > start) {
// An empty MIME type is allowed, but if non-empty it must contain
// exactly one slash.
- throw new FormatException("Invalid MIME type", text, i);
+ throw FormatException("Invalid MIME type", text, i);
}
while (char != comma) {
// Parse parameters and/or "base64".
@@ -3653,7 +3642,7 @@
if (char != comma ||
i != lastSeparator + 7 /* "base64,".length */ ||
!text.startsWith("base64", lastSeparator + 1)) {
- throw new FormatException("Expecting '='", text, i);
+ throw FormatException("Expecting '='", text, i);
}
break;
}
@@ -3672,7 +3661,7 @@
text = text.replaceRange(i + 1, text.length, data);
}
}
- return new UriData._(text, indices, sourceUri);
+ return UriData._(text, indices, sourceUri);
}
/**
@@ -3701,7 +3690,7 @@
for (int i = 0; i < bytes.length; i++) {
var byte = bytes[i];
if (byte < 0 || byte > 255) {
- throw new ArgumentError.value(byte, "non-byte value");
+ throw ArgumentError.value(byte, "non-byte value");
}
}
}
@@ -3717,7 +3706,7 @@
// '(', ')', '<', '>', '@', ',', ';', ':', '\', '"', '/', '[, ']', '?', '='.
//
// In a data URI, we also need to escape '%' and '#' characters.
- static const _tokenCharTable = const [
+ static const _tokenCharTable = [
// LSB MSB
// | |
0x0000, // 0x00 - 0x0f 00000000 00000000
@@ -3747,7 +3736,7 @@
static const _uricTable = _Uri._queryCharTable;
// Characters allowed in base-64 encoding (alphanumeric, '/', '+' and '=').
- static const _base64Table = const [
+ static const _base64Table = [
// LSB MSB
// | |
0x0000, // 0x00 - 0x0f 00000000 00000000
@@ -3948,8 +3937,7 @@
// excluding escapes.
const pchar = "$unreserved$subDelims";
- var tables =
- new List<Uint8List>.generate(stateCount, (_) => new Uint8List(96));
+ var tables = List<Uint8List>.generate(stateCount, (_) => Uint8List(96));
// Helper function which initialize the table for [state] with a default
// transition and returns the table.
@@ -4251,14 +4239,14 @@
// Check original behavior - W3C spec is wonky!
bool isHttp = _isHttp;
if (_schemeEnd < 0) {
- throw new StateError("Cannot use origin without a scheme: $this");
+ throw StateError("Cannot use origin without a scheme: $this");
}
if (!isHttp && !_isHttps) {
- throw new StateError(
+ throw StateError(
"Origin is only applicable to schemes http and https: $this");
}
if (_hostStart == _portStart) {
- throw new StateError(
+ throw StateError(
"A $scheme: URI should have a non-empty host name: $this");
}
if (_hostStart == _schemeEnd + 3) {
@@ -4283,12 +4271,12 @@
}
}
parts.add(_uri.substring(start, end));
- return new List<String>.unmodifiable(parts);
+ return List<String>.unmodifiable(parts);
}
Map<String, String> get queryParameters {
if (!hasQuery) return const <String, String>{};
- return new UnmodifiableMapView<String, String>(Uri.splitQueryString(query));
+ return UnmodifiableMapView<String, String>(Uri.splitQueryString(query));
}
Map<String, List<String>> get queryParametersAll {
@@ -4296,9 +4284,9 @@
Map queryParameterLists = _Uri._splitQueryStringAll(query);
for (var key in queryParameterLists.keys) {
queryParameterLists[key] =
- new List<String>.unmodifiable(queryParameterLists[key]);
+ List<String>.unmodifiable(queryParameterLists[key]);
}
- return new Map<String, List<String>>.unmodifiable(queryParameterLists);
+ return Map<String, List<String>>.unmodifiable(queryParameterLists);
}
bool _isPort(String port) {
@@ -4311,15 +4299,8 @@
Uri removeFragment() {
if (!hasFragment) return this;
- return new _SimpleUri(
- _uri.substring(0, _fragmentStart),
- _schemeEnd,
- _hostStart,
- _portStart,
- _pathStart,
- _queryStart,
- _fragmentStart,
- _schemeCache);
+ return _SimpleUri(_uri.substring(0, _fragmentStart), _schemeEnd, _hostStart,
+ _portStart, _pathStart, _queryStart, _fragmentStart, _schemeCache);
}
Uri replace(
@@ -4389,8 +4370,7 @@
fragment = _uri.substring(_fragmentStart + 1);
}
- return new _Uri._internal(
- scheme, userInfo, host, port, path, query, fragment);
+ return _Uri._internal(scheme, userInfo, host, port, path, query, fragment);
}
Uri resolve(String reference) {
@@ -4425,7 +4405,7 @@
var delta = base._schemeEnd + 1;
var newUri = base._uri.substring(0, base._schemeEnd + 1) +
ref._uri.substring(ref._schemeEnd + 1);
- return new _SimpleUri(
+ return _SimpleUri(
newUri,
base._schemeEnd,
ref._hostStart + delta,
@@ -4444,7 +4424,7 @@
int delta = base._queryStart - ref._queryStart;
var newUri = base._uri.substring(0, base._queryStart) +
ref._uri.substring(ref._queryStart);
- return new _SimpleUri(
+ return _SimpleUri(
newUri,
base._schemeEnd,
base._hostStart,
@@ -4458,7 +4438,7 @@
int delta = base._fragmentStart - ref._fragmentStart;
var newUri = base._uri.substring(0, base._fragmentStart) +
ref._uri.substring(ref._fragmentStart);
- return new _SimpleUri(
+ return _SimpleUri(
newUri,
base._schemeEnd,
base._hostStart,
@@ -4474,7 +4454,7 @@
var delta = base._pathStart - ref._pathStart;
var newUri = base._uri.substring(0, base._pathStart) +
ref._uri.substring(ref._pathStart);
- return new _SimpleUri(
+ return _SimpleUri(
newUri,
base._schemeEnd,
base._hostStart,
@@ -4494,7 +4474,7 @@
var delta = base._pathStart - refStart + 1;
var newUri = "${base._uri.substring(0, base._pathStart)}/"
"${ref._uri.substring(refStart)}";
- return new _SimpleUri(
+ return _SimpleUri(
newUri,
base._schemeEnd,
base._hostStart,
@@ -4573,7 +4553,7 @@
var newUri = "${base._uri.substring(0, baseEnd)}$insert"
"${ref._uri.substring(refStart)}";
- return new _SimpleUri(
+ return _SimpleUri(
newUri,
base._schemeEnd,
base._hostStart,
@@ -4586,15 +4566,14 @@
String toFilePath({bool windows}) {
if (_schemeEnd >= 0 && !_isFile) {
- throw new UnsupportedError(
- "Cannot extract a file path from a $scheme URI");
+ throw UnsupportedError("Cannot extract a file path from a $scheme URI");
}
if (_queryStart < _uri.length) {
if (_queryStart < _fragmentStart) {
- throw new UnsupportedError(
+ throw UnsupportedError(
"Cannot extract a file path from a URI with a query component");
}
- throw new UnsupportedError(
+ throw UnsupportedError(
"Cannot extract a file path from a URI with a fragment component");
}
windows ??= _Uri._isWindows;
@@ -4604,7 +4583,7 @@
String _toFilePath() {
if (_hostStart < _portStart) {
// Has authority and non-empty host.
- throw new UnsupportedError(
+ throw UnsupportedError(
"Cannot extract a non-Windows file path from a file URI "
"with an authority");
}
@@ -4624,7 +4603,7 @@
}
Uri _toNonSimple() {
- return new _Uri._internal(
+ return _Uri._internal(
this.scheme,
this.userInfo,
this.hasAuthority ? this.host : null,