Change core lib, dart2js, and more for new optional parameters syntax and semantics (new semantics is not enforced yet).
Review URL: https://codereview.chromium.org//11090016
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge@13684 260f80e4-7a28-3924-810f-c04153c831b5
diff --git a/lib/src/git.dart b/lib/src/git.dart
index 31e8b27..12c6a02 100644
--- a/lib/src/git.dart
+++ b/lib/src/git.dart
@@ -25,7 +25,7 @@
/// list of strings if it succeeded. Completes to an exception if it failed.
Future<List<String>> run(List<String> args, [String workingDir]) {
return _gitCommand.chain((git) {
- return runProcess(git, args, workingDir);
+ return runProcess(git, args, workingDir: workingDir);
}).transform((result) {
if (!result.success) throw new Exception(
'Git error. Command: git ${Strings.join(args, " ")}\n'
diff --git a/lib/src/git_source.dart b/lib/src/git_source.dart
index 3530de6..76900a5 100644
--- a/lib/src/git_source.dart
+++ b/lib/src/git_source.dart
@@ -66,7 +66,7 @@
/**
* Ensures [description] is a Git URL.
*/
- void validateDescription(description, [bool fromLockFile = false]) {
+ void validateDescription(description, {bool fromLockFile: false}) {
// A single string is assumed to be a Git URL.
if (description is String) return;
if (description is! Map || !description.containsKey('url')) {
diff --git a/lib/src/hosted_source.dart b/lib/src/hosted_source.dart
index b3676b8..47cda67 100644
--- a/lib/src/hosted_source.dart
+++ b/lib/src/hosted_source.dart
@@ -126,7 +126,7 @@
* given name from the default host, while a map with keys "name" and "url"
* refers to a package with the given name from the host at the given URL.
*/
- void validateDescription(description, [bool fromLockFile=false]) {
+ void validateDescription(description, {bool fromLockFile: false}) {
_parseDescription(description);
}
diff --git a/lib/src/io.dart b/lib/src/io.dart
index 6981e28..f3ae4c7 100644
--- a/lib/src/io.dart
+++ b/lib/src/io.dart
@@ -481,8 +481,8 @@
* piped streams won't be available in the result object.
*/
Future<PubProcessResult> runProcess(String executable, List<String> args,
- [workingDir, Map<String, String> environment, bool pipeStdout = false,
- bool pipeStderr = false]) {
+ {workingDir, Map<String, String> environment, bool pipeStdout: false,
+ bool pipeStderr: false}) {
int exitCode;
// TODO(rnystrom): Should dart:io just handle this?
@@ -556,8 +556,8 @@
}
/// Run a git process with [args] from [workingDir].
-Future<PubProcessResult> runGit(List<String> args, [String workingDir]) =>
- _gitCommand.chain((git) => runProcess(git, args, workingDir));
+Future<PubProcessResult> runGit(List<String> args, {String workingDir}) =>
+ _gitCommand.chain((git) => runProcess(git, args, workingDir: workingDir));
/// Returns the name of the git command-line app, or null if Git could not be
/// found on the user's PATH.
diff --git a/lib/src/source.dart b/lib/src/source.dart
index 69f476c..bb956c9 100644
--- a/lib/src/source.dart
+++ b/lib/src/source.dart
@@ -154,7 +154,7 @@
* [fromLockFile] is true when the description comes from a [LockFile], to
* allow the source to use lockfile-specific descriptions via [resolveId].
*/
- void validateDescription(description, [bool fromLockFile=false]) {}
+ void validateDescription(description, {bool fromLockFile: false}) {}
/**
* Returns whether or not [description1] describes the same package as
diff --git a/lib/src/version.dart b/lib/src/version.dart
index 82bc015..98fcf72 100644
--- a/lib/src/version.dart
+++ b/lib/src/version.dart
@@ -41,7 +41,7 @@
final String build;
/** Creates a new [Version] object. */
- Version(this.major, this.minor, this.patch, [String pre, this.build])
+ Version(this.major, this.minor, this.patch, {String pre, this.build})
: preRelease = pre {
if (major < 0) throw new ArgumentError(
'Major version must be non-negative.');
@@ -68,7 +68,7 @@
String preRelease = match[5];
String build = match[8];
- return new Version(major, minor, patch, preRelease, build);
+ return new Version(major, minor, patch, pre: preRelease, build: build);
} on FormatException catch (ex) {
throw new FormatException('Could not parse "$text".');
}
@@ -257,8 +257,8 @@
final bool includeMin;
final bool includeMax;
- VersionRange([this.min, this.max,
- this.includeMin = false, this.includeMax = false]) {
+ VersionRange({this.min, this.max,
+ this.includeMin: false, this.includeMax: false}) {
if (min != null && max != null && min > max) {
throw new ArgumentError(
'Minimum version ("$min") must be less than maximum ("$max").');
@@ -339,8 +339,8 @@
}
// If we got here, there is an actual range.
- return new VersionRange(intersectMin, intersectMax,
- intersectIncludeMin, intersectIncludeMax);
+ return new VersionRange(min: intersectMin, max: intersectMax,
+ includeMin: intersectIncludeMin, includeMax: intersectIncludeMax);
}
throw new ArgumentError(
diff --git a/lib/src/yaml/model.dart b/lib/src/yaml/model.dart
index 710baf6..1247a71 100644
--- a/lib/src/yaml/model.dart
+++ b/lib/src/yaml/model.dart
@@ -118,7 +118,7 @@
* should be specified for a composed scalar, although `null` is a valid
* value.
*/
- _ScalarNode(String tagName, [String content, this.value])
+ _ScalarNode(String tagName, {String content, this.value})
: _content = content,
super(new _Tag.scalar(tagName));
diff --git a/lib/src/yaml/parser.dart b/lib/src/yaml/parser.dart
index 4423cf6..b3c69df 100644
--- a/lib/src/yaml/parser.dart
+++ b/lib/src/yaml/parser.dart
@@ -915,7 +915,7 @@
if (!truth(c_indicator(C_DOUBLE_QUOTE))) return null;
var contents = nb_doubleText(indent, ctx);
if (!truth(c_indicator(C_DOUBLE_QUOTE))) return null;
- return new _ScalarNode("!", contents);
+ return new _ScalarNode("!", content: contents);
});
});
@@ -1003,7 +1003,7 @@
if (!truth(c_indicator(C_SINGLE_QUOTE))) return null;
var contents = nb_singleText(indent, ctx);
if (!truth(c_indicator(C_SINGLE_QUOTE))) return null;
- return new _ScalarNode("!", contents);
+ return new _ScalarNode("!", content: contents);
});
});
@@ -1535,7 +1535,7 @@
var content = l_literalContent(indent + additionalIndent, header.chomping);
if (!truth(content)) return null;
- return new _ScalarNode("!", content);
+ return new _ScalarNode("!", content: content);
});
// 171
@@ -1572,7 +1572,7 @@
var content = l_foldedContent(indent + additionalIndent, header.chomping);
if (!truth(content)) return null;
- return new _ScalarNode("!", content);
+ return new _ScalarNode("!", content: content);
});
// 175