Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: dart-lang/dart_style
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 2.0.0
Choose a base ref
...
head repository: dart-lang/dart_style
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 2.0.1
Choose a head ref
  • 18 commits
  • 18 files changed
  • 4 contributors

Commits on Mar 29, 2021

  1. Support triple-shift operators.

    Fix #992.
    munificent committed Mar 29, 2021
    Copy the full SHA
    ddca262 View commit details
  2. Fix lint.

    munificent committed Mar 29, 2021
    Copy the full SHA
    c21c6ff View commit details
  3. Copy the full SHA
    1630914 View commit details

Commits on Mar 30, 2021

  1. Merge pull request #1011 from dart-lang/triple-shift

    Support triple-shift operators.
    munificent authored Mar 30, 2021
    Copy the full SHA
    fc5655f View commit details
  2. Support non-function type aliases.

    Fix #993.
    munificent committed Mar 30, 2021

    Verified

    This commit was signed with the committer’s verified signature.
    stsewd Santos Gallegos
    Copy the full SHA
    f7cb290 View commit details
  3. Copy the full SHA
    36ea5d0 View commit details

Commits on Mar 31, 2021

  1. Merge pull request #1013 from dart-lang/type-aliases

    Support non-function type aliases.
    munificent authored Mar 31, 2021
    Copy the full SHA
    939ede3 View commit details

Commits on Apr 1, 2021

  1. Update LICENSE

    Changes to comply with internal review
    franklinyow authored Apr 1, 2021
    Copy the full SHA
    a89346e View commit details
  2. Copy the full SHA
    78eef23 View commit details

Commits on Apr 2, 2021

  1. Merge branch 'nested-ternary' of https://github.com/RedHatter/dart_style

     into RedHatter-nested-ternary
    munificent committed Apr 2, 2021
    Copy the full SHA
    b20e7a5 View commit details
  2. Copy the full SHA
    31e9318 View commit details
  3. Copy the full SHA
    ad4d861 View commit details
  4. Merge pull request #1015 from dart-lang/1010-init-after-required

    Correct constructor initializer indentation after "required".
    munificent authored Apr 2, 2021
    Copy the full SHA
    4b931ff View commit details

Commits on Apr 3, 2021

  1. Bump for 2.0.1 release.

    munificent committed Apr 3, 2021
    Copy the full SHA
    042a2a4 View commit details
  2. Merge pull request #1016 from dart-lang/bump-2.0.1

    Bump for 2.0.1 release.
    munificent authored Apr 3, 2021
    Copy the full SHA
    0067cfc View commit details

Commits on Apr 9, 2021

  1. Revert the change to flatten nested conditionals.

    This leaves the tests and commented out implementation in place in case
    we decide to re-enable the change later, but it's too close to Dart 2.13
    and I've heard too much negative feedback to push it out right now.
    munificent committed Apr 9, 2021
    Copy the full SHA
    f71240c View commit details
  2. Merge pull request #1019 from dart-lang/undo-flatten-conditionals

    Revert the change to flatten nested conditionals.
    munificent authored Apr 9, 2021
    Copy the full SHA
    f17c23e View commit details

Commits on Apr 26, 2021

  1. Copy the full SHA
    b13403c View commit details
8 changes: 4 additions & 4 deletions .github/workflows/test-package.yml
Original file line number Diff line number Diff line change
@@ -23,9 +23,9 @@ jobs:
sdk: [dev]
steps:
- uses: actions/checkout@v2
- uses: dart-lang/setup-dart@v0.1
- uses: dart-lang/setup-dart@v1.0
with:
channel: ${{ matrix.sdk }}
sdk: ${{ matrix.sdk }}
- id: install
name: Install dependencies
run: dart pub get
@@ -50,9 +50,9 @@ jobs:
sdk: [dev]
steps:
- uses: actions/checkout@v2
- uses: dart-lang/setup-dart@v0.1
- uses: dart-lang/setup-dart@v1.0
with:
channel: ${{ matrix.sdk }}
sdk: ${{ matrix.sdk }}
- id: install
name: Install dependencies
run: dart pub get
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 2.0.1

* Support triple-shift `>>>` and `>>>=` operators (#992).
* Support non-function type aliases (#993).
* Correct constructor initializer indentation after `required` (#1010).

# 2.0.0

* Migrate to null safety.
5 changes: 3 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -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 @@ met:
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.

2 changes: 1 addition & 1 deletion lib/src/cli/formatter_options.dart
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ import 'show.dart';
import 'summary.dart';

// Note: The following line of code is modified by tool/grind.dart.
const dartStyleVersion = '2.0.0';
const dartStyleVersion = '2.0.1';

/// Global options that affect how the formatter produces and uses its outputs.
class FormatterOptions {
8 changes: 6 additions & 2 deletions lib/src/dart_formatter.dart
Original file line number Diff line number Diff line change
@@ -87,8 +87,12 @@ class DartFormatter {
// 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;
2 changes: 1 addition & 1 deletion lib/src/line_splitting/solve_state.dart
Original file line number Diff line number Diff line change
@@ -569,7 +569,7 @@ class SolveState {

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();
22 changes: 19 additions & 3 deletions lib/src/source_visitor.dart
Original file line number Diff line number Diff line change
@@ -821,6 +821,13 @@ class SourceVisitor extends ThrowingAstVisitor {

@override
void visitConditionalExpression(ConditionalExpression node) {
// TODO(rnystrom): Consider revisiting whether users prefer this after 2.13.
/*
// Flatten else-if style chained conditionals.
var shouldNest = node.parent is! ConditionalExpression ||
(node.parent as ConditionalExpression).elseExpression != node;
if (shouldNest) builder.nestExpression();
*/
builder.nestExpression();

// Start lazily so we don't force the operator to split if a line comment
@@ -856,6 +863,11 @@ class SourceVisitor extends ThrowingAstVisitor {
builder.endRule();
builder.endSpan();
builder.endBlockArgumentNesting();

// TODO(rnystrom): Consider revisiting whether users prefer this after 2.13.
/*
if (shouldNest) builder.unnest();
*/
builder.unnest();
}

@@ -937,8 +949,12 @@ class SourceVisitor extends ThrowingAstVisitor {
// super();
space();
if (node.initializers.length > 1) {
_writeText(node.parameters.parameters.last.isOptional ? ' ' : ' ',
node.separator!.offset);
var padding = ' ';
if (node.parameters.parameters.last.isNamed ||
node.parameters.parameters.last.isOptionalPositional) {
padding = ' ';
}
_writeText(padding, node.separator!.offset);
}

// ":".
@@ -1819,7 +1835,7 @@ class SourceVisitor extends ThrowingAstVisitor {

space();

visit(node.functionType);
visit(node.type);
});
}

38 changes: 19 additions & 19 deletions pubspec.lock
Original file line number Diff line number Diff line change
@@ -7,14 +7,14 @@ packages:
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 @@ packages:
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 @@ packages:
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 @@ packages:
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 @@ packages:
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 @@ packages:
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 @@ packages:
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 @@ packages:
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 @@ packages:
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 @@ packages:
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 @@ packages:
source: hosted
version: "3.1.0"
sdks:
dart: ">=2.12.0-0.0 <3.0.0"
dart: ">=2.12.0 <3.0.0"
6 changes: 3 additions & 3 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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
description: >-
Opinionated, automatic Dart source code formatter.
Provides an API and a CLI tool.
@@ -10,7 +10,7 @@ environment:
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 @@ dev_dependencies:
# 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'
25 changes: 22 additions & 3 deletions test/regression/0400/0407.unit
Original file line number Diff line number Diff line change
@@ -18,8 +18,8 @@ receiver
..formattedTotal = _total == 0
? ""
: _chartType == "PieChart"
? _formatter.formatAsPercent(item.value / _total, fractionDigits: 1)
: _formatter.formatValue(item.value, item.valueType);
? _formatter.formatAsPercent(item.value / _total, fractionDigits: 1)
: _formatter.formatValue(item.value, item.valueType);
}
<<<
main() {
@@ -30,4 +30,23 @@ receiver
? _formatter.formatAsPercent(item.value / _total,
fractionDigits: 1)
: _formatter.formatValue(item.value, item.valueType);
}
}
>>> (indent 6)
main() {
receiver
..formattedTotal = _total == 0
? ""
: _chartType == "PieChart"
? _formatter.formatAsPercent(item.value / _total, fractionDigits: 1)
: _formatter.formatValue(item.value, item.valueType);
}
<<<
main() {
receiver
..formattedTotal = _total == 0
? ""
: _chartType == "PieChart"
? _formatter.formatAsPercent(item.value / _total,
fractionDigits: 1)
: _formatter.formatValue(item.value, item.valueType);
}
12 changes: 12 additions & 0 deletions test/regression/0700/0713.stmt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
>>>
String type = status == 'OK'
? 'notices'
: status == 'NO' ? 'warnings' : status == 'BAD' ? 'errors' : '';
<<<
String type = status == 'OK'
? 'notices'
: status == 'NO'
? 'warnings'
: status == 'BAD'
? 'errors'
: '';
Loading