This is non-breaking since `shouldBeMigrated` is unreferenced outside
the nnbd_migration package). Once this lands, we can switch clients
from overriding/calling `shouldBeMigrated2` back to `shouldBeMigrated`
and then eliminate `shouldBeMigrated2`.
Change-Id: I1235113bda6f7609de17ec05e7120b312f201536
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/178762
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
The `url` argument is changing from `Object`, accepting either `String`
or `Uri` at runtime, to `Uri` for better static help.
https://github.com/dart-lang/http/pull/507
- Switch to using `Uri` for requests. Where sensible push this type into
the signature of the surrounding method.
- Make some updated method private where they were unnecessarily public
which makes it harder to have confidence when looking for usages.
Rename a method with an unnecessary `get` name.
Change-Id: Ibf075741d6b9d292349b15f1dc84004981729aca
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/179368
Auto-Submit: Nate Bosch <nbosch@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
This change changes `MigrationCliRunner.shouldBeMigrated` to forward
to a transitional method `MigrationCliRunner.shouldBeMigrated2`, which
lacks the now-unused `context` argument. After this lands, internal
clients will be switched to overriding/calling `shouldBeMigrated2`
instead of `shouldBeMigrated`.
Once no clients remain that refer to `shouldBeMigrated`, the `context`
argument will be removed from it (this will be non-breaking since
`shouldBeMigrated` will at that point be unreferenced outside the
nnbd_migration package). After that, we will switch clients back to
overriding/calling `shouldBeMigrated` and eliminate
`shouldBeMigrated2`.
Change-Id: If9b476878260a5777f3346486d44c805dc361691
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/178761
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
* Rename isPreviewServerRunnning to isPreviewServerRunning
* Fix top "Migrating" checkbox upon navigation.
This change does not completely solve google3-compatibility, just the
web preview UI portion.
Work to improve any opt-out `// @dart=2.9` comments will follow.
Change-Id: Iee38650ab732179d82060b14bc7b657e3c560543
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/178160
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
This CL modifies flow analysis API so that when a variable is written
or initialized, if the written expression has non-trivial flow
analysis information, it is captured in the SsaNode associated with
the variable.
The stored information is not yet used; in a follow-up CL, I will add
the ability to retrieve it on a read and use it for promotions.
Bug: https://github.com/dart-lang/language/issues/1274
Change-Id: I1e2590205d4a0c59f4400a119f3d6b380a11414c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/176460
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Also:
* Print out details when applying migration
* Also fix title text position to not scroll out of view.
Change-Id: Idc4b703535400956f78d76ab7959f40cf77a0bc9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/175860
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Also sort test file.
Change-Id: Id8133d699ae1a71d1852ef29ce1f843c7ede98cc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/175561
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Emphasize that the operation is going away,
and mark constructor as deprecated.
TEST= Refactoring+deprecation only, covered by existing tests.
Change-Id: I82aa044cd2cf7bf347b624371399f44bda8f4a07
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/173261
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
This is a reland of 17226bbbff
Remove generated files
Original change's description:
> dart migrate: Move title bar and add 'Migrate' check box next to title
>
> This check box displays whether a file is migrating, opting out, or
> already migrated. The check box can be clicked to toggle between
> migrating and opting out. Clicking the check box updates status in the
> navigation tree. Clicking on check boxes updates the status in the
> title bar.
>
> Screenshot here: https://screenshot.googleplex.com/9z9v9L5DHhBXzEU.png
>
> In terms of the HTML, a new parent above '.content' div was added:
> the '.file' div, which includes a '.title-bar' div above the '.content'
> div.
>
> Bug: https://github.com/dart-lang/sdk/issues/44101 and
> Change-Id: I021f0dd873119ae801e29faa92e97fe48d03ef3c
> https://github.com/dart-lang/sdk/issues/44124
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/174440
> Commit-Queue: Samuel Rawlins <srawlins@google.com>
> Reviewed-by: Paul Berry <paulberry@google.com>
Bug: https://github.com/dart-lang/sdk/issues/44101 and
Change-Id: Iefada3e2fc8cbbc767cfc539204dc51b369888a2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/174720
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Since the EdgeBuilder overrides VisitNode, it wasn't getting the
benefit of the error recovery behavior provided by the
PermissiveModeVisitor mixin. This CL replicates some of the
functionality of PermissiveModeVisitor in the EdgeBuilder._dispatch
method so that it applies throughout the EdgeBuilder's visiting
process.
This uncovered a second bug: when an exception is reported, and the
user hasn't passed in the `--ignore-exceptions` flag, the migration
tool tries to exit immediately by throwing an error of type
MigrationExit, but this was being caught by the error recovery logic,
so the tool wouldn't actually stop reliably. This CL changes the
exception reporting code so that it re-throws MigrationExit when
necessary to ensure quick termination.
Change-Id: Ifd2faf8edb7cd0087c45e20a747ab7f1790ef1c2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/174420
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
This reverts commit 17226bbbff.
Reason for revert: has unrelated tools/abiversions changes
Original change's description:
> dart migrate: Move title bar and add 'Migrate' check box next to title
>
> This check box displays whether a file is migrating, opting out, or
> already migrated. The check box can be clicked to toggle between
> migrating and opting out. Clicking the check box updates status in the
> navigation tree. Clicking on check boxes updates the status in the
> title bar.
>
> Screenshot here: https://screenshot.googleplex.com/9z9v9L5DHhBXzEU.png
>
> In terms of the HTML, a new parent above '.content' div was added:
> the '.file' div, which includes a '.title-bar' div above the '.content'
> div.
>
> Bug: https://github.com/dart-lang/sdk/issues/44101 and
> Change-Id: I021f0dd873119ae801e29faa92e97fe48d03ef3c
> https://github.com/dart-lang/sdk/issues/44124
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/174440
> Commit-Queue: Samuel Rawlins <srawlins@google.com>
> Reviewed-by: Paul Berry <paulberry@google.com>
TBR=paulberry@google.com,srawlins@google.com
Change-Id: I8b8433d47390df91201a365f5aa54c7fb835d997
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: https://github.com/dart-lang/sdk/issues/44101 and
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/174385
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This check box displays whether a file is migrating, opting out, or
already migrated. The check box can be clicked to toggle between
migrating and opting out. Clicking the check box updates status in the
navigation tree. Clicking on check boxes updates the status in the
title bar.
Screenshot here: https://screenshot.googleplex.com/9z9v9L5DHhBXzEU.png
In terms of the HTML, a new parent above '.content' div was added:
the '.file' div, which includes a '.title-bar' div above the '.content'
div.
Bug: https://github.com/dart-lang/sdk/issues/44101 and
Change-Id: I021f0dd873119ae801e29faa92e97fe48d03ef3c
https://github.com/dart-lang/sdk/issues/44124
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/174440
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
This avoids an apparent hang when visiting the SDK file
`html_dart2js.dart` (which happens anytime the user clicks on a link
like `HtmlElement`).
Bug: https://buganizer.corp.google.com/issues/168936042
Change-Id: I52bb535b6a2ca1a74071e272b1276520048a67bd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/174441
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Checking and unchecking a directory toggles the status of all child files which
are 'migrating' or 'opting out.' Files which are already migrated do not
change.
Checking and unchecking a file updates the status of all parent directories.
Directories with both 'migrating' and 'opting out' files are 'indeterminate'.
The difference between 'file' and 'directory' NavigationTreeNodes was
getting too hairy so I split into two subclasses.
Removed the keepingOptedOut status and added the indeterminate status.
Bug: https://github.com/dart-lang/sdk/issues/44101
Change-Id: Iea1a8c07b08c3d7956db51ca372437093457fe7f
https://github.com/dart-lang/sdk/issues/44124
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/173600
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
These check boxes are hidden behind a parameter that must be changed during
development; it is not wired to a public-facing flag.
The check boxes are styled, and are connected to the starting status of each
compilation unit (already migrated, opted out, migrating).
The check boxes can be toggled, but just for mocking purposes; their status is
not connected to the back end. The directory check boxes are not wired to the
status of their children.
Screenshot of checkboxes w/o colors: https://screenshot.googleplex.com/43XBRWsMPgbQXik
Screenshot of check boxes w/ colors: https://screenshot.googleplex.com/3bhJqcnmeV4sGNm
* dark green - already migrated; file is not being changed.
* light green - file is being migrated now.
* orange un-checked - file is being opted out, initial migration,
file will gain opt-out comment.
* grey un-checked - staying opted out, file is not being changed.
* indeterminate - folder has multiple states inside.
Bug: https://github.com/dart-lang/sdk/issues/44124 and
Change-Id: I49daf1f52544024ec1c6d8d5cf3c59515c7db3a7
https://github.com/dart-lang/sdk/issues/44101
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/172821
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Expand the range allowed by the dep from `package:analyzer`.
Switch dependencies to `any` for the packages which are `publish_to:
none`. The actual constraints aren't useful in these packages since they
are always pinned exactly by DEPS and so we can't trust they are kept up
to date.
Change-Id: Ibd937e8646574d49105f4dd0de2529e7ab30862a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/172380
Auto-Submit: Nate Bosch <nbosch@google.com>
Commit-Queue: Nate Bosch <nbosch@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
Change-Id: Ib8056827595470d8c3c8b2cb8371ab08dcc3e651
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/172040
Auto-Submit: Paul Berry <paulberry@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Commit-Queue: Kevin Moore <kevmoo@google.com>
Reviewed-by: Kevin Moore <kevmoo@google.com>
It's no longer just for the tools in the `tool` directory; it also
contains test utilities for use by the analyzer and related packages.
Change-Id: I0f8cf57f24ea7aad8e2177e43ee2bcb2ab3030da
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/171704
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
If all the user's code has already been migrated and there are no
errors, instead of crashing, produce a friendly message indicating
that there's nothing to do, and exit cleanly.
Fixes#44193.
Bug: https://github.com/dart-lang/sdk/issues/44193
Change-Id: I9da9ab0221d4e13a61985eaa3fec0e74b86e9072
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/171960
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Change-Id: I8289aa274a7882a41a5411739999f1db77fc196f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/172000
Auto-Submit: Paul Berry <paulberry@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Commit-Queue: Michael Thomsen <mit@google.com>
Reviewed-by: Michael Thomsen <mit@google.com>
This feature is now working reliably enough that we no longer need the
option of turning it off.
Change-Id: I2bbeb114ca1bd4e0dc8e94ac6775ec5e2fa8718e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/171705
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
I will need to add another callback in a follow-up CL, and it seems
silly to pass a bunch of closures to the DartFixListener constructor.
Change-Id: I969d1d90fca0889b131589248aaa1cec343a9059
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/171700
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Previously, the user experience was an `UnimplementedError` with no
further information. Now the user gets an error message telling them
how they need to update the pubspec, which I believe was the original
implementation intent.
Note that the field `_packageIsNNBD` has been removed. Although the
comment for this field said it was tracking whether the package was
opted in to null safety, it actually had no effect (since the only
code path that would set it to `false` was after the
`UnimplementedError` and thus unreachable).
Change-Id: I3cef2f0a7203941b22e37e3ae1bee14806cfc9c0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/171621
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
The script's Usage text has the best description.
Change-Id: I6baf747a13a7655e40bc0158cb40ad965fa6ee3a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/171422
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
When I first implemented this I thought that checking exports wasn't
needed, since it's not allowed for a migrated library to re-export
symbols defined in an unmigtated library. But it turns out we still
do need to include exports in the check, since there might be migrated
libraries that are only reachable in the transitive dependency graph
via an export, and we need to check that *those* libraries don't
import unmigrated code.
Bug: https://github.com/dart-lang/sdk/issues/44061
Change-Id: I280b4117373a3320fc1efe65abe24e344199754c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170840
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
The old phrasing was confusing because it was unclear which libraries
were being referred to.
Bug: https://github.com/dart-lang/sdk/issues/44061
Change-Id: Id68f28fcd8ba5a80763e7bf86d6774289701d381
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170841
Auto-Submit: Paul Berry <paulberry@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
Reviewed-by: Devon Carew <devoncarew@google.com>
Instead of running `pub outdated` to see if the user's dependencies
have been migrated yet, the migration tool now examines all of the
transitive import dependencies of the user's code to see if they are
opted in to null safety. This produces a more accurate result than
`pub outdated`, because it is able to ignore files in transitive
package dependencies that aren't reachable via imports
(e.g. references to `package:analyzer` brought in by `package:test`).
Fixes#44061.
Bug: https://github.com/dart-lang/sdk/issues/44061
Change-Id: I38465bcbf35e8552f0060b5d51c0f1cfc5d18c7f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170561
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
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>
Early in the development of the migration tool, due to language
versioning support being incomplete, it didn't have a good way to
distinguish opted in from opted out code, so we had the convention
that any code not being migrated was opted in. Now that we have
language versioning support, we need to explicitly opt that code in.
Without this change, we'll get bogus failures when we add logic to
detect unmigrated dependencies.
Bug: https://github.com/dart-lang/sdk/issues/44061
Change-Id: I12920ea75b8af2142a044314b89b76bb602897c6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170560
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
As discussed in
https://github.com/dart-lang/sdk/issues/44031#issuecomment-720967259,
we want to encourage users to publish null safe packages with an SDK
min constraint matching the SDK version that was used for the
migration, e.g. `2.12.0-18.0.beta`. However, we also want to make
sure that users doing migration via internal, dev, or bleeding edge
builds publish their null safe packages don't wind up inadvertently
publishing packages that are un-resolvable with the latest beta SDK,
so if the user is on one of those versions, we'll set their SDK min
constraint to `2.12.0-0`.
And of course, once the feature ships to stable, we'll want users to
publish their null safe packages with an SDK min constraint matching
the version in which null safety shipped to stable.
This CL implements all of that functionality, and tests it by
overriding the `version` file in the analyzer's mock SDK.
Change-Id: Ib9ed97e691271da0ed391a6c1a5fe209aa959dce
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170380
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
This reverts commit c10be63d51.
Reason for revert: this creates a circular dependency between nnbd_migration and dartdev which is hard to support internally
Original change's description:
> [pkg/dartdev] refactor the migrate command to subclass DartdevCommand
>
> Change-Id: I60f91f14e066b3a173f45b3c988830d5b435f2ed
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170206
> Reviewed-by: Ben Konyi <bkonyi@google.com>
> Commit-Queue: Devon Carew <devoncarew@google.com>
TBR=devoncarew@google.com,bkonyi@google.com,sigurdm@google.com
Change-Id: I3ba4648ea7f879ea4a893df2a9d75581a6f48dec
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170348
Reviewed-by: Ivan Inozemtsev <iinozemtsev@google.com>
Reviewed-by: Devon Carew <devoncarew@google.com>
Commit-Queue: Ivan Inozemtsev <iinozemtsev@google.com>
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>
Previously, we hard a hard-coded set that included all packages added
by unit tests, which created confusion when writing new unit tests.
Now, `addPackageFile` records a list of all packages and
`package_config.json` is automatically generated just before analysis
begins.
Change-Id: I3393c0266a54d051ffa7601e74753a75857635e2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170024
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Currently the migrator can add `@required` from the preview, which will crash
the preview upon rerunning, if package:meta is not imported.
This change instead adds a /*required*/ hint when meta is not imported.
Additionally, /*required*/ is understood by the migrator just as if it were
`@required`.
Fixes https://github.com/dart-lang/sdk/issues/43751
Change-Id: I1ea532246b956feacedd179146372b13c65003df
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/169900
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
There are no formatting changes in this release. The only change is the
fix for https://github.com/dart-lang/dart_style/issues/964.
Includes corresponding adaptations of dartdev/dart CLI.
Change-Id: I1c97f0b7009b98ae609b258401522453faa35c64
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170083
Reviewed-by: Jonas Jensen <jonasfj@google.com>
Commit-Queue: Sigurd Meldgaard <sigurdm@google.com>
In the beta release, we plan to recommend that people set their
pubspec SDK constraints to `>=2.12.0-0 <2.12.0`, so this change
updates the migration tool to have that behavior.
In the second beta release we'll change switch the upper bound to
`<3.0.0`.
Change-Id: Ib90e893bebaebea968b19e7de663cbbbca570f84
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/169143
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Instead, produce `null /*no valid migration*/`. This should lead to
less user confusion (`null!` seems crazy, since obviously a null
literal will fail a `!` check). Note that this will be a static
error, which will give the user a better chance of noticing and fixing
the problem.
Fixes#43972.
Bug: https://github.com/dart-lang/sdk/issues/43972
Change-Id: Ibf83b786dc486b14c001c17ca2ba902dafcb8a18
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/169600
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
This was causing visual clutter by making informative regions offset
from regular code. Worse yet, there was a "double vision" effect
because the top of the underlying non-offsetted text could sometimes
be seen behind the informative region overlay.
Change-Id: I206c74b3d91f305a21494b767ec27f396a8513b0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/169700
Reviewed-by: Samuel Rawlins <srawlins@google.com>
* `--apply-changes` and no value passed for `web-preview`: assume
`--no-web-preview`
* `--apply-changes` and `--web-preview` (each explicitly passed): error
* no value for `apply-changes` and no value passed for `web-preview`: assume
`--web-preview`
Bug: https://github.com/dart-lang/sdk/issues/43866
Change-Id: I518f20f8095a6c9a11109fd9ae0f7c0e16050ddd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/169521
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Previously, we were switching test paths to drive `D` at the start of
the test, after the `package_config.json` file had already been
generated to drive `C`; as a result, it didn't apply. We will need
the `package_config.json` to apply when we flip the null safety flag
(so that the inputs to the migration tool are considered opted out
prior to migration). This CL reworks the test so that the paths are
modified as part of test set-up, so `package_config.json` gets put in
the right place.
Fixes#43883.
Bug: https://github.com/dart-lang/sdk/issues/43883
Change-Id: I08f79ddb07d7a5ecf640370a32334a7ceb92ceff
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/169421
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
With this change, the functionality of changing iterable method calls
such as `.firstWhere` into extension method calls such as
`.firstWhereOrNull` is working well enough that I think we can switch
it on.
We don't update the pubspec properly yet; that will be addressed in
follow-up CLs.
Change-Id: I758332e9752b12d399ecb5c70cf37bbc8da77d6c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168988
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
We don't want inserted lines to receive their own line number for two reasons:
- It makes the line numbers displayed by the migration preview fail to
line up with the line numbers in the user's editor (since the lines
haven't been added yet)
- It makes navigation links within the migration tool point to the
wrong place, since these links are computed based on analysis of the
pre-migration code.
So instead, we supply a line number string of `(new)` for inserted lines.
This required refactoring the algorithm for
`UnitRenderer._computeRegionContent` a bit. Now, instead of trying to
accumulate the output HTML string all at once, we produce it one row
at a time, first accumulating the line text in a StringBuffer, and
then once the end of the line is reached, attaching the line number to
form a table row. Then we join together all the rows into a table
when we're done.
Change-Id: Ie18632186ddd0f4f5f33d4da41b4943759699e1f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168987
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Previously UnitInfo.regions contained just information about edits
that we wanted to alert the user about; it didn't contain information
about unimportant edits like adjusting whitespace.
This caused problems when trying to make complex edits (like those
necessary to transform a `.firstWhere` call into a `.firstWhereOrNull`
call) because it interfered with UnitRenderer._computeRegionContent's
ability to properly compute file offsets.
So we now include all edits in UnitInfo.regions, and we distinguish
the unimportant ones by seeing that their `kind` and `explanation`
fields are `null`.
To ensure that important edits never wind up with `null` values for
these fields, we add assertions to the `NullabilityFixDescription`
constructor.
Change-Id: I89928150eb507524222d03acfae0b4770363443c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168985
Reviewed-by: Samuel Rawlins <srawlins@google.com>
The method we use to rename method calls to Iterable
(e.g. `firstWhere` -> `firstWhereOrNull`) causes a pair of consecutive
AtomicEdit objects to be generated: one to remove the old name
followed by one to add the new name. This was causing
InfoBuilder._explainUnit to update its output offsets incorrectly,
because it waited until after processing all of the AtomicEdit objects
pointing to a single source offset before updating the output offset.
What it needs to do instead is update the output offset (in the
variable called `offset`) after processing every single AtomicEdit.
Change-Id: I8ad51e20d4021c62c45542cec7f0f54a9ff3cf26
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/169000
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
This is a weird CL because it strives to keep tests passing before and after
the CL, when they include a lot of error-path tests with weird pubspec files
and package config files.
Bug: https://github.com/dart-lang/sdk/issues/43883
Change-Id: I55dd4b398f3b1b53b8f2df95b2dcf880104ec7b6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168901
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Well not quite all; migration_cli_test tests are a bit of a different
beast so I am going to tackle them separately. But this fixes over
1000 test failures, and should clean up test output for further
debugging of the flip CL.
Each test file needs to be in a package with a package config file
which spells out that it is _opted out_ of null safety.
Bug: https://github.com/dart-lang/sdk/issues/43883
Change-Id: I583f66119df57031fd80824111923e15e0f91782
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168900
Reviewed-by: Leaf Petersen <leafp@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
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>
The output the migration tool generates when the web preview is
disabled shows a complete diff of all changes the tool will make, so
it's really a misnomer to call it a "summary".
Change-Id: I8c7d9f9870bf8beffb62f1d10d36a65b66c32657
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168381
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Without this fix, the tool inserts an enable-experiment
section indented at the wrong spot:
analyzer:
exclude:
foo:
bar: 1
enable-experiment:
- non-nullable
Change-Id: Ib6601733221e77a4028f3c0ac87b36c258db6ec0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168120
Reviewed-by: Devon Carew <devoncarew@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
I'm looking into enabling NullSafetyUnderstandingFlag in the next
analyzer breaking change.
test_function_void_to_function_object() fails, and it seems that
the test class should use legacy TypeProvider, because `Object` is not
assignable to `void`, but `Object*` is.
Change-Id: Ib867e0eec7a387ed3ed1379a7ef34a58b16e54ae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168125
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
The file might be edited in one of a few ways, depending on what it contains.
Previously we read and edited pubspec, which is also YAML, so this
implementation borrows a lot of that, and renames several "pubspec" elements to
be "yaml" elements.
I try to cover in tests various odd existing analysis_options.yaml situations,
so that we try to never crash, or corrupt on weird input here.
Fixes https://github.com/dart-lang/sdk/issues/43806
Change-Id: Ifc57d583e98d798fd7bca748bbe4afef272edab5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/167862
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
The internal code that was using this method has been updated to use
MigrationCli.options instead.
Change-Id: I46941b3a2b8dc65a66a3235052bc5c2110a9ab99
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/167820
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
This adds some technical debt in form of using writeOrReadElement in
clients, which can be paid incrementally by migrating these places to
handling assignment like expressions one by one. Doing it all in one
CL was too much. But now the underlaying AST resolution will be
sound.
In the next breaking change we will remove
setAssignmentBackwardCompatibility(), so stop setting elements/types
for assignment targets.
Change-Id: I11626876cfed25653edb0cc18544aba51cef5965
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/165622
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This CL unblocks the internal SDK roll by restoring the migration
tool's `MigrationCli.addCoreOptions` method (which is currently used
internally). It also adds a replacement, `MigrationCli.options`,
which is more robust because it allows the client to choose which
options to include and which options to exclude.
Once this CL has rolled in, I'll update the internal code base to use
the new `MigrationCli.options` method and then remove the deprecated
`addCoreOptions` method.
Change-Id: I3ddbd935c3858c3302a2ad2b825b97df96249043
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/167443
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
This will be the last published version, and is only being published
so that we can include a README entry indicating why the package is
not to be used. After publishing, I will mark the package as
discontinued.
Change-Id: I95cb6d8d6ec41415edd2c8da300c165a0c4cfb93
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/167444
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
`late final` is not functionally different from `late`, as far
as the migrator is concerned; it is just an indication of late
in the face of missing initialization.
Fixes https://github.com/dart-lang/sdk/issues/41655
Change-Id: I1b0efd3de3b5c7064784ebd1e86c7d12436b1319
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/167203
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
I plan to publish this on pub, and then mark the package as
discontinued. Customers should invoke NNBD migration using the `dart
migrate` command.
Change-Id: Ia871e71258e3951ac7fd866e46ae97043a6fa93c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/167364
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
The fix is just to capture the scroll position when the button was clicked,
then rescroll to that pixel after reloading the file.
I also sorted migration.dart.
I also added comments while investigating migration.dart.
Fixes https://github.com/dart-lang/sdk/issues/43546
Change-Id: Iac0a7bf10a671fd6e6b5f02ee0609b7e36fc985a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/167360
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Rather than produce an error immediately upon encountering an
alredy-migrated library, we simply skip processing it; this causes its
elements to be added to the nullability graph on demand, just like for
already-migrated dependencies.
We still check for the possibility that *every* file in the user's
package has already been migrated, and issue an error if so (rather
than just doing nothing); this should help avoid user confusion if the
user tries to re-migrate an already-migrated package.
Bug: https://github.com/dart-lang/sdk/issues/42308
Change-Id: I8dd81a9c6ff2bb23ede91e89d1152bd7726dec32
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/167202
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
This is a reland of 6a1c54ec30
Original change's description:
> Flow analysis: promote to non-nullable on initialization
>
> When flow analysis encounters a variable declaration of the form `T? x
> = expr;`, if the type of `expr` is `T`, then the variable is
> immediately promoted to type `T`.
>
> Fixes#43099.
>
> Change-Id: Ia206fe0d50e2fdd9bdf637e13c85633d8490dbcc
> Bug: https://github.com/dart-lang/sdk/issues/43099
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/163841
> Commit-Queue: Paul Berry <paulberry@google.com>
> Reviewed-by: Bob Nystrom <rnystrom@google.com>
> Reviewed-by: Johnni Winther <johnniwinther@google.com>
> Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Bug: https://github.com/dart-lang/sdk/issues/43099
Change-Id: I7530bb0f7c24674a7b500558b89d50b35e045aca
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/166305
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
When flow analysis encounters a variable declaration of the form `T? x
= expr;`, if the type of `expr` is `T`, then the variable is
immediately promoted to type `T`.
Fixes#43099.
Change-Id: Ia206fe0d50e2fdd9bdf637e13c85633d8490dbcc
Bug: https://github.com/dart-lang/sdk/issues/43099
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/163841
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
The packages 'analyzer' and 'nnbd_migration' tightly depend on each
other via MigrationResolutionHooks. I will publish analyzer 0.40.4
shortly after this CL lands.
Change-Id: I6f5e51f88e0020a1674ffb251712658e896170e7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/164900
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
This logic was removed from the spec in
b70bb3f906.
Only a few places in the SDK itself were relying on this promotion
logic; I've fixed those places by adding explicit types.
Change-Id: Iaeaebe8dd5ab3e848699bc8ebc64a1ae80c1027a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/163681
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Uses the existing dart_192.png image.
Alternatively this could have been done using a favicon.ico file but
that would have required more boilerplate, so I went with a simpler
approach.
fixes#43438https://github.com/dart-lang/sdk/issues/43438
Change-Id: I91e0c28a2c0a28db58dbf5189aae4d099c19b23c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/163500
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: John Ryan <ryjohn@google.com>
There are certain rare conditions involving generated code in a bazel
workspace that can cause a source file to get processed more than once
by the migration tool (sometimes with a correct URI, sometimes with an
incorrect URI that corresponds to a file path in the `bazel-out`
directory). For the most part the migration tool is tolerant of this
situation, but it can cause InfoBuilder._explainUnit to get called
twice for the same unit. To avoid this creating user-visible
problems, we need to ensure that any regions left over from the
previous invocation of InfoBuilder._explainUnit are cleared out before
we re-populate the region list.
Bug: https://b.corp.google.com/issues/168295421
Change-Id: I18936b03261c30b8c9062b4a568e1a1e094ec867
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/162800
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
* Refactor MigrationCliRunner, mostly simplification.
* Add AnalysisResult class to track analysis errors.
* MigrationState now contains an AnalysisResult, and the previewUrls.
* Add logic in the UI to display analysis results.
* Add logic to the backend to display analysis results.
Fixes https://github.com/dart-lang/sdk/issues/41712
Fixes https://github.com/dart-lang/sdk/issues/43138
Change-Id: I3304467955cfa81820f0010d32e17931b3c68b08
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/162400
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
This is a reland of d833f2f65c
Original change's description:
> Flow analysis changes to fix mixed-mode unsoundness loophole.
>
> This is the flow analysis portion of the fix to
> https://github.com/dart-lang/language/issues/1143. Follow-up changes
> will be needed in the CFE and/or backends to ensure that exceptions
> are thrown under appropriate circumstances.
>
> This CL also makes some improvements to flow analysis's reachability
> analysis so that it accounts for nullability of the target when
> analyzing the reachability of `??=` and `?.`. Hopefully these
> improvements should make the fix to
> https://github.com/dart-lang/language/issues/1143 clearer and more
> consistent.
>
> Change-Id: I5fa5c070f13fd57ac4c2fb87f2d67588861594b0
> Bug: https://github.com/dart-lang/language/issues/1143
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/160440
> Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
> Reviewed-by: Johnni Winther <johnniwinther@google.com>
> Commit-Queue: Paul Berry <paulberry@google.com>
Bug: https://github.com/dart-lang/language/issues/1143
Change-Id: If9c45649c1e9f4b19f7c282e7a1c4c956a7bc17f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/161622
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
This is the flow analysis portion of the fix to
https://github.com/dart-lang/language/issues/1143. Follow-up changes
will be needed in the CFE and/or backends to ensure that exceptions
are thrown under appropriate circumstances.
This CL also makes some improvements to flow analysis's reachability
analysis so that it accounts for nullability of the target when
analyzing the reachability of `??=` and `?.`. Hopefully these
improvements should make the fix to
https://github.com/dart-lang/language/issues/1143 clearer and more
consistent.
Change-Id: I5fa5c070f13fd57ac4c2fb87f2d67588861594b0
Bug: https://github.com/dart-lang/language/issues/1143
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/160440
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>