Preserve "?" in function-typed initializing formals.
Fix #960.
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ae83093..a5f41bd 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+# 1.3.8
+
+* Preserve `?` in initializing formal function-typed parameters (#960).
+
# 1.3.7
* Split help into verbose and non-verbose lists (#938).
diff --git a/lib/src/cli/formatter_options.dart b/lib/src/cli/formatter_options.dart
index a3f20ba..8fd0d03 100644
--- a/lib/src/cli/formatter_options.dart
+++ b/lib/src/cli/formatter_options.dart
@@ -13,7 +13,7 @@
import 'summary.dart';
// Note: The following line of code is modified by tool/grind.dart.
-const dartStyleVersion = '1.3.7';
+const dartStyleVersion = '1.3.8';
/// Global options that affect how the formatter produces and uses its outputs.
class FormatterOptions {
diff --git a/lib/src/source_visitor.dart b/lib/src/source_visitor.dart
index 1f63c6c..1fbdaca 100644
--- a/lib/src/source_visitor.dart
+++ b/lib/src/source_visitor.dart
@@ -1443,6 +1443,7 @@
token(node.period);
visit(node.identifier);
visit(node.parameters);
+ token(node.question);
_endFormalParameter(node);
});
}
diff --git a/pubspec.lock b/pubspec.lock
index ee29188..544b9cc 100644
--- a/pubspec.lock
+++ b/pubspec.lock
@@ -35,21 +35,21 @@
name: async
url: "https://pub.dartlang.org"
source: hosted
- version: "2.5.0-nullsafety"
+ version: "2.5.0-nullsafety.1"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
url: "https://pub.dartlang.org"
source: hosted
- version: "2.1.0-nullsafety"
+ version: "2.1.0-nullsafety.1"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
- version: "1.2.0-nullsafety"
+ version: "1.2.0-nullsafety.1"
cli_util:
dependency: transitive
description:
@@ -63,7 +63,7 @@
name: collection
url: "https://pub.dartlang.org"
source: hosted
- version: "1.15.0-nullsafety.2"
+ version: "1.15.0-nullsafety.3"
convert:
dependency: transitive
description:
@@ -147,7 +147,7 @@
name: js
url: "https://pub.dartlang.org"
source: hosted
- version: "0.6.3-nullsafety"
+ version: "0.6.3-nullsafety.1"
logging:
dependency: transitive
description:
@@ -161,14 +161,14 @@
name: matcher
url: "https://pub.dartlang.org"
source: hosted
- version: "0.12.10-nullsafety"
+ version: "0.12.10-nullsafety.1"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
source: hosted
- version: "1.3.0-nullsafety.2"
+ version: "1.3.0-nullsafety.4"
mime:
dependency: transitive
description:
@@ -210,21 +210,21 @@
name: path
url: "https://pub.dartlang.org"
source: hosted
- version: "1.8.0-nullsafety"
+ version: "1.8.0-nullsafety.1"
pedantic:
dependency: "direct dev"
description:
name: pedantic
url: "https://pub.dartlang.org"
source: hosted
- version: "1.10.0-nullsafety"
+ version: "1.10.0-nullsafety.1"
pool:
dependency: transitive
description:
name: pool
url: "https://pub.dartlang.org"
source: hosted
- version: "1.5.0-nullsafety"
+ version: "1.5.0-nullsafety.1"
pub_semver:
dependency: "direct dev"
description:
@@ -266,70 +266,70 @@
name: source_map_stack_trace
url: "https://pub.dartlang.org"
source: hosted
- version: "2.1.0-nullsafety.1"
+ version: "2.1.0-nullsafety.2"
source_maps:
dependency: transitive
description:
name: source_maps
url: "https://pub.dartlang.org"
source: hosted
- version: "0.10.10-nullsafety"
+ version: "0.10.10-nullsafety.1"
source_span:
dependency: "direct main"
description:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
- version: "1.8.0-nullsafety"
+ version: "1.8.0-nullsafety.2"
stack_trace:
dependency: transitive
description:
name: stack_trace
url: "https://pub.dartlang.org"
source: hosted
- version: "1.10.0-nullsafety"
+ version: "1.10.0-nullsafety.4"
stream_channel:
dependency: transitive
description:
name: stream_channel
url: "https://pub.dartlang.org"
source: hosted
- version: "2.1.0-nullsafety"
+ version: "2.1.0-nullsafety.1"
string_scanner:
dependency: transitive
description:
name: string_scanner
url: "https://pub.dartlang.org"
source: hosted
- version: "1.1.0-nullsafety"
+ version: "1.1.0-nullsafety.1"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.dartlang.org"
source: hosted
- version: "1.2.0-nullsafety"
+ version: "1.2.0-nullsafety.1"
test:
dependency: "direct dev"
description:
name: test
url: "https://pub.dartlang.org"
source: hosted
- version: "1.16.0-nullsafety.2"
+ version: "1.16.0-nullsafety.5"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
- version: "0.2.19-nullsafety"
+ version: "0.2.19-nullsafety.2"
test_core:
dependency: transitive
description:
name: test_core
url: "https://pub.dartlang.org"
source: hosted
- version: "0.3.12-nullsafety.2"
+ version: "0.3.12-nullsafety.5"
test_descriptor:
dependency: "direct dev"
description:
@@ -350,7 +350,7 @@
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
- version: "1.3.0-nullsafety.2"
+ version: "1.3.0-nullsafety.3"
vm_service:
dependency: transitive
description:
@@ -387,4 +387,4 @@
source: hosted
version: "2.2.1"
sdks:
- dart: ">=2.10.0-0 <2.10.0"
+ dart: ">=2.10.0-78 <=2.11.0-edge.67c703063d5b68c9e132edbaf34dfe375851f5a6"
diff --git a/pubspec.yaml b/pubspec.yaml
index 92d9bbe..2f6d6cc 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,6 +1,6 @@
name: dart_style
# Note: See tool/grind.dart for how to bump the version.
-version: 1.3.7
+version: 1.3.8
description: >-
Opinionated, automatic Dart source code formatter.
Provides an API and a CLI tool.
diff --git a/test/regression/0900/0960.unit b/test/regression/0900/0960.unit
new file mode 100644
index 0000000..a098c76
--- /dev/null
+++ b/test/regression/0900/0960.unit
@@ -0,0 +1,18 @@
+>>>
+const m = 0;
+
+class C {
+ var z, w, u, v;
+ C({@m int this.v()?});
+}
+
+void main() {}
+<<<
+const m = 0;
+
+class C {
+ var z, w, u, v;
+ C({@m int this.v()?});
+}
+
+void main() {}
\ No newline at end of file
diff --git a/test/whitespace/functions.unit b/test/whitespace/functions.unit
index 82db3d1..e17e716 100644
--- a/test/whitespace/functions.unit
+++ b/test/whitespace/functions.unit
@@ -174,6 +174,14 @@
function(
int? callback()?,
) {}
+>>> nullable old style named function typed parameter
+function({int? callback() ? }) {}
+<<<
+function({int? callback()?}) {}
+>>> nullable old style initializing formal function typed parameter
+function(int? this.callback() ? ) {}
+<<<
+function(int? this.callback()?) {}
>>> required parameters
class A {
f({ required int a,required b}) {}