Commit Graph

11 Commits

Author SHA1 Message Date
Devon Carew 81986f4a36 [dartdev] add a --format option to dart analyze
Change-Id: Iad7d14b12892ce2121430f0cd94a2b0cd0d8e978
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/174384
Commit-Queue: Devon Carew <devoncarew@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-12-01 01:32:34 +00:00
Sam Rawlins 40cfccda6f Migrator: Add a progress bar for explainMigration, which can take a long time.
This shows progress for work which happens after the migration suggestions have
been generated. This work is generating instrumentation details for the front
end.

When migrating the analyzer package, the progress indicated by this third
progress bar takes approximately the same time as generating suggestions (on
the same order of magnitude).

Fixes https://github.com/dart-lang/sdk/issues/44074

Change-Id: I0b40dd5e587b718bd1ef56d64f03929924cc430a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170563
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-11-05 22:10:51 +00:00
Paul Berry 92587baee5 Migration: fix "whereOrNull" transformation to handle complex targets.
Previously, when analyzing a call to an iterable method that could
potentially be transformed into an `OrNull` extension, such as:

  allMatches(str).firstWhere(..., orElse: () => null);

the migration tool would erroneously identify some subexpressions of
the call target (`str` in this example) as the argument supplied to
`orElse`, resulting in a crash.

This CL fixes the logic so that we use an `identical` check to verify
when we are looking at the argument to `orElse`.

Fixes #43956.

Bug: https://github.com/dart-lang/sdk/issues/43956
Change-Id: I2f4a0e81becf789cab5334d4926e014bda2772f4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170162
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-11-03 22:48:17 +00:00
Paul Berry f1843b0abe Add special case migration logic for iterator methods.
This logic allows us to migrate code like this:

    int firstEven(Iterable<int> values)
        => values.firstWhere((i) => i.isEven, orElse: () => null);

Into:

    import 'package:collection/collection.dart' show IterableExtension;

    int? firstEven(Iterable<int> values)
        => values.firstWhereOrNull((i) => i.isEven);

Rather than the default behavior, which would migrate it to:

    int? firsteven(Iterable<int?> values)
        => values.firstWhere((i) => i!.isEven, orElse: () => null);

(The new migration is far superior because it doesn't require the
input iterable to accept null).

This functionality is disabled at the moment, because:
- The changes it makes don't show up properly in the web preview.
- The pubspec is not yet properly updated.

I will address these issues in follow-up CLs and then enable the
feature.

Change-Id: I96f3b12d682c586631920b38406bad6aa3f4789e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168500
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-10-20 17:45:04 +00:00
Paul Berry 5898fefb92 Add missing invocation to test_all.dart
Change-Id: Ibcbe7f50555a66360b563ae3915d2567567dd025
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168462
Reviewed-by: Janice Collins <jcollins@google.com>
2020-10-20 17:45:04 +00:00
Paul Berry 1ac898a2c5 Migration: add the ability to output a text diff to the CLI.
The previous implementation of the tool (based on dartfix) used
diffing code that was pretty deeply tied into dartfix, and didn't
produce good quality output for migration, so I've replaced it with a
new implementation.

Change-Id: Id3679435bf59c73145eacb6eaee1b6ce16dd61f1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/146442
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2020-05-05 20:19:23 +00:00
Janice Collins 1d932f7450 Add a 'run' feature to MultiFutureTracker.
This makes a certain idiom using MultiFutureTracker more compact,
namely blocking on the completion of the closure.

Change-Id: I8872ce882da0b20775c416895047cc18abd2801a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134248
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Commit-Queue: Janice Collins <jcollins@google.com>
2020-02-04 18:57:18 +00:00
Janice Collins 4ee5fd243f Move the parallelization restriction into SubprocessLauncher.
This eliminates a lot of really noisy boilerplate in the upcoming
FantasyRepo implementation.  The test only verifies that the pathway
works, we rely on MultiFutureTracker working to actually restrict
properly.

Change-Id: Ia88d0b24dd739ab1cd4a661325214395bf37eef3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133742
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Janice Collins <jcollins@google.com>
2020-01-29 18:32:36 +00:00
Janice Collins f0038ad8aa Move MultiFutureTracker and SubprocessLauncher into utilities.
Also adds some basic tests for both, centering on the functionality
that is most important to use in SubprocessLauncher's case.

Change-Id: I90a79cd12f7b2222bae366907a6dc200591bb59c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133433
Commit-Queue: Janice Collins <jcollins@google.com>
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-01-27 21:34:19 +00:00
Mike Fairhurst 39c74d30a1 [nnbd_migration] more postdominator feedback: postdominating locals lists
Change-Id: Ib00a238f09fdc247e05b3754403d60db86e1ffbc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/112682
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
2019-08-13 17:00:55 +00:00
Mike Fairhurst e627d8b852 [nnbd_migration] use postdominators to do hard edge detection in most cases
Change-Id: I6af934b4a4795a0cfd74519985b24ae171485880
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/111941
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
2019-08-09 07:12:00 +00:00