Merge branch 'nested-ternary' of https://github.com/RedHatter/dart_style into RedHatter-nested-ternary
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 19d2c55..63249e0 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,8 @@
+# 2.0.1
+
+* Support triple-shift `>>>` and `>>>=` operators (#992).
+* Support non-function type aliases (#993).
+
# 2.0.0
* Migrate to null safety.
diff --git a/LICENSE b/LICENSE
index 5c60afe..000cd7b 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,4 +1,5 @@
-Copyright 2014, the Dart project authors. All rights reserved.
+Copyright 2014, the Dart project authors.
+
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
@@ -9,7 +10,7 @@
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
- * Neither the name of Google Inc. nor the names of its
+ * Neither the name of Google LLC nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
diff --git a/lib/src/dart_formatter.dart b/lib/src/dart_formatter.dart
index eac9377..7f437a9 100644
--- a/lib/src/dart_formatter.dart
+++ b/lib/src/dart_formatter.dart
@@ -87,8 +87,12 @@
// TODO(paulberry): consider plumbing in experiment enable flags from the
// command line.
var featureSet = FeatureSet.fromEnableFlags2(
- sdkLanguageVersion: Version(2, 10, 0),
- flags: ['non-nullable', 'generic-metadata']);
+ sdkLanguageVersion: Version(2, 13, 0),
+ flags: [
+ 'generic-metadata',
+ 'nonfunction-type-aliases',
+ 'triple-shift'
+ ]);
var inputOffset = 0;
var text = source.text;
diff --git a/lib/src/line_splitting/solve_state.dart b/lib/src/line_splitting/solve_state.dart
index 6701c7a..a90a246 100644
--- a/lib/src/line_splitting/solve_state.dart
+++ b/lib/src/line_splitting/solve_state.dart
@@ -569,7 +569,7 @@
buffer.write(' \$${splits.cost}');
- if (overflowChars > 0) buffer.write(' (${overflowChars} over)');
+ if (overflowChars > 0) buffer.write(' ($overflowChars over)');
if (!_isComplete) buffer.write(' (incomplete)');
return buffer.toString();
diff --git a/lib/src/source_visitor.dart b/lib/src/source_visitor.dart
index fa25d91..7678743 100644
--- a/lib/src/source_visitor.dart
+++ b/lib/src/source_visitor.dart
@@ -1822,7 +1822,7 @@
space();
- visit(node.functionType);
+ visit(node.type);
});
}
diff --git a/pubspec.lock b/pubspec.lock
index 35fc3e4..6a4251e 100644
--- a/pubspec.lock
+++ b/pubspec.lock
@@ -7,14 +7,14 @@
name: _fe_analyzer_shared
url: "https://pub.dartlang.org"
source: hosted
- version: "17.0.0"
+ version: "19.0.0"
analyzer:
dependency: "direct main"
description:
name: analyzer
url: "https://pub.dartlang.org"
source: hosted
- version: "1.1.0"
+ version: "1.3.0"
args:
dependency: "direct main"
description:
@@ -70,7 +70,7 @@
name: coverage
url: "https://pub.dartlang.org"
source: hosted
- version: "0.15.2"
+ version: "1.0.2"
crypto:
dependency: transitive
description:
@@ -91,21 +91,21 @@
name: glob
url: "https://pub.dartlang.org"
source: hosted
- version: "2.0.0"
+ version: "2.0.1"
grinder:
dependency: "direct dev"
description:
name: grinder
url: "https://pub.dartlang.org"
source: hosted
- version: "0.9.0-nullsafety.0"
+ version: "0.9.0"
http_multi_server:
dependency: transitive
description:
name: http_multi_server
url: "https://pub.dartlang.org"
source: hosted
- version: "2.2.0"
+ version: "3.0.0"
http_parser:
dependency: transitive
description:
@@ -119,7 +119,7 @@
name: io
url: "https://pub.dartlang.org"
source: hosted
- version: "0.3.5"
+ version: "1.0.0"
js:
dependency: "direct dev"
description:
@@ -133,7 +133,7 @@
name: logging
url: "https://pub.dartlang.org"
source: hosted
- version: "1.0.0"
+ version: "1.0.1"
matcher:
dependency: transitive
description:
@@ -161,7 +161,7 @@
name: node_preamble
url: "https://pub.dartlang.org"
source: hosted
- version: "1.4.13"
+ version: "2.0.0"
package_config:
dependency: transitive
description:
@@ -182,7 +182,7 @@
name: pedantic
url: "https://pub.dartlang.org"
source: hosted
- version: "1.10.0"
+ version: "1.11.0"
pool:
dependency: transitive
description:
@@ -203,28 +203,28 @@
name: shelf
url: "https://pub.dartlang.org"
source: hosted
- version: "1.0.0"
+ version: "1.1.0"
shelf_packages_handler:
dependency: transitive
description:
name: shelf_packages_handler
url: "https://pub.dartlang.org"
source: hosted
- version: "2.0.1"
+ version: "3.0.0"
shelf_static:
dependency: transitive
description:
name: shelf_static
url: "https://pub.dartlang.org"
source: hosted
- version: "0.2.9+2"
+ version: "1.0.0"
shelf_web_socket:
dependency: transitive
description:
name: shelf_web_socket
url: "https://pub.dartlang.org"
source: hosted
- version: "0.2.4+1"
+ version: "1.0.1"
source_map_stack_trace:
dependency: transitive
description:
@@ -280,21 +280,21 @@
name: test
url: "https://pub.dartlang.org"
source: hosted
- version: "1.16.4"
+ version: "1.16.8"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
- version: "0.2.19"
+ version: "0.3.0"
test_core:
dependency: transitive
description:
name: test_core
url: "https://pub.dartlang.org"
source: hosted
- version: "0.3.14"
+ version: "0.3.19"
test_descriptor:
dependency: "direct dev"
description:
@@ -343,7 +343,7 @@
name: webkit_inspection_protocol
url: "https://pub.dartlang.org"
source: hosted
- version: "0.7.5"
+ version: "1.0.0"
yaml:
dependency: "direct dev"
description:
@@ -352,4 +352,4 @@
source: hosted
version: "3.1.0"
sdks:
- dart: ">=2.12.0-0.0 <3.0.0"
+ dart: ">=2.12.0 <3.0.0"
diff --git a/pubspec.yaml b/pubspec.yaml
index 13586ed..cfcc9d3 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: 2.0.0
+version: 2.0.1-dev
description: >-
Opinionated, automatic Dart source code formatter.
Provides an API and a CLI tool.
@@ -10,7 +10,7 @@
sdk: '>=2.12.0-0 <3.0.0'
dependencies:
- analyzer: ^1.1.0
+ analyzer: ^1.3.0
args: '>=1.0.0 <3.0.0'
path: ^1.0.0
pub_semver: '>=1.4.4 <3.0.0'
@@ -23,7 +23,7 @@
# and publishing to npm hasn't been used in a while.
# node_preamble: ^1.0.0
pedantic: ^1.0.0
- test: ^1.16.0
+ test: ^1.16.8
test_descriptor: ^2.0.0
test_process: ^2.0.0
yaml: '>=2.0.0 <4.0.0'
diff --git a/test/splitting/mixed.stmt b/test/splitting/mixed.stmt
index 97ba507..7d8dfff 100644
--- a/test/splitting/mixed.stmt
+++ b/test/splitting/mixed.stmt
@@ -170,12 +170,12 @@
longName -
longName;
>>> mixed shift operators
-longName >> longName << longName >> longName << longName;
+longName >> longName << longName >> longName >>> longName;
<<<
longName >>
longName <<
longName >>
- longName <<
+ longName >>>
longName;
>>> mixture of same and different precedence
veryLongIdentifier + veryLongIdentifier / veryLongIdentifier *
diff --git a/test/splitting/typedef.unit b/test/splitting/typedef.unit
index aa0760f..e2a89a0 100644
--- a/test/splitting/typedef.unit
+++ b/test/splitting/typedef.unit
@@ -60,4 +60,30 @@
First first,
Second second,
Third third,
- Fourth fourth);
\ No newline at end of file
+ Fourth fourth);
+>>> non-function split type parameters
+typedef G = SomeType<TypeOne, TypeTwo, TypeThree>;
+<<<
+typedef G = SomeType<TypeOne, TypeTwo,
+ TypeThree>;
+>>> non-function split all type parameters
+typedef G = SomeType<TypeOne, TypeTwo, TypeThree, TypeFour, TypeFive, TypeSix>;
+<<<
+typedef G = SomeType<
+ TypeOne,
+ TypeTwo,
+ TypeThree,
+ TypeFour,
+ TypeFive,
+ TypeSix>;
+>>> non-function generic typedef parameters on one line
+typedef Foo<T, S> = SomeType;
+<<<
+typedef Foo<T, S> = SomeType;
+>>> non-function generic typedef parameters that split
+typedef LongGenericType<First, Second, Third, Fourth, Fifth, Sixth> = AnotherType<First, Second, Third, Fourth>;
+<<<
+typedef LongGenericType<First, Second,
+ Third, Fourth, Fifth, Sixth>
+ = AnotherType<First, Second, Third,
+ Fourth>;
\ No newline at end of file
diff --git a/test/whitespace/expressions.stmt b/test/whitespace/expressions.stmt
index 0d300e9..1a138dc 100644
--- a/test/whitespace/expressions.stmt
+++ b/test/whitespace/expressions.stmt
@@ -3,6 +3,10 @@
var a=1+2/(3*-b~/4);
<<<
var a = 1 + 2 / (3 * -b ~/ 4);
+>>> triple-shift
+a>>>=1>>>-2>>>3;
+<<<
+a >>>= 1 >>> -2 >>> 3;
>>> conditional operator
var c=!condition==a>b;
<<<
diff --git a/test/whitespace/metadata.unit b/test/whitespace/metadata.unit
index 87ed0b7..37a311a 100644
--- a/test/whitespace/metadata.unit
+++ b/test/whitespace/metadata.unit
@@ -270,6 +270,11 @@
<<<
@foo
typedef Fn = Function();
+>>> metadata on non-function typedef
+@foo typedef Hash< @a K, @b ( 1 ) V > = Map < K , V > ;
+<<<
+@foo
+typedef Hash<@a K, @b(1) V> = Map<K, V>;
>>> single metadata on for-in loop variable
main() {
for ( @a var i in list) {;}
diff --git a/test/whitespace/typedef.unit b/test/whitespace/typedef.unit
index 71d697c..9cfaad8 100644
--- a/test/whitespace/typedef.unit
+++ b/test/whitespace/typedef.unit
@@ -37,4 +37,17 @@
>>> generic function
typedef Foo =Function < A ,B > ( A a,B b );
<<<
-typedef Foo = Function<A, B>(A a, B b);
\ No newline at end of file
+typedef Foo = Function<A, B>(A a, B b);
+>>>
+typedef Foo = Bar;
+<<<
+typedef Foo = Bar;
+>>> non-function typedef
+typedef Json = Map < String , Object ? > ;
+<<<
+typedef Json = Map<String, Object?>;
+>>> non-function generic typedef
+typedef Hash < K extends List < T > , V > = Map < K , V > ;
+<<<
+typedef Hash<K extends List<T>, V>
+ = Map<K, V>;
\ No newline at end of file