Commit graph

1164 commits

Author SHA1 Message Date
Paul Berry
98ccfc33df Sort declarations in pkg/nnbd_migration/test/api_test.dart
Change-Id: Ic4990bbb40fe571a5fcba3a9b03366266cd565db
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/167725
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-10-17 01:11:43 +00:00
Sam Rawlins
7c01226470 Fix navigation scrolling with big projects
Change-Id: Ie5fb3f79225354aef956e71467c0fe34b5e4cbc2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168122
Reviewed-by: Devon Carew <devoncarew@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-10-16 21:56:52 +00:00
Sam Rawlins
33e7bae759 Migrator: Fix issue with map node under 'analyzer:'
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>
2020-10-16 21:37:02 +00:00
Konstantin Shcheglov
3a97c9f602 Use legacy TypeProvider in AssignmentCheckerTest.
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>
2020-10-16 21:10:03 +00:00
Sam Rawlins
a23dbf7417 Migration: do not wrap navigation items
Change-Id: I6b3a2c41d4df9cc0f789d04f74cdddf79f7759d7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168060
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-10-16 15:29:22 +00:00
Sam Rawlins
3191b45998 Edit analysis_options.yaml to enable the non-nullable experiment.
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>
2020-10-16 12:58:32 +00:00
Paul Berry
6282572479 Remove deprecated method MigrationCli.addCoreOptions.
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>
2020-10-15 16:09:56 +00:00
Konstantin Shcheglov
aad1a677c0 Deprecate GenericTypeAliasElement
See also https://dart-review.googlesource.com/c/sdk/+/166680

Change-Id: I6018f3bf5796dcc8ab059aab5b29d01e7336581b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/167727
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-10-15 16:03:26 +00:00
Paul Berry
acef33fd08 Avoid using http: URIs with relative paths in the migration tool.
Such URIs fail when the connection between the migration tool and the
user's web browser is proxied over https.

Fixes #43545.

Bug: https://github.com/dart-lang/sdk/issues/43545
Change-Id: Id457851d5c074ff707a2829c928401a766e15ece
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/167660
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-10-14 18:52:48 +00:00
Konstantin Shcheglov
fbfc723de7 Use CompoundAssignmentExpression instead of LHS element/type.
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>
2020-10-14 18:45:08 +00:00
Devon Carew
7d994c106a Add a migration tool notice for TP2.
Change-Id: I3f882bc47c372e196186d6c9c539cc572d406f43
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/167620
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
2020-10-14 17:30:17 +00:00
Paul Berry
63a406d78b Restore addCoreOptions functionality and create more robust replacement.
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>
2020-10-14 00:27:47 +00:00
Paul Berry
acf440fe42 Sort declarations in migration_cli.dart
Change-Id: I14c4b9b77eec3fef5a23f76877a8d291ca217198
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/167423
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2020-10-14 00:27:47 +00:00
Paul Berry
ad82b437f4 Prepare to publish package nnbd_migration version 0.1.1.
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>
2020-10-13 22:53:04 +00:00
Sam Rawlins
cddea627a7 Migrator: Accept 'late final' hint; same as 'late' hint
`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>
2020-10-13 19:41:58 +00:00
Sam Rawlins
b9e8f6f09c Migrator: Use 2.10 as a lower bound for null safety to allow 2.11 dev versions
Fixes https://github.com/dart-lang/sdk/issues/43757

Change-Id: I989b1542d2c6746513cc88dcfeff995873536ac5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/167400
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-10-13 19:41:18 +00:00
Sam Rawlins
f2b94295d3 Migrator: Disable 'pub outdated' check temporarily
Bug: https://github.com/dart-lang/sdk/issues/43774
Change-Id: I128d0e24aa6b8c972f393d3e91aae418a44ed8ef
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/167380
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-10-13 18:29:58 +00:00
Sam Rawlins
5c17af0843 Migrator: Refactor currentScrollPosition to be a function
Bug: https://github.com/dart-lang/sdk/issues/43546
Change-Id: Ie79b00b6471f4d5416e78fb6ca04e4c7f46d7231
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/167381
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-10-13 17:54:08 +00:00
Paul Berry
d6292f99c2 Add a notice to the nnbd_migration package README.
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>
2020-10-13 16:29:08 +00:00
Sam Rawlins
284c78d338 Fix scrolling when clicking the "Add hint" buttons.
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>
2020-10-13 15:24:18 +00:00
Paul Berry
626c865a3e Support migration of partially migrated packages.
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>
2020-10-12 23:58:32 +00:00
Sam Rawlins
ef30beda17 Migrator: Print less output in tests
Change-Id: I8add1a75de71a4b979399be821a4baa803bc0165
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/167180
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-10-12 17:48:32 +00:00
Sam Rawlins
a5455694d5 migrator: Bump opt-in null safety version
Fixes: https://github.com/dart-lang/sdk/issues/43757

Change-Id: Iabcb0ef088d94b29cad4663763a1a842a8c49dcd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/167160
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-10-12 17:23:22 +00:00
Devon Carew
07e2973f60 [pkg/nnbd_migration] some updates to the command line messaging for dart migrate
Change-Id: I780f7d6ec1e6985179f69ceb105519d5be838e80
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/167120
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
2020-10-12 15:53:32 +00:00
Paul Berry
2601fa6d78 Ensure that && and || expressions promote properly in unreachable code.
Bug: https://github.com/dart-lang/sdk/issues/40009
Change-Id: Ib06449624de9320f5229957511ebaaee92c75ec8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/166606
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2020-10-08 21:42:14 +00:00
Paul Berry
57932cfb4f Ensure that conditional expressions promote properly in unreachable code
Change-Id: I8680b81b44be789a047238b1e2d008ff240e59c2
Bug: https://github.com/dart-lang/sdk/issues/40009
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/165405
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-10-07 18:16:52 +00:00
Paul Berry
ed2f45d56d Ensure that if statements promote properly in unreachable code
Bug: https://github.com/dart-lang/sdk/issues/40009
Change-Id: I04a5af558bb70b861d92b5379a8fb84489d5c9f4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/165402
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-10-07 15:32:25 +00:00
Paul Berry
e933e91aaa Reland "Flow analysis: promote to non-nullable on initialization"
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>
2020-10-07 13:14:55 +00:00
Clement Skau
b4f49dc255 Revert "Flow analysis: promote to non-nullable on initialization"
This reverts commit 6a1c54ec30.

Reason for revert: Triggers test failure:
https://ci.chromium.org/p/dart/builders/ci.sandbox/vm-kernel-precomp-linux-debug-x64/8247

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>

TBR=paulberry@google.com,scheglov@google.com,rnystrom@google.com,johnniwinther@google.com

Change-Id: I8549b48a734f527194ce11d82235b9d5c6e58185
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: https://github.com/dart-lang/sdk/issues/43099
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/165564
Reviewed-by: Clement Skau <cskau@google.com>
Commit-Queue: Clement Skau <cskau@google.com>
2020-10-01 08:41:15 +00:00
Paul Berry
6a1c54ec30 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>
2020-10-01 01:15:31 +00:00
Konstantin Shcheglov
8de1bc0a07 Stop using getReadType() in nnbd_migration.
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>
2020-09-29 17:18:25 +00:00
Konstantin Shcheglov
e3fcb1a646 Remove unnecessary convertPath() invocations.
Change-Id: I57d0d2204df02bd9a5fc97986347ac0218442d39
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/164722
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-09-26 18:25:00 +00:00
Konstantin Shcheglov
f9e6e38b21 Straighten up invocation of an Object method on dynamic.
Fixes https://github.com/dart-lang/sdk/issues/39609

Change-Id: I9b98d9bff8d4e9b75ab7625323f62eb6b6701a94
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/164256
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-09-25 16:46:04 +00:00
Konstantin Shcheglov
d219bde703 Enforce await_only_futures and fix violations (in more packages).
Change-Id: I1812f7721915178e42956f988b9276bf8db0bfaa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/164281
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-09-24 16:58:50 +00:00
Paul Berry
f860868740 Flow analysis: remove old "promotable via initialization" logic.
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>
2020-09-22 12:22:13 +00:00
John Ryan
90ff5d0af6 Add favicon to nnbd_migration tool
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 #43438
https://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>
2020-09-21 17:51:47 +00:00
Konstantin Shcheglov
9ef060886e Fix lints in nnbd_migration.
Change-Id: I57a8de216709beb1c65877bb228e1a0365ac6976
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/163461
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-09-18 18:32:06 +00:00
Sam Rawlins
475ffb96c0 Migrator: Use pedantic 1.9.0
Change-Id: Ia53e84ac6b2f3ab0679710c14453fd65c8f9c00d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/163161
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-09-17 20:52:43 +00:00
Paul Berry
a3c10e3653 Migration: clear regions at the top of InfoBuilder._explainUnit.
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>
2020-09-14 23:58:58 +00:00
Sam Rawlins
151292572c Migrator: Check analysis results before re-running.
* 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>
2020-09-10 20:55:14 +00:00
Sam Rawlins
8035d5a0a7 Migrator: Switch styles for un-changed NN type and inserted "?", "!", etc.
Fixes https://github.com/dart-lang/sdk/issues/43125

Some screens:

Old: https://screenshot.googleplex.com/6dqJeWEvX2pYSi4
New w/o position change: https://screenshot.googleplex.com/8HorAjqMw2tMshk
New + bold font (not included in CL; just for reference): https://screenshot.googleplex.com/3N9cMr4RijXv5sM
New w/ position change (included in CL): https://screenshot.googleplex.com/9TfLKpHCCZkzLXX

Change-Id: Ib8aaf3ae56e645beaa01b2cf9e78db68544441b0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/162242
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-09-10 18:57:58 +00:00
Paul Berry
a4b2047d9d Reland "Flow analysis changes to fix mixed-mode unsoundness loophole."
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>
2020-09-03 01:01:43 +00:00
Konstantin Shcheglov
1b26394a63 Upgrade nnbd_migration to analyzer 0.40.1, switch to VariableElement.hasInitializer
Change-Id: Iddcc04a8b86dc9e24df003fd8bbd090f025aeef6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/161443
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-09-02 19:46:22 +00:00
Mike Fairhurst
30cfb228c0 [nnbd_migration] Remove unused dart:async imports
Change-Id: Ie370dc43312bc872712e1cf811eb7194a30c9945
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/161468
Auto-Submit: Mike Fairhurst <mfairhurst@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-09-02 17:30:32 +00:00
Paul Berry
ab16d79af9 Revert "Flow analysis changes to fix mixed-mode unsoundness loophole."
This reverts commit d833f2f65c.

Reason for revert: Broke build, e.g. https://ci.chromium.org/p/dart/builders/ci/dart-sdk-mac/12688

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>

TBR=paulberry@google.com,scheglov@google.com,johnniwinther@google.com

Change-Id: If1215b19975e0958d612dd69767088095d853879
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: https://github.com/dart-lang/language/issues/1143
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/161580
Reviewed-by: Paul Berry <paulberry@google.com>
2020-09-02 15:02:46 +00:00
Paul Berry
d833f2f65c 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>
2020-09-02 14:27:52 +00:00
Paul Berry
e8201aa761 Migration: fix a crash when downcasting to the Null type.
Change-Id: I905e5fe658989969fe72953485f86de1689c5b51
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/161140
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-08-31 20:38:48 +00:00
Paul Berry
a832289de6 Migration: fix handling of late hints followed by an underscore.
Change-Id: If22d3b398c53912d0de8f5a9977c13411884840c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/161142
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-08-31 20:38:29 +00:00
Devon Carew
f81dadfa32 [dartdev] update the help text for dartdev and related commands
Change-Id: Ia7139b109872575e58fa8f1cbc4aa72bef44bee5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/161020
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
2020-08-31 20:17:48 +00:00
Sam Rawlins
4e7848d17a Migrator: Fix windows path failure.
Fixes https://github.com/dart-lang/sdk/issues/43178

Change-Id: I9b41c7bf3f317abfe8f06b37a40ebd9a3d63a813
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/160960
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-08-31 18:16:28 +00:00
Sam Rawlins
6f0e28b0c8 Fix #43178 by calculating relative path before doing the URI mapping.
Change-Id: I76c3a62d393537da1dbc73cacb9fedfc66f3d2d2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/160443
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-08-27 20:00:27 +00:00
Paul Berry
9046c6e1db Migration: separate core command line options from others.
This allows the core options to be re-used by other tools.

Change-Id: Iea9c18bf4568280dbf2a93ba43656b266226bcf5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/160341
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-08-27 03:13:16 +00:00
Paul Berry
2cb426f9fc Fix context type for compound operators.
This is partially in support of the new numeric typing rules for null
safety, however it turned out that the anaylzer wasn't setting the
context type properly even in legacy code.  I've fixed both legacy and
null safe behaviors and included tests to cover both.

Fixes #39642.

Bug: https://github.com/dart-lang/sdk/issues/39642
Change-Id: Ie4d0936d335b1f750eae4febe76f2b8879c228b1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/159965
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2020-08-26 18:21:05 +00:00
Devon Carew
504195907b [dartdev] don't expose the 'dart migrate' command on the stable channel
Change-Id: I95d5d9dd74e488c749f17fd358d20188de32866c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/160184
Commit-Queue: Devon Carew <devoncarew@google.com>
Reviewed-by: Jaime Wren <jwren@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-08-26 17:42:55 +00:00
Konstantin Shcheglov
0cc487a00e Stop using package:analyzer/analyzer.dart in migration test.
R=paulberry@google.com

Change-Id: I47ac999b0912d14f17a16da88a48816f65b4c5f9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/159973
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-08-25 02:20:17 +00:00
Sam Rawlins
20261e77af Migrator: Include the auth token in various links:
* Navigation links on the left
* target links in source
* "Proposed edit" links

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

Change-Id: I8ee8899286faadfda20dcf02aa409e118e227bcb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/159970
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-08-24 23:47:27 +00:00
Paul Berry
08dd4b1faa Null-safe numbers: implement static typing rules, hook up for binary operators.
Future CLs will hook up the static typing rules for method calls
(`clamp` and `remainder`) and will implement the rules for contexts.

Bug: https://github.com/dart-lang/sdk/issues/42629
Change-Id: Iccfb1fa1ac9aff6c0832d65e4835b5b9bd51a804
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/158501
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-08-24 15:34:33 +00:00
Sam Rawlins
e7c79ae9ae Migrator: fix issue with applying hint, then navigating.
Bug: https://github.com/dart-lang/sdk/issues/42636
Change-Id: I2bda4f91eb6da738b2b2a9c0f0a17d1a71b027cd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/159780
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-08-24 13:32:04 +00:00
Sam Rawlins
b1094db98b Fix Migrator tool generation on Windows
Bug: https://github.com/dart-lang/sdk/issues/42636#issuecomment-678289547
Change-Id: I426bf87cfc29f19fdabbc5ce7692dd98e25ba33c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/159760
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-08-24 13:31:44 +00:00
Paul Berry
194be0b23f During migration, if a getter is nullable, make the setter nullable too.
This is necessary because whatever type is returned by the getter must
be accepted by the setter.

Bug: https://github.com/dart-lang/sdk/issues/43119
Change-Id: I5a43ec3750328081c39c26ba6fb937a9be068eb6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/159644
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-08-21 20:03:00 +00:00
Paul Berry
e8577913eb Sort declarations in edge_origin.dart
Change-Id: I8a410be295191abbaa332b0d626abd5320d32fb7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/159585
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-08-21 16:58:20 +00:00
Devon Carew
c04ef0ba96 [dartdev] update the link to the 'dart migrate' migration docs
Change-Id: Ide264b97d4dd192a015b6b53b63521452dd64322
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/159303
Reviewed-by: Jaime Wren <jwren@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
2020-08-19 20:18:07 +00:00
Konstantin Shcheglov
2b7fc8f134 Update FeatureSet to the new rules.
Bug: https://github.com/dart-lang/sdk/issues/43032
Change-Id: I6c7d7dc56fd0d4edcc3c6f6cc6fb0422316b8f4c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/159187
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-08-19 18:27:37 +00:00
Devon Carew
1eed2dcc2a update the pubspec file for pkg/nnbd_migration
Change-Id: I8ad96626dff34875394d4c5111549ae430de4ce5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/159145
Commit-Queue: Devon Carew <devoncarew@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2020-08-19 15:14:22 +00:00
Konstantin Shcheglov
a51f1747e0 Prepare to publish analyzer 0.40.0 and _fe_analyzer_shared 8.0.0.
Change-Id: I126207dcc47885565a3a6d7002ff15ad3cc493c5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122483
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-08-18 15:12:10 +00:00
Konstantin Shcheglov
2bf61f4936 Don't call getFileSync() in tests.
I see no reason why this would be useful.

But it might be harmful.
When we create file1 that imports file2, and call getFileSync(file1),
the analyzer will read both file1 and file2 while building the
file graph. So, when we then create file2, it will not be read unless
we call changeFile(file2). And we don't.

Actually, if we want to simulate how migration works, we should first
create all files, and then migrate them.

R=paulberry@google.com

Change-Id: I22ff994d346c4ad985e5d06a34e9fd854d451757
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/158960
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-08-18 14:58:30 +00:00
Paul Berry
5642366611 Null safe numbers: plumb element through to refineBinaryExpressionType.
The new rules for null-safe number promotion apply to both operators
and ordinary method calls, so I'll be implementing them in terms of
MethodElement.name rather than an operator TokenType.  To make this
possible, we need to pass the method element to
TypeSystem.refineBinaryExpressionType.

I'm doing this as a separate CL from the main implementation so that I
can verify that it doesn't introduce backward compatibility issues.

Bug: https://github.com/dart-lang/sdk/issues/42629
Change-Id: I6be9086553ee0ea9994994c903880fe9bb4477fa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/158480
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-08-17 23:17:55 +00:00
Paul Berry
e403e6ae77 Flow analysis: rework handling of equality tests.
The new logic classifies the LHS and RHS of the equality check as
either null, non-nullable, or potentially nullable, and then either
promotes, treats the expression as equivalent to a boolean, or does
nothing, as appropriate.

This means, for example, that a comparison between a non-nullable
value and `null` is now known to evaluate to `true` for reachability
analysis.

Note: as part of this change, it was tempting to trigger promotion
whenever a varialbe is equality compared to an expression of type
`Null`, but this would be unsound (consider `(int? x) => x == (x =
null) ? true : x.isEven`).  So we still only promote when the variable
is compared to a literal `null`.

Fixes #41985.

There's a corresponding spec change out for review:
https://github.com/dart-lang/language/pull/1134

Change-Id: Id7f1d4eaa3b0fa57124445bb8352eef32c304feb
Bug: https://github.com/dart-lang/sdk/issues/41985
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/155926
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-08-14 12:16:36 +00:00
Konstantin Shcheglov
302ad7ab2c Replace isNonNullableByDefaultInternal flag in LibraryElementImpl with FeatureSet.
R=brianwilkerson@google.com, paulberry@google.com

Change-Id: I4fdb464df5f70ae93ccff5f06d8c99d34d3f8e31
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/158500
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-08-13 17:27:04 +00:00
Devon Carew
31361ff444 [deps] bring cli_util 0.2.0 into the repo; update the analyzer dep
Change-Id: I705d500a745b5ca972bdc49314b39ee9357989f8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157541
Commit-Queue: Devon Carew <devoncarew@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2020-08-06 17:27:29 +00:00
Paul Berry
2225b6f472 Migration: fix handling of async functions that return FutureOr.
Change-Id: I613d0bfd8340062bb78b20a8fd035d24a4ccdf8d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/155543
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2020-07-23 13:27:28 +00:00
Paul Berry
f907e561c9 Migration: never produce a type of the form FutureOr<T?>?.
`FutureOr<T?>` is already nullable, because `FutureOr<T?>` ==
`FutureOr<T | Null>` == `Future<T | Null> | T | Null`.  So the second
`?` is redundant.

Also fix a bug where we were treating a `Null` type as `Never` if we
couldn't find a reason to require it to be nullable; this was
inconsistent with how the FixBuilder was handling `Null` (which is to
leave it unchanged).

Change-Id: I5e0e4b7fb449988d8ff0dd87a2b4c3da4a6ecebb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/155506
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-07-23 13:24:48 +00:00
Paul Berry
ded9b3ce3f Flow analysis: consider promotion to Never to be unreachable.
Fixes #41981.

Bug: https://github.com/dart-lang/sdk/issues/41981
Change-Id: Id2ce176c703cb3346d4bd7471b10ecac9e3b9907
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/154624
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-07-20 16:17:57 +00:00
Paul Berry
0fee7d6a14 Migration: fix handling of class C<T extends C<T>>
Fixes #42732.

Bug: https://github.com/dart-lang/sdk/issues/42732
Change-Id: Ifd3e294abceb0478a1f945ff8bd305cebbd043ac
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/154847
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-07-20 16:01:47 +00:00
Sam Rawlins
d90daf9154 Analyzer: Report unused optional parameters of private functions
Fixes https://github.com/dart-lang/sdk/issues/29731

This change produces UNUSED_ELEMENT hints for optional parameters
for which no arguments are ever explicitly given, under the following
circumstances:

* parameter is for a constructor, method, or top-level function which
  is not accessible outside the library,
* function is never torn-off (all bets are off once its been torn off),
* method does not override a method in which the matching parameter is
  required,
* method does not override a method with a matching paramter, in which
  an argument is given for the matching parameter.

Change-Id: Idabf051f55140b62a440dc63ca0234f22598a5e8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152730
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-07-17 19:30:27 +00:00
Paul Berry
a3d3777094 Migration: add a hook invoked after changes are applied.
Change-Id: I97b5f132ab24887d6274fcaef96fadeac85de6da
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/154621
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-07-16 00:14:02 +00:00
Paul Berry
c71d40f70b Migration: allow clients to use CommandLineOptions.
Previously this class was marked `@visibleForTesting`, but we need
clients to be able to create instances of this class in order to drive
the migration process.

Change-Id: Ibb8a4cda342942dcb15e6fd7625387d246b41f84
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153800
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-07-09 15:21:52 +00:00
Michael Thomsen
897706edbd Remove unrecommended flag from output:
The current output indirectly advertizes premature out-of-order migration,
which would be bad if it happened widely.

We can keep the flag, but should not advertize it.

Change-Id: I8bde10489cef8e1104e2e5216e03aed61bc95ba0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153612
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Kevin Moore <kevmoo@google.com>
Commit-Queue: Michael Thomsen <mit@google.com>
2020-07-09 01:19:53 +00:00
Konstantin Shcheglov
a1f510080d Use analyzer 0.39.12 in nnbd_migration.
So, we can use package:analyzer/src/dart/element/type_system.dart
instead of src/generated/... library.

R=brianwilkerson@google.com, paulberry@google.com

Change-Id: Ic804cd29429bf8a85d25e21f77292a6816a3ede7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153363
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-07-07 20:59:50 +00:00
Konstantin Shcheglov
9cfdc02e58 Stop depending on exports from generated/resolver.dart
We cannot remove them completely just yet, there are users in google3.
But this CL will allow experimenting internally to track these users
and update them similarly.

R=brianwilkerson@google.com, devoncarew@google.com

Change-Id: Ic588b2873f9d5202783c8991f58e86bab28bd47e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153240
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-07-03 15:55:41 +00:00
Paul Berry
b514f45ac7 Migration: allow tests to override preview server's use of ipv4.
This is necessary for some Google internal testing environments that
are ipv6-only.

Change-Id: I1385786bd0f9614fabcf5730d96a0d6018c6401e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153063
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-07-01 21:26:04 +00:00
Paul Berry
22da8934ac Migration: properly handle extension override syntax.
There were two problems:

- EdgeBuilder wasn't handling the extension override syntax at all,
  causing a crash.

- FixBuilder wasn't overriding the behavior of
  ExtensionElement.extendedType, causing a star type to be used as a
  context for the target expression; this prevented the fix builder
  from realizing when it needed to insert `!` after the target
  expression.

Fixes #42455.

Bug: https://github.com/dart-lang/sdk/issues/42455
Change-Id: I5a9f66f83db73a796e72708022faefd527667e32
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152941
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-06-30 16:00:47 +00:00
Paul Berry
11aaa12d0a Migration: revert informative region height changes.
These height changes caused the overlay containing highlighted regions
to lose alignment with the underlying text, making the preview output
nearly unreadable for files with a lot of informative regions.

Change-Id: Ie6d0e9e58d28bc63dea5ae1e0a6a630f00c814ae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152729
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-06-27 20:44:11 +00:00
Sam Rawlins
d022d4c9e1 Migrator: Fix if-null promotion with GLB
Fixes https://github.com/dart-lang/sdk/issues/42375

EdgeBuilder wishes to do its own GLB type-joining, as does FlowAnalysis.
When FlowAnalysis pushes a promotion in ifNullExpression_rightBegin,
and then in write, and then pops those two promotions to join them in
ifNullExpression_end, EdgeBuilder is not given a chance to make its
own GLB node. Instead promotion never happens: the DecoratedType which
is the variable's type is promoted to non-nullable, for the left side.
The DecoratedType for the right side expression is not considered
non-nullable, so the FlowAnalysis.join will always fail to promote.

TypeOperations.adjustPromotedTypes solves this. It is a no-op in all
implementations except in EdgeBuilder.

Additionally FlowAnalysis.write's promotion fails for the same reason:
the only type of interest is the declared type made non-nullable, and
no matter what, the writtenType is not a subtype of this.

TypeOperations.forcePromotion solves this. It is a no-op in all
implementations except EdgeBuilder.

Change-Id: Iba6b9a69583af8fe1aa23124c7d66047acfff495
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152104
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-06-25 21:09:12 +00:00
Nate Bosch
14aa6cd87a Remove a debug print statement
Change-Id: Ic2b595fe4201ec83ee374e2208bed7cba1d8be67
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152201
Auto-Submit: Nate Bosch <nbosch@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2020-06-23 20:49:23 +00:00
Sam Rawlins
448016e811 Migrator: add --preview-hostname option
Fixes https://github.com/dart-lang/sdk/issues/41084

Change-Id: I35068ecf2cf0cec5cac418146149d0e0705dc05d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151666
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-06-23 18:50:53 +00:00
Brian Wilkerson
ded14919b2 Clean up some hints in the migration engine package
Change-Id: I351884a7246b1f786b7e4fb468110dacfa2d5e4e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152106
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2020-06-23 18:08:43 +00:00
John Ryan
2d22e4ca26 Set informative-region text color.
Text is now white on a light-blue background.

Change-Id: Iac613c49fc8db6241ba013341fb29045f89048e2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152042
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: John Ryan <ryjohn@google.com>
2020-06-23 00:21:26 +00:00
John Ryan
3c85ade7f9 Migration tool UI improvements
- Update header text and buttons
- Add Roboto font
- Add Roboto Mono font
- Add Material icons font
- Update color scheme
- Move help button to header
- Change "Report a problem" button to "Send Feedback"
- Update button colors

Change-Id: Ia4d8b71ae8ec7a7c04ab8c238ffb0499becc9620
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151663
Commit-Queue: John Ryan <ryjohn@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2020-06-22 18:19:16 +00:00
Mike Fairhurst
ea7e6f29bf [nnbd_migration] Fix #42374: mark types as non-null for assert(is T)
Fixed: 42374
Change-Id: I009cba3d0a3d16e57aec24c62fbb3e0cbfa03c01
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151925
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
2020-06-22 18:08:36 +00:00
Brian Wilkerson
ab73158758 Fix the windows bot and update MockSdk
Fixing the test that's causing the Windows bot to fail required updating
the MockSdk, which cause a lot of other changes. I would have done this
in two separate CLs if I'd known how big this was going to get, but I'm
hoping it isn't too big.

Change-Id: Idee56bab5e73a78ab7857e81177090493aa08b40
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151874
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2020-06-22 14:34:25 +00:00
Paul Berry
717efd357f Migration: do not add ? after the Null type
Fixes #42322.

Change-Id: I4c26985da520e024b8a6c335834dd0fc2a41d59d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151561
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-06-17 21:29:51 +00:00
Paul Berry
7cd5e1ecbd Sort declarations in fix_builder.dart
Change-Id: I914e6fb43f17d8b2c2f01ec83a13c0bb9ef1e729
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151580
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2020-06-17 21:29:51 +00:00
John Ryan
8fe9dac0c8 add Dart logo to null safety migration tool
Change-Id: Ie9cd580fad0e596f1653e3a87cde75e133d1fe2d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151360
Commit-Queue: John Ryan <ryjohn@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2020-06-17 20:17:21 +00:00
Paul Berry
82750c58f7 Update toList in analyzer's mock SDK
Fixes #42327.

Change-Id: Iecab55d0c97d439de02ac63ba53a0511532c773f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151560
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-06-17 17:20:57 +00:00
Sam Rawlins
8fcb9e4b0e Migrator: draw a hard edge when marking an AsExpression non-nullable
Fixes https://github.com/dart-lang/sdk/issues/41397

Change-Id: I03307f297954f97911ed501240df17e48ef2dfc8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151480
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-06-17 14:38:24 +00:00
Paul Berry
0b12c1d775 Migration: fix crash when there is an extension in code not being migrated
Change-Id: Ie7d4daf827f7803ea4001a26e06aa58577b9d49a
Bug: https://buganizer.corp.google.com/issues/158730342
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151443
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-06-17 14:03:44 +00:00
Leaf Petersen
d44457f79d [Core Libraries] Eliminate the fork in the core libraries.
Move the nnbd core libraries from sdk_nnbd to sdk, and updates
references in build files and elsewhere accordingly.

Change-Id: I09760fe1e006657aacdfe80f3b22fdf6f7e30a9f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151121
Commit-Queue: Leaf Petersen <leafp@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
2020-06-16 23:37:36 +00:00
Paul Berry
ed9112e862 Sort declarations in api_test.dart
Change-Id: Ibe2b078f6a38a79d304ad81b1625c72a65fe53c0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151320
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2020-06-16 21:10:11 +00:00
Paul Berry
a9bb706ce2 Migration: allow the client to specify which files to analyze/migrate.
Change-Id: Ie49f003640342a8c0d26b4f509a9268200955dda
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151302
Reviewed-by: Janice Collins <jcollins@google.com>
2020-06-16 21:10:11 +00:00
Mike Fairhurst
e11eb2cd08 [nnbd_migration] Fix #42263, tool inserting ! on toString/hashCode
Fixed: 42263
Change-Id: Ia4c6d3543bc7628c76b85d986b9709de58925884
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151441
Auto-Submit: Mike Fairhurst <mfairhurst@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2020-06-16 20:21:31 +00:00
Paul Berry
d1638508c1 Migration: streamline behavior injection in migration_cli_test.dart.
We now store both environmentVariables and injectArtificialException
in the _MigrationCliTestBase class, and refer to them wherever they
are needed, so we reduce the amount of plumbing we need to do.

In a follow up CL I'll be adding more behavior injection using the
same technique.

Change-Id: Ib736373f7a92a46922964d3c5c59d35bf72d618a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151300
Reviewed-by: Janice Collins <jcollins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-06-16 17:52:10 +00:00
Sam Rawlins
efcb8f9213 Migrator: Do not connect return values to return types on generators
Fixes https://github.com/dart-lang/sdk/issues/42299

Change-Id: I07b3955907efa3007ec146f4cb4170b117b58dcf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151328
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-06-16 14:08:54 +00:00
Sam Rawlins
61184814e2 Migrator: use dart pub to check outdated
Fixes #42343

This also prevents a crash if the binary-to-execute could not be found.

Change-Id: I19dd9f6dcbb41a5c8b4ef2a04a87c1fc83429120
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151327
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-06-16 14:08:04 +00:00
Sam Rawlins
459255ab09 Migrator: Fix navigating to top-of-file
There is logic to navigate to the top of a newly-loaded page. It
broke with a visual redesign, in which the title of a page is always
sitting at the top of the screen. The new logic will scroll the page
to the first line of source text.

Change-Id: I685d1fb96c6ca1789f114871acd2bb8148e6ae7e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151032
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-06-15 18:15:12 +00:00
Paul Berry
2fbe5c1f54 Migration: Make the three migration phases explicit in NonNullableFix API.
Previously the API was general, exposing a `numPhases` integer, and
providing a generic processing function with a `phase` argument.  This
was necessary back when migration was built into DartFix (because
different kinds of fixes had different numbers of phases), but now
that migration is a separate tool, it gets in the way because it makes
it difficult for the caller to have different behaviors in different
phases.

This is a prerequisite for making it possible to have some files
analyzed but not finalized (which is in turn necessary for handling
generated files).

Change-Id: I5993808eb3dace21d8b6cb9c5308f94a3b1f898e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151081
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2020-06-15 15:26:48 +00:00
Paul Berry
9f8776f4a9 Migration: split out a MigrationCliRunner API from MigrationCli.
This API can be used by tools that wish to perform migration but want
to provide their own command-line argument parsing.

Change-Id: Ic54e993139c803ded5ac39229ae84980db12184e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151080
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2020-06-15 15:26:48 +00:00
Paul Berry
a7c93201e4 Migration: rework how MigrationCli.run() reports an exit code.
Previously, MigrationCli.run() would always return, but it would set
MigrationCli.exitCode to indicate whether an error occurred.  This
made it necessary to thread a lot of tricky logic around to ensure
that we would exit quickly if an error occurred.  This CL switches to
using an exception, so we get the same effect automatically.

Change-Id: I2b885092dec551700900b118ec3d9acd2f3649d7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150760
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2020-06-15 15:26:48 +00:00
Sam Rawlins
3dc27a55fa Migrator: Add a failing test for #42327
Bug: https://github.com/dart-lang/sdk/issues/42327
Change-Id: I5ac4dbaf95efdc7b54ea4009b78187e519cac92d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151094
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-06-13 14:31:15 +00:00
Sam Rawlins
213f805294 Migrator: Bump highlight.js to 10.1.0
Fixes https://github.com/dart-lang/sdk/issues/41885

Change-Id: I2c19a36f0eb46e2941ca143c23e2b0be938b7d96
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151089
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-06-12 22:17:12 +00:00
Sam Rawlins
b907f9928f Migrator: Begin flow analysis on top-level annotations
Fixes https://github.com/dart-lang/sdk/issues/42295

Change-Id: I9d224b5c8a3fa5d57f17e434a9e6dfbcebc14781
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151026
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-06-12 22:01:32 +00:00
Paul Berry
b1442a1f9a Remove unused import
Change-Id: I6d25e5ea3f1fdf320ec85d5f405789e6e8c2ddf0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151084
Auto-Submit: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2020-06-12 20:25:39 +00:00
Paul Berry
43131b575e Migration: fix crashes with extension Foo<T extends ...> on T
Change-Id: I3a8f1be4f52a6a49bb57ab032fef668482f5acf6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151002
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-06-12 18:21:15 +00:00
Devon Carew
c607eb9637 [nnbd_migration] address an issue with the progress text written to stdout
Change-Id: I8bd4b4a291d1d64b48752c06f2ec7784e5bac819
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151040
Commit-Queue: Devon Carew <devoncarew@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2020-06-12 00:18:46 +00:00
Mike Fairhurst
6b40b26044 [nnbd_migration] Print warning when SDK_PATH is set and things go wrong.
Also clean up sanity checking code a little bit.

Change-Id: I4274dad42687a4dc419090d656ec56168c982c29
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150661
Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-06-11 17:19:51 +00:00
Paul Berry
2a5c122d4a Migration: Fix EdgeBuilder._unimplemented if node==null
Change-Id: Id1a297f1ee5eaf4d7111ad081a0a8c49cb334303
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150801
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-06-11 16:14:42 +00:00
Sam Rawlins
6ac9749546 Update nnbd_migration README with more details.
* Use title case on all headings.
* Link to https://dart.dev/null-safety and
  https://dart.dev/tools/pub/cmd/pub-outdated
* Remove any text which suggests to publish. Official docs warn
  strongly against using in production.
* Mention `pub outdated --mode=null-safety`.
* Mention migrating a clean code repository.
* Add more text about committing along the way.
* Make clear that the tool provides no revert capability.

Change-Id: I7914dc904a93046ce2508c51cae158ac39e889af
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150822
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2020-06-11 03:33:25 +00:00
Samuel Rawlins
5a32ff0d7f Revert "Bump cli_util to 0.2.0; implement new methods"
This reverts commit ebcc6dc2a2.

Reason for revert: Broke golem. I think there are more implementations of Logger than I realized.

Original change's description:
> Bump cli_util to 0.2.0; implement new methods
> 
> This fixes the issue of progress indicators being shown during tests.
> 
> Change-Id: I39fd68cfeca70a63d088aceb4325b42c53766afd
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150669
> Commit-Queue: Samuel Rawlins <srawlins@google.com>
> Reviewed-by: Paul Berry <paulberry@google.com>

TBR=paulberry@google.com,jcollins@google.com,mfairhurst@google.com,srawlins@google.com

Change-Id: I52ac0f5d96a161534c28cc160c2a2b3b364ad511
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150693
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-06-10 23:59:05 +00:00
Sam Rawlins
ebcc6dc2a2 Bump cli_util to 0.2.0; implement new methods
This fixes the issue of progress indicators being shown during tests.

Change-Id: I39fd68cfeca70a63d088aceb4325b42c53766afd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150669
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-06-10 22:10:06 +00:00
Paul Berry
ae3b975373 Migration: exit early if an exception occurs
Change-Id: I108b64d75f9eb4ab376dfacaaeafcac1ef333755
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150580
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2020-06-10 13:50:27 +00:00
Paul Berry
aa2566410f Migration: Add a flag to allow the user to ignore exceptions.
This should allow users to work around bugs while waiting for fixes
from the migration team.

Change-Id: I04fe08b4753ee1377a60ec60728a16560847536f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150542
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2020-06-10 13:50:27 +00:00
Mike Fairhurst
2a3d15e16f [nnbd_migration] Decorate Never type.
Both John and I have hit this in our own projects, seemed worth fixing.

Change-Id: Ic053287d365b92cbfd72448fe401ca627891f802
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150663
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
2020-06-10 04:24:17 +00:00
Paul Berry
3aad249fe2 Sort declarations in preview_site_test.dart
Change-Id: I6154bcff1b6421207ef3c76b5679a1d5d3b6a4ba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150541
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-06-09 15:14:21 +00:00
Paul Berry
9907b0327b Migration: add an api_test of a14n's repro for #41397
Bug: https://github.com/dart-lang/sdk/issues/41397
Change-Id: I271b8d961faf12d84f5ebd28ac44ec1d8490b465
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150540
Auto-Submit: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2020-06-09 13:58:16 +00:00
Paul Berry
e4aaa1146b Sort declarations in migration_cli.dart
Change-Id: I05025f629080725f39a762c1d9f54d3aac7bf950
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150463
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-06-08 23:44:50 +00:00
Paul Berry
96c2cc2589 Migration: fix class hierarchy handling in FixBuilder.
When running the FixBuilder we need to override the behavior of
ClassElement.interfaces so that it returns the post-migration
interface types.  We also need to override the behavior of
LibraryElement.isNonNullableByDefault so that the library being
migrated is considered opted in during FixBuilder analysis.  This
required adding hooks to the analyzer to allow those overrides.

Additionally, since the analyzer caches the InheritanceManager, we
need to clear that cache out just prior to running the FixBuilder, so
that no pre-migration interface types leak into the FixBuilder.

Fixes #40475.
Fixes #42139.

Change-Id: I45e2c30ebe8c12e4a599e2458d77a3731bad0f98
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150260
Reviewed-by: Janice Collins <jcollins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-06-08 17:26:41 +00:00
Paul Berry
b7abe2cf00 Migration: change how migration_cli_test checks for a correct SDK.
When tests are run internally under bazel, there's no `version` file
we can look for to verify that we are looking at an SDK directory.
Looking for a `bin` directory works equally well.

Change-Id: Ib19350eaf90d105ebaa3d197fb45b5a41a10179d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150285
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-06-08 16:47:16 +00:00
Devon Carew
88f20ece1e [nnbd_migration] re-land a fix for migrating packages with multiple contexts
Change-Id: I60365e4a159f8696b17a8dd7f6d3fa0641a5afae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149889
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
2020-06-04 17:05:57 +00:00
Paul Berry
ac45f23134 Migration: Fix reporting of exceptions.
Permissive mode in the analyzer currently is broken, leading to a
useless stacktrace if an exception occurs.  As a quick fix, turn
permissive mode off, so the exception just bubbles up normally and
shows on the console.  In follow-up CLs I'll actually fix permissive
mode and add a user option to enable it.

Fixes #42138.

Change-Id: I59322ca9dd90b856c56a6ec335762b94ec6935b7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149863
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-06-04 13:01:51 +00:00
Paul Berry
af588af7de Prepare to publish package nnbd_migration
Change-Id: Ia56b262688c2eb1e0fd8edeef18de562a59c52b1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149801
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-06-03 18:49:59 +00:00
Michael Thomsen
ab2020725c Clarify migration guidance
Closes https://github.com/dart-lang/sdk/pull/42172
https://github.com/dart-lang/sdk/pull/42172

GitOrigin-RevId: af666ade7a03affc5210ddd644ac1f9ede682df1
Change-Id: I2cf627aab3d79c32025a2fd345d30dc97ef0cc02
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149802
Reviewed-by: Kevin Moore <kevmoo@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-06-03 16:06:53 +00:00
creativecreatorormaybenot
1b886a806d [nnbd_migration] Fix typos/mistakes
The text says "We can fix this all by adding a single `/*!*/` hint.", but the code uses `/*?*/`. I am pretty sure that this is wrong.

Closes https://github.com/dart-lang/sdk/pull/42153
https://github.com/dart-lang/sdk/pull/42153

GitOrigin-RevId: f8b974b475bdaaa5c9c82204e2313d539a8247d7
Change-Id: I03a991b93bced2e24562f57128ef4bfb21eabf82
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149685
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2020-06-03 16:06:01 +00:00
Devon Carew
ceb08283df Revert "[nnbd_migration] handle multiple contexts"
This reverts commit 54adfeb93f.

Reason for revert: this breaks the windows bot

Original change's description:
> [nnbd_migration] handle multiple contexts
> 
> Bug: https://github.com/dart-lang/sdk/issues/42141
> Change-Id: I64179cd3fa0389397a8a9b3a763fbb1a3719294e
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149664
> Commit-Queue: Devon Carew <devoncarew@google.com>
> Reviewed-by: Paul Berry <paulberry@google.com>

TBR=paulberry@google.com,devoncarew@google.com

Change-Id: I793d8f4a2832e7da0cb30565aee4a4806c0b0e02
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: https://github.com/dart-lang/sdk/issues/42141
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149803
Reviewed-by: Devon Carew <devoncarew@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
2020-06-03 16:04:53 +00:00
Mike Fairhurst
e39568516b [nnbd_migration] Fix #42117, cannot load edit details on windows.
Change-Id: I5b10861b870d0d3d37a9abfacbc18152844e4ec9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149760
Commit-Queue: Paul Berry <paulberry@google.com>
Auto-Submit: Mike Fairhurst <mfairhurst@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-06-03 12:20:19 +00:00
Paul Berry
b0df013ac8 Migration: fix pubspec deps.
The previous deps had never been validated and were wrong in many ways
(for some deps the constraint was too narrow or too wide; other deps
were missing or extraneous).  I did some experimenting with `pub get`
and `pub run test` to find the earliest version of each package for
which the version solve succeeds and the tests pass.

Note, however, that nnbd_migration currently depends on unpublished
functionality from the _fe_analyzer_shared and analyzer packges.  So
before publishing nnbd_migration we'll need to publish
_fe_analyzer_shared and analyzer and then update the pubspec one last
time.

Change-Id: If8453226bfcc5e94ac84f1a3fdc0d2f4ee150f54
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149661
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-06-02 19:20:53 +00:00
Devon Carew
54adfeb93f [nnbd_migration] handle multiple contexts
Bug: https://github.com/dart-lang/sdk/issues/42141
Change-Id: I64179cd3fa0389397a8a9b3a763fbb1a3719294e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149664
Commit-Queue: Devon Carew <devoncarew@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-06-02 18:40:43 +00:00
Sam Rawlins
93d39a5ef5 Migrator: Edit the package_config.json file
Bug: https://github.com/dart-lang/sdk/issues/41765
Change-Id: I019a97427b6faa4d4f5335b64424fab4bc3c5cde
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149611
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-06-02 15:51:11 +00:00
Paul Berry
609b7f3735 Migration: change how we set the CLI exit code.
Setting exitCode (rather than calling exit) allows Observatory to keep
running, which makes for easier debugging.

Change-Id: If9812ead72ac04808030cd62467ba2f09b92b947
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149609
Reviewed-by: Kevin Moore <kevmoo@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-06-01 21:21:48 +00:00
Sam Rawlins
b9a89b223f Migrator: improve pubspec parsing
* Prevent cast exception crash when pubspec.yaml is not a map
* Prevent cast exception crash when pubspec sdk is not a string
* Test error cases for parsing pubspec.

Change-Id: Id392815207dc52719cfec5038d6fa2d09f952f08
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149602
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-06-01 17:57:07 +00:00
Devon Carew
2c5739bd2b [nnbd_migration] update the CLI instructions of the migration tool
Change-Id: If42abe73b9a6640e3e1a7d2ecc23bd604c57238e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149603
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
2020-06-01 16:25:04 +00:00
Sam Rawlins
258b6cb525 Migrator: tweaks to README
* Change the "Migrating a package" to be an ordered list of steps.
* Spell 'url' as 'URL'.
* Be consistent about capitalization and hyphenating "null-safe" and not
  hyphenating "null safety".
* Add text that the tool will edit pubspec.yaml.

Change-Id: Ief5eac682af2813d267568695f920445b0b79615
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149484
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-05-30 23:40:42 +00:00
Mike Fairhurst
42b71b8f9e [nnbd_migration] Fix #41795, delete/change hint causes rerun.
This is only an issue for the old style (not in stacktrace) buttons.

I did not add a test for this; there are many tests for this code in the
new workflow, inside UnitInfo.handleSourceEdit, etc, and this code path
will be removed soon hopefully.

I *did* test manually and saw that it works.

Change-Id: Iac8ba4cb775b9b15c8db1c1cadd4701da81452be
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149382
Commit-Queue: Paul Berry <paulberry@google.com>
Auto-Submit: Mike Fairhurst <mfairhurst@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-05-29 14:33:15 +00:00
Sam Rawlins
d79c5b5d31 Migrator: run pub outdated from the correct directory
Fixes https://github.com/dart-lang/sdk/issues/42084

Change-Id: I74eb3cbf61f4346b82f81f77977989fbbd7f8274
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149366
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Janice Collins <jcollins@google.com>
2020-05-29 00:23:09 +00:00
Sam Rawlins
2dea325d87 Migrator: use pub.bat on Windows
Fixes https://github.com/dart-lang/sdk/issues/42102

Change-Id: Ic2dd785a84835402c7af3ef7b8d15285585a0afb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149386
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Reviewed-by: Janice Collins <jcollins@google.com>
2020-05-28 23:17:12 +00:00
Paul Berry
bf30eb53e2 Migration: Remove "fantasy land" functionality
We're not currently working on this, and it has some dependencies that
interfere with publishing the migration tool.  If we wind up needing
it again, we can always revert.

Change-Id: Ia6219ac376cef77bda7470777eaf2bebf38769b4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149343
Commit-Queue: Janice Collins <jcollins@google.com>
Reviewed-by: Janice Collins <jcollins@google.com>
2020-05-28 22:05:05 +00:00
Paul Berry
2e261f9386 Migration: add locations to trace entries that refer to elements.
Bug: https://github.com/dart-lang/sdk/issues/41402
Change-Id: I0dc59ae9d64c6e8ab470b2ddcb5fd42557ba5704
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148742
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-05-27 21:52:14 +00:00
Paul Berry
be6cbd3fb8 Sort declarations in instrumentation_test.dart
Change-Id: I0a9febdad57779b2d9d3f17e1d4909194ca15772
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148740
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Janice Collins <jcollins@google.com>
2020-05-27 21:52:14 +00:00
Mike Fairhurst
76839d5e4d [nnbd_migration] Fix navigation urls on windows.
Change-Id: I226b36039c781e3f12b76e8ee3a5ae5e8eefcbed
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149055
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
2020-05-27 19:56:14 +00:00
Konstantin Shcheglov
00fa48fbb1 MockSdk does need to create summary.
Change-Id: Id62bc99394e9afd6306ba6a12118d7bcd045a598
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149202
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-05-27 19:39:10 +00:00
Sam Rawlins
3c6a3fba30 Migrator: Add some failing tests for extensions
Bug: https://github.com/dart-lang/sdk/issues/39387
Change-Id: I2187db2433255fd950789942712d215c2472db4f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149005
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-05-26 23:24:22 +00:00
Konstantin Shcheglov
279024d823 Deprecate InstanceCreationExpression.staticElement
Change-Id: I3c2de8ce22944963418d543b887720db15badd0d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148981
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-05-26 22:56:42 +00:00
Sam Rawlins
0f7653bb66 Migrator: Fix crash when target of extension method invocation has type names
Fixes https://github.com/dart-lang/sdk/issues/41958

Change-Id: Ib6e3b9d8fbb9d0083c007118a346150d57969461
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148884
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-05-26 17:54:13 +00:00
Konstantin Shcheglov
80e9667f2c Fix unused imports.
R=brianwilkerson@google.com

Change-Id: I02f47632bef3a2e601f7f471c7149829e06844f6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148963
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-05-25 16:58:38 +00:00
Sam Rawlins
16b90d2085 Migrator: Check dependencies with pub outdated
Fixes https://github.com/dart-lang/sdk/issues/41769

Change-Id: I892322076c1d03026c42c13b98bb1dcb466e9263
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148789
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2020-05-21 22:06:53 +00:00
Mike Fairhurst
9bcdbfa34e [nnbd_migration] Update README
Change-Id: Idc81bbebadbe3d6111a6e7e31ee0c68a30d8ff26
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148795
Reviewed-by: Devon Carew <devoncarew@google.com>
Reviewed-by: Janice Collins <jcollins@google.com>
2020-05-21 19:50:23 +00:00
Sam Rawlins
07dd27673a Migrator: Fix crash when casting to generic type
Fixes https://github.com/dart-lang/sdk/issues/41955

Change-Id: I6ca9f1ceae7992f4085f96c927ec989dbb6e2568
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148741
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-05-21 17:09:43 +00:00
Sam Rawlins
562b11a4d8 Migrator: Add types to implicitly-typed field formal parameters
Fixes https://github.com/dart-lang/sdk/issues/38453

Change-Id: I56474071fcc7d408487fc74bd76d7520022f0259
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148643
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-05-20 22:29:14 +00:00
Mike Fairhurst
361070ba3f Reland [nnbd_migration] Fix two popup style bugs
Relands https://dart-review.googlesource.com/c/sdk/+/148642

Due to a z-index bug, regions are showing up on top of the popup. Fixed.

A regression during a previous a.button/.button change that meant that
the close button wasn't rendered as a button.

Previous change from `a.button/.button` reduced the specificity which
caused incorrect font color in edit link buttons. This has been fixed by
using `.button, a.button` so that we keep the desired specificity but
also keep applying the style to all elements with the `button` class.

Change-Id: Idb5eb154904430d946a80b7574537564b7c71bd1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148646
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
2020-05-20 18:04:02 +00:00
Mike Fairhurst
5910a61a7b [nnbd_migration] Show error popup on GET requests, refused connections.
I noticed that failed GET requests did not show the error popup. At the
time it seemed like uncommon enough to not be a priority, but this is
occurring frequently for windows users, so it's not reasonable to rule
this out and should be handled.

I also have seen that if the preview server is killed, we get an
unhandled `ProgressEvent` error which is just "instance of minified:ew",
handle that case more gracefully as well.

Change-Id: I4f1f307dc33cd7bf0d76a9702df6728dda09926e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148601
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
2020-05-20 18:01:51 +00:00
Mike Fairhurst
79762f96f8 [nnbd_migration] fix hint test on windows that unnecessarily maps a path
Change-Id: Id35ae2332520c96265b92abd31c8ec3a92521c8b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148569
Commit-Queue: Paul Berry <paulberry@google.com>
Auto-Submit: Mike Fairhurst <mfairhurst@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-05-20 15:42:54 +00:00
Paul Berry
15df850fd3 Migration: fix trace display for variable and field types.
Change-Id: Ib601fea6b6edd50a047471fe4eacf56339e4a4a0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/147345
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-05-20 15:09:10 +00:00
Mike Fairhurst
71c10c4c9c [nnbd_migration] Fix navigation tree test on windows
Change-Id: Ib6bbf1af5c6061423093e1b05a1ce135ee097d47
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148686
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Auto-Submit: Mike Fairhurst <mfairhurst@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2020-05-20 14:05:10 +00:00
Mike Fairhurst
4e2f7ac9a2 [nnbd_migration] Fix navigation tree on windows.
Ensure that the preview server responds with full paths so that the
front end does not need to do path magic on relative links, and test
that those full paths are correct on both windows and linux.

Remove [UnitLink.uri], as it is no longer correct, and it does not have
access to a [PathMapper] which is necessary to build a correct URI.

Change-Id: I7ef764d84c0859d72a21134dc042f837767e91b1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148565
Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-05-19 21:08:51 +00:00
Mike Fairhurst
a2a98e2362 [nnbd_migration] Fix stack trace links on windows.
Previously, the backend was returning a relative URI, but that doesn't
work when you have stack traces across root directories. So the front
end used path logic to turn the relative path into an absolute one, but
it didn't do this correctly on windows.

Instead just send an absolute path (still a relative URI, though) from
the backend.

Change-Id: Ied06a9d948851fcf6dc1d4aa007961d3d2a000fd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148564
Reviewed-by: Paul Berry <paulberry@google.com>
2020-05-19 21:08:51 +00:00
Mike Fairhurst
59d66151d8 [nnbd_migration] Fix edit region top link on windows.
We want to continue to show windows users the windows path, but on click
we want to take load based on the uri path.

Change-Id: Idb1bff3cac1a7b9830c3a4458fc79fbf76551b4f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148561
Reviewed-by: Paul Berry <paulberry@google.com>
2020-05-19 21:08:51 +00:00
Mike Fairhurst
73c51fc03b Revert "[nnbd_migration] Fix two popup style bugs"
This reverts commit 480e34ce99.

Reason for revert: `button, .button` is not specific enough, has too low of precedence, resulting in edit link buttons getting the wrong color. Will reland as `button, .button, a.button`. Thanks CSS :)

Original change's description:
> [nnbd_migration] Fix two popup style bugs
> 
> Due to a z-index bug, regions are showing up on top of the popup. Fixed.
> 
> A regression during a previous a.button/.button change that meant that
> the close button wasn't rendered as a button.
> 
> Change-Id: I2c8b84655bd8afdbc0163f5dd810bca84c3db8b2
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148642
> Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
> Commit-Queue: Paul Berry <paulberry@google.com>
> Auto-Submit: Mike Fairhurst <mfairhurst@google.com>
> Reviewed-by: Paul Berry <paulberry@google.com>

TBR=paulberry@google.com,mfairhurst@google.com,srawlins@google.com

Change-Id: I29f92aaa79c6285e2822866660e1b5f77b1f43ae
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148644
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2020-05-19 18:18:30 +00:00
Paul Berry
de5b23d63d Migration: remove abstract interfaces defined by analysis_server for use by nnbd_migration.
These interfaces acted as a temporary bridge to allow analysis server
core classes to provide services needed by nnbd_migration without
forcing analysis_server to depend on nnbd_migration; that in turn
allowed the analysis server to provide migration services to dartfix.
Now that we no longer use the analysis server nor dartfix for
migration, these interface classes are no longer needed.

As of this commit, the nnbd_migration package no longer depends on
analysis_server.

Change-Id: Ia923d91dd59c9a612000da8b0c9ead8a68686d89
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148560
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2020-05-19 18:09:54 +00:00
Paul Berry
4f4ef71798 Migration: copy pages.dart to nnbd_migration package.
Previously we re-used pages.dart from the analysis server.  This paves
the way for making nnbd_migration independent of the analysis server,
which will allow it to be published on pub.

Note that only the portions of pages.dart that are actually used by
nnbd_migration are retained.

Change-Id: I48db228a3bf372cf918f2d2719f8f5415ddfc193
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148511
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2020-05-19 18:09:54 +00:00
Paul Berry
e248acc156 Migration: remove dependency on analysis server's fix_code_task.dart.
Change-Id: I07b30dbfdf82d940f51d8f009d0e44e2baea15ef
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148509
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2020-05-19 18:09:54 +00:00
Paul Berry
9261549cdb Migration: eliminate preview_site_test.dart's dependency on analysis_server.
Change-Id: I7582f1cfc52d1fa7ed84e1c2f9b3669d3af4ef57
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148541
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2020-05-19 18:09:54 +00:00
Mike Fairhurst
480e34ce99 [nnbd_migration] Fix two popup style bugs
Due to a z-index bug, regions are showing up on top of the popup. Fixed.

A regression during a previous a.button/.button change that meant that
the close button wasn't rendered as a button.

Change-Id: I2c8b84655bd8afdbc0163f5dd810bca84c3db8b2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148642
Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Auto-Submit: Mike Fairhurst <mfairhurst@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-05-19 18:01:30 +00:00
Sam Rawlins
718c83abe6 Migrator: Add decorated types for class alias implicit constructor parameters
This is necessary for the included test case, and also for an upcoming
change to MigrationResolutionHooksImpl to support changing parameter
types in general.

Bug: https://github.com/dart-lang/sdk/issues/38453
Change-Id: I587ae86943d0fa349b03037a76dee91fb0298dcc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148583
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-05-19 17:26:51 +00:00
Paul Berry
e1316a1cc1 Migration: replace imports of analysis_server with imports of analyzer_plugin where possible.
Change-Id: I329e423bbe47645432d7a37e50a1877c7395f63d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148504
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-05-19 17:08:00 +00:00
Paul Berry
e589f5f76b Migration: remove isolate_server.dart.
This code was necessary when the NNBD migration engine was part of the
analysis server, to allow migration to be run in-process.  Now that
it's been separated to its own library, it always runs in process, so
this code is not needed anymore.

Change-Id: Id9e497dca6700ad804f2410cb3b20107be3a4bd2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148503
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2020-05-19 17:08:00 +00:00
Paul Berry
fc9ed66071 Migration: remove analysis_server dependencies from some test classes.
These tests were initially based on analysis server tests, so they
shared a lot of analysis server infrastructure.  However, none of that
infrastructure was really needed; we can test equally well just using
analyzer infrastructure.  This helps pave the way for removing the
dependency from nnbd_migration on analysis_server, which will in turn
allow nnbd_migration to be published as its own package.

Change-Id: Icccb73a6248a0b766db5cfe66f42a6dceac0d944
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148540
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2020-05-19 17:08:00 +00:00
Paul Berry
fa3a17bc4f Sort declarations in nnbd_migration_test_base.dart
Change-Id: I866fe463c81f59e40898f3ac39df54d8fc1a3c19
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148469
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2020-05-19 17:08:00 +00:00
Paul Berry
48202fa5c2 Migration: extract some implementation details from migration_cli.dart
This will enable these classes to be re-used in unit tests.

Change-Id: Icb5e7ede94603577de44a7d53c30bb4e76a92b96
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148465
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2020-05-19 17:08:00 +00:00
Mike Fairhurst
f943d994d3 [nnbd_migration] Support change hint type in stack trace
Change-Id: I715875bb72d4a19480c5f42e796b4ec4cabe3881
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148189
Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-05-19 16:34:20 +00:00
Mike Fairhurst
b21ee57ccd [nnbd_migration] Support remove hint action in stack traces
Change-Id: I2878fde38b233747d8cf9e3e8666b5768f3125fa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148187
Reviewed-by: Paul Berry <paulberry@google.com>
2020-05-19 16:34:20 +00:00
Mike Fairhurst
a8ab569f5c [nnbd_migration] Support deletions in UnitInfo.handleInsertion
Change `handleInsertion` to use a `SourceEdit` instead, and update
`PreviewSite` to use it, but otherwise do not change `PreviewSite`. That
can be tested later when we have new `HintAction`s that allow us to
exercise this new code.

Change-Id: Idd6d782e003d4d643abb5770daa9055685f2e76a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148186
Reviewed-by: Paul Berry <paulberry@google.com>
2020-05-19 16:34:20 +00:00
Mike Fairhurst
fdc19bc8f1 [nnbd_migration] Support replace/delete in offset mappers.
Change-Id: Ieef27cff8c9d03537b8f80e5d436eec524abac7e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148220
Reviewed-by: Paul Berry <paulberry@google.com>
2020-05-19 16:34:20 +00:00
Mike Fairhurst
6208c169c7 [nnbd_migration] Fix #41872, don't lose stacktrace state on edit
Change-Id: I51bc87416d382854e8eb94404e4c3c3b1ef92a43
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148005
Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-05-15 19:21:48 +00:00
Mike Fairhurst
40d048ac29 [nnbd_migration] Fix hint action windows test.
Previous windows-incompatible implementation of hint action mapped the
path unnecessarily. The path for the new hint action comes from the AST
node and not a web URL and therefore should not be (and cannot be)
mapped for it to work on windows.

In the process of fixing this on cli_test, I missed this place where an
extra map was added in the preview_site test code which causes the test
to fail on windows.

Change-Id: If8d175379f0cb9fe864ab1f588af514a17b4758b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148229
Auto-Submit: Mike Fairhurst <mfairhurst@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
2020-05-15 19:15:43 +00:00
Paul Berry
166d083389 Migration: remove directory lib/api_for_analysis_server.
This existed solely to have a centralized location for the analysis
server's dependencies on nnbd_migration.  Now that nnbd_migration
doesn't depend on the analysis server, there's no need for it anymore.

Change-Id: I24b231337b1f724840b4533afef1672241b0af4b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148181
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Janice Collins <jcollins@google.com>
2020-05-15 17:12:02 +00:00
Paul Berry
c38742cdbc Migration: remove references from analysis_server to nnbd_migration.
Change-Id: I90b562b8b3e82b770f197d7ef2c4e10ac9f99100
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148160
Reviewed-by: Janice Collins <jcollins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-05-15 16:49:32 +00:00
Mike Fairhurst
5b81c0a6d2 [nnbd_migration] Handle stack trace edit links in web view
Change-Id: Ib893059681dbf8d29a575b71df6e67eb50f0c814
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/147815
Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-05-14 22:51:45 +00:00
Mike Fairhurst
f6d1c93a70 [nnbd_migration] Handle new stack trace add hint action
Change-Id: I94e11938214413955e066f5e1b00c412ee6d78f0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/147814
Reviewed-by: Paul Berry <paulberry@google.com>
2020-05-14 22:51:45 +00:00
Paul Berry
d00d800f3a Migration: connect dartdev to new command-line API.
We no longer use the analysis server or dartfix for migration.

This should unblock removing migration integration from dartfix, which
will unblock publishing dartfix.

It should also pave the way for future changes that will allow us to
publish the NNBD migration tool on pub, which in turn will allow us to
provide updates and bug fixes to the migration tool without having to
publish a new Dart or Flutter SDK.

Change-Id: I9f128b61a2983befc5ef686867dab3db87fd6855
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148020
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-05-14 18:03:21 +00:00
Paul Berry
898f28d51a Migration: do not parse args in new CLI handler.
This is a step toward integrating the new migration CLI with dartdev.
It's necessary because dartdev handles arg parsing.

Change-Id: Ie50a69c434fd4d8873616e72b8274545cf0277d8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148007
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2020-05-14 18:03:21 +00:00
Sam Rawlins
a432ca0f8c Migrator: Improve adding explicit types to parameters and variable declarations
While working on #38453, I encountered these issues.

Change-Id: I6abbfca19d9f6de771181e7f5515681cbbc39a4e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148080
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-05-14 17:32:01 +00:00
Mike Fairhurst
95e11bc2d3 [nnbd_migration] Fix #41894, corrupt offset mapper on edit links.
Fixed: 41894
Change-Id: Ice7b436baa57c473f8cdcab02580b8e531372d7b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148026
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
2020-05-14 17:22:01 +00:00
Sam Rawlins
ba82e5cc5d Migrator: Update non-nullable Details click region
Fixes https://github.com/dart-lang/sdk/issues/41851

Screenshot (5% darker than surrounding bg): https://screenshot.googleplex.com/pzOBBoOC5MV.png

Alternatives:
10% darker than surrounding bg: https://screenshot.googleplex.com/6CpRZKegTNH.png
10% lighter than surrounding bg: https://screenshot.googleplex.com/m5tTsrwmrxx.png
info icon: https://screenshot.googleplex.com/Awwc8U9i0fo.png
rectangle: https://screenshot.googleplex.com/1vrKRyXUx1g.png
struck thru question: https://screenshot.googleplex.com/43st7uupEpo.png

I tried many different tweaks and a lot of things looked very bad:

* subscript _i_
* superscript _i_
* bang

I think the main problem with the previous look was that the background
of the rectangle was exactly the color of the other text, so it really
looked like there might be a masked character, as Devon pointed out.
This CL fixes that aspect, changing the background to be a grey,
slightly darker than the other gray background.

Reference:

* UTF question marks: https://unicode-search.net/unicode-namesearch.pl?term=QUESTION
* UTF boxen: https://www.fileformat.info/info/unicode/block/geometric_shapes/list.htm
* UTF

Change-Id: I8378376eabaf849488fddb150780dbb256779a00
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/147942
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2020-05-13 23:39:23 +00:00
Mike Fairhurst
fc391eb620 [nnbd_migration] Add hint actions to stack trace info
Still not rendered by the front end or handled by the server, but now
sent over to the front end via json encode/decode.

Change-Id: I3f93dc78d9981bf08fddf03bcf484a0fc324b66a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/147809
Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-05-13 22:31:03 +00:00
Mike Fairhurst
547b72d55b [nnbd_migration] Create a simple node mapper, part of instrumentation
Change-Id: Ia7b3f60ea6e5ce8518e62013e4deb0d315426f86
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/147802
Reviewed-by: Paul Berry <paulberry@google.com>
2020-05-13 22:31:03 +00:00
Mike Fairhurst
c18db7c8dd [nnbd_migration] Build hint actions in node builder.
Change-Id: I36428e72170d07f0f234aab0290365ca47f5b08a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/147801
Reviewed-by: Paul Berry <paulberry@google.com>
2020-05-13 22:31:03 +00:00
Mike Fairhurst
424c2ad5a7 [nnbd_migration] Add model for hint actions stored on nullability nodes.
In the future this could change to simply be a `Set<HintActionKind>`, so
that the `AtomicEdit`s can be calculated lazily. However, for the first
pass, they are calculated eagerly. This model lets us do that.

Change-Id: I07108ae0876d5e0efe7b35559cedb4cbd1c13605
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/147624
Reviewed-by: Paul Berry <paulberry@google.com>
2020-05-13 22:31:03 +00:00
Mike Fairhurst
b33496bbbd [nnbd_migration] Add header to edit links section
This is to differentiate it from the edit links that appear inside the
stack trace in later CLs for #41077.

Change-Id: I018518cb16ef09a4959895bb4becd10cbabbea23
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/147622
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-05-13 22:31:03 +00:00
Konstantin Shcheglov
123f92f239 Remove unused extension in NavigationTreeRendererTest.
Change-Id: Ieeac05bac86f06cb8fbd21169574e5b53fa3988d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/147941
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-05-13 21:08:56 +00:00
Paul Berry
fabceab5ee Migration: remove changedPaths tracking.
See comments in
https://dart-review.googlesource.com/c/sdk/+/147043/1/pkg/nnbd_migration/lib/migration_cli.dart#484
for why this is unnecessary.

Change-Id: I046835d73eb581aecd8d65b1e3248d07daf34f17
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/147702
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2020-05-13 20:42:56 +00:00
Sam Rawlins
ae5eb469dc Fix trace for unnamed constructors; remove stack frame icon
Bug: https://github.com/dart-lang/sdk/issues/41851
Change-Id: Ib3a4b76f094c2c4ce55e8617138ab6403b9d80f6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/147825
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-05-13 18:12:02 +00:00
Paul Berry
83a2b2e51d Migration: exclude "never" node from "why not nullable" traces
Change-Id: I7b1e22b439dc32b5272e13c947f86e640ffc366b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/147050
Reviewed-by: Janice Collins <jcollins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-05-12 17:50:39 +00:00
Paul Berry
94997823c0 Migration: verify that the preview server doesn't leak information from outside the project
Change-Id: Ic49f02ab58bff367ac55c4807feecb54a28aa0f1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/147045
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2020-05-12 16:33:59 +00:00
Paul Berry
9e087df222 Migration: fix rerunning migration tool after adding/removing files
Change-Id: I33e7ab428902efa44c7569fefc9f9c7436cae740
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/147044
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2020-05-12 16:33:59 +00:00
Paul Berry
383e75e5de Migration: add rerun support to new CLI
Change-Id: If4e2854f0326ef0ef2d03a83a647a3d3bb092d76
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/147043
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2020-05-12 16:33:59 +00:00
Sam Rawlins
af99babc6c Migrator: Only print text about --apply-changes conditionally
Fixes https://github.com/dart-lang/sdk/issues/40881

Change-Id: I4671e29f05ca9495419681a1f3fcb9d1718acbf8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/147334
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-05-12 13:57:09 +00:00
Sam Rawlins
c6db98667a Migrator: Add a progress bar; fixes #41187
The progress bar fills the width of the user's terminal, and computes
progress strictly based on files and phases, not weighing any file or
phase as greater than another.

Change-Id: Ic9840b3b66789512e0973160b3e0f069b714a4f8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/147421
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Janice Collins <jcollins@google.com>
2020-05-12 01:22:11 +00:00
Paul Berry
9019699520 Migration: reorganize code in source_edit_diff_formatter.dart
Based on suggestions from
https://dart-review.googlesource.com/c/sdk/+/146442.  Specifically,
the `_Output` class hierarchy has been moved to a new file so that the
classes in it are together, and the remaining classes (in the
DiffStyle hierarchy) are together in source_edit_diff_formatter.dart.
This required making a bunch of things public, so I split `DiffStyle`
into an interface and and impl class to make it easier to see which
method is intended to be used (DiffStyle.formatDiff).  Also, moved the
logic that was previously in _Output._processEdits to
DiffStyleImpl.formatDiff.

Change-Id: Iad448f16233e6752e7b20d1e0cee4eb5c033f498
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/146821
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-05-08 12:48:54 +00:00
Paul Berry
6ef6d3ca89 Migration: sort declarations in instrumentation.dart.
Change-Id: I8c4c38300de959a38d00d6b3fad8f490060c1018
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/146982
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-05-08 12:40:49 +00:00
Paul Berry
f48e7e9f8a Migration: assign better quality node targets in NodeBuilder.
This should help ensure that descriptions of nullabilities that show
up in the stack trace refer to parts of the program the user is
familiar with, rather than simply saying "explicit type".

Change-Id: If53198cc45077a664e44859c7c0770ec9831c765
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/146964
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2020-05-08 12:40:49 +00:00
Konstantin Shcheglov
7161036eb7 Fix avoid_unused_constructor_parameters in analyzer.
Bug: https://github.com/dart-lang/sdk/issues/41797
Change-Id: I6fb201b549a599b12d022abd6108d3418966c4f0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/147221
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2020-05-08 04:44:58 +00:00
Paul Berry
ce62ad2e8b Migration: test "add hint" functionality, and fix a path problem on Windows
Change-Id: I6373a20ef3e3e74c77c4a1b9108317996256b831
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/146820
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-05-07 16:24:58 +00:00
Paul Berry
8636312883 Migration: turn off removeViaComments by default.
This was the original behavior, and it persists in some tests because
it's more trouble than it's worth to rewrite them.  But it's not the
behavior we want to ship to users.

Change-Id: Ibf1df628f62b01e934d05336bfe43a5a61268f93
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/147042
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-05-07 16:21:48 +00:00
Sam Rawlins
1279bbf0f1 Migrator: Always remove @ from @required
Commenting out the @ (producing `/* @*/ required`) does no one good. It
does not help weak-mode or strong-mode testing.

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

Change-Id: I9de2775e2a17bacdd30cbfb34dc095cf2b5c603f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/147040
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-05-07 14:47:07 +00:00
Sam Rawlins
6630f39690 Migrator: Fix null-check hint after a cast
Fixes https://github.com/dart-lang/sdk/issues/41400

Change-Id: Iba8ee6c63ea4613904b7eb11b688d14b33ba29dd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/146825
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-05-06 21:43:21 +00:00
Sam Rawlins
c958fa4fb9 Migrator: Fix nullable casts which are immediately null-checked.
Fixes https://github.com/dart-lang/sdk/issues/41397

Change-Id: I7e64cbb475b6387ad10a2895e67311edac3aa7d8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/146824
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-05-06 21:33:29 +00:00
Sam Rawlins
7477ab0b93 Migrator: add two failing tests for #41788
The expectation in test_expression_bang_hint_in_as_wrapped looks weird,
but without  https://github.com/dart-lang/sdk/issues/41397 fixed, this
is the expectation I have; if the migrator starts producing that output,
then #41788 is being fixed. If #41397 is being fixed, the dev can change
the expectation in this test.

Change-Id: I0cfc0c5da8cd12ea12ae74b1909155a0b9a2b043
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/146822
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-05-06 16:32:22 +00:00
Paul Berry
097c3aab2c Migration: add a repro for issue #41409.
Bug: https://github.com/dart-lang/sdk/issues/41409
Change-Id: I1029767745414c472bbe0b6efc7ee1ea6c0ac51e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/146685
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-05-06 12:59:52 +00:00
Konstantin Shcheglov
9b3f9db65a Switch InheritanceManager3 to computing ClassElement interfaces.
Change-Id: Id9148d1bf3fc369eeabe2b1acc7507c20986a3e8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/146682
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-05-06 03:09:03 +00:00
Mike Fairhurst
ba6725d547 [nnbd_migration] Fix #41338, top code reference in details now a link
Change-Id: If93956ef4065582bee9afdff783358870e18e16c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/146701
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Auto-Submit: Mike Fairhurst <mfairhurst@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2020-05-05 21:47:13 +00:00
Paul Berry
965dd4d6d8 Migration CLI: validate that package to migrate exists and is not a file
Change-Id: I4b7c189e29c141a5bbd7738542d7dbf398e567d5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/146523
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2020-05-05 20:25:33 +00:00
Paul Berry
e5efe2be29 Migration CLI: normalize input path and make it absolute
Change-Id: Ie88dae881f62b3513df9f799ca1abd4c7e831641
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/146500
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2020-05-05 20:25:33 +00:00
Paul Berry
c644e4c001 Migration: remove unnecessary TODO comment about supporting --debug in new CLI.
In the dartfix-based implementation, the only significant effect of
supplying `--debug` was to enable the analysis server's
instrumentation log.  Since we don't have an analysis server layer in
the new CLI, there's no need for this command line option right now.

If we decide we need a `--debug` flag later we can always add it.

Change-Id: Ib729c5793044456ef460cfa7f823c48f5af9e898
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/146445
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2020-05-05 20:25:33 +00:00
Paul Berry
399805bfdc Migration: upgrade to cli_util 0.1.4, which supports Ansi.reversed.
We no longer need a clumsy workaround using an extension method.

Change-Id: If443cbe7138f59e66cce0ca613940b67307b637e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/146502
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-05-05 20:19:23 +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
Sam Rawlins
57ff9b73f9 Migrator: Support nullable function-typed parameters
Feature includes:
* function-typed formal parameters
* function-typed field formal parameters
* overridding parameters
* nullability hints
* adding `required`
* optional parameters

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

Change-Id: I1d9b1a50a9a6a77651fe6179b66c8301c8ab9408
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/146029
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-05-05 20:03:07 +00:00
Mike Fairhurst
44ad40afa5 [nnbd_migration] Add a trace entry for nodes with no known nullability.
Change-Id: Ic73563fb5c7dffd03685c87a5ba2eaf591513934
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/145660
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
2020-05-05 19:39:47 +00:00
Paul Berry
8061d2d6cc Migration: add support for a machine-readable summary of migration results.
Change-Id: Id41bc9869448dd4ed63286cab814bf7687baaaad
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/146620
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-05-05 17:35:22 +00:00
Paul Berry
c27da7da14 Migration: clarify titles for bug reporting links.
If an external customer reports an issue with the migration tool using
the links we provide, they won't have the necessary github privileges
to apply labels to the issue, so we want to make sure the default bug
title clarifies that this is a customer-reported issue with NNBD
migration.

Change-Id: I55bf8c16062b1b9e8c25415addc99dd1c378b724
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/146621
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-05-05 17:27:17 +00:00
Sam Rawlins
9c94f08410 Migrator: Fix 'Report a Problem' link
Fixes https://github.com/dart-lang/sdk/issues/41485

Change-Id: I514cc299f7a821f8cd8d623a8d9702e694178379
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/146461
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2020-05-05 04:04:03 +00:00
Paul Berry
11e5a05a70 Migration: when removing dead code, remove unnecessay ??=s
Fixes #38676.

Change-Id: Icc24c6f070d7f3e8a74fc9494aef3e4c2583fac4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/146320
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2020-05-05 02:18:13 +00:00
Paul Berry
13b3d67278 Migration: test interactions between type promotion and new compound assignment diagnostics
Change-Id: I31d0389872640a54c962976754e65c3e2aeb2f1a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/145981
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2020-05-05 02:18:13 +00:00
Paul Berry
eb3a42b789 Migration: test interactions between null-shorting and new compound assignment diagnostics
Change-Id: Ia46aaf380fad1c65b59fff214217658cfcaee973
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/146000
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2020-05-04 23:02:17 +00:00
Paul Berry
b71d09542c Migration: extend compound assignment diagnostics to ++ and --.
Bug: https://github.com/dart-lang/sdk/issues/38676
Change-Id: Iab5097359d8de7aa9411f51ee0ec6212c3adb678
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/145920
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2020-05-04 23:02:17 +00:00
Paul Berry
2846ec88b3 Migration: test that new compound assignment checks respect potential nullability
Bug: https://github.com/dart-lang/sdk/issues/38676
Change-Id: I344a9c9ea1e79af864c239dbcc924f78e798a8aa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/145900
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-05-01 22:54:25 +00:00
Paul Berry
bf56b2ca2c Migration: produce diagnostic information for assignments.
We produce a diagnostic under the following conditions:

- For compound assignments, if the type read from the LHS is nullable
  (this is illegal after NNBD, and requires user intervention to fix).

- For compound assignments, if the type returned from the combiner is
  not assignable to the LHS (this was required prior to NNBD, but it
  is a stricter condition after migration, both because the LHS might
  have a non-nullable type, and because implicit downcasts are not
  allowed).

- For null-aware assignments, if the type read from the LHS is
  non-nullable (this indicates that once strong mode is enabled, the
  assignment will be dead code).

Bug: https://github.com/dart-lang/sdk/issues/38676
Change-Id: Icb242ba36437e38364ada069880831eb05e3a513
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/145664
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2020-05-01 22:54:25 +00:00
Paul Berry
f0e428eb73 Migration: encode and decode paths properly on Windows.
Fixes #41678.

Bug: https://github.com/dart-lang/sdk/issues/41678
Change-Id: I532f65eb99a9ad7ce2542bffa0aa2d5a680d28c7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/145880
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-05-01 17:53:13 +00:00
Paul Berry
31c8b587b1 Migration: introduce NodeChange.toString() method.
This should make it easier to debug failures in FixBuilder unit tests.

Change-Id: I785e939648f10753ae9ac1e18530248c728a7157
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/145564
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-04-30 21:52:32 +00:00
Paul Berry
ff53bd8d4a Migration: make sure new CLI detects when run with an old SDK
Change-Id: I7b279788e34d3d2e86df58ff4ef7c86b58e154e3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/145644
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-04-30 21:50:12 +00:00
Paul Berry
c33f4ad9fc Migration: support changing pubspec in new CLI
Change-Id: I2e091a4ef8999f1fe649c7b9e69798e9959b635a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/145643
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2020-04-30 21:50:12 +00:00
Paul Berry
28952641d5 Sort declarations in fix_aggregator.dart
Change-Id: I19c8370fc38fbebc104dca3b6108db10660c5b9f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/145620
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-04-30 21:07:22 +00:00
Konstantin Shcheglov
cf3a034210 Implement promotion via initialization in flow analysis.
Change-Id: I10a5f6bfeb5a05dd144db5212c9f31796f5a2385
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/145502
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-04-30 16:26:27 +00:00
Paul Berry
a144fedbba Migration: add support for --ignore-errors to new CLI
Change-Id: I467c3ecfc7e8a7f52a1ba2be887ac2a677d5545c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/145543
Reviewed-by: Janice Collins <jcollins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-04-30 16:23:37 +00:00
Paul Berry
136ad8353b In migration CLI tests, verify that preview server only starts when expected
Change-Id: I81555fe4c520761ab14dc1535ad4a9918e226965
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/145540
Reviewed-by: Janice Collins <jcollins@google.com>
2020-04-30 16:23:37 +00:00
Sam Rawlins
5ab3f3506f migrator: quiver's checkNotNull implies non-null intent
Fixes https://github.com/dart-lang/sdk/issues/39315

Change-Id: I136975064c6aadf9b8548afe9b5928d4ee6775a3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/145569
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-04-30 16:15:32 +00:00
Mike Fairhurst
cde8098c97 [nnbd_migration] Improve error message quality
Change-Id: I3da17864861dc58df7cde9d1c6b034715f1c88bd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/144684
Commit-Queue: Janice Collins <jcollins@google.com>
Auto-Submit: Mike Fairhurst <mfairhurst@google.com>
Reviewed-by: Janice Collins <jcollins@google.com>
2020-04-30 00:25:48 +00:00
Sam Rawlins
5506769402 Count variables checked with ArgumentError.checkNotNull as not null
Fixes https://github.com/dart-lang/sdk/issues/39644

Change-Id: I552e87e7c57dd2c5a012b76d9c73c24fefb19785
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/145025
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-04-29 22:35:18 +00:00
Sam Rawlins
61755dea19 Migrator: Infer late for test variables
Fixes https://github.com/dart-lang/sdk/issues/38291

This change also involves moving the "package" where test sources are
written and analyzed; It used to be /home/test (or /project in some
places); and a pubspec.yaml was written (or a .packages file) which
specified the package's name was "test". However, this conflicts with
adding an entry for a mock copy of the actual _test_ package. A
.packages file cannot have two entries for a package named "test", so
the package where all test sources are written is changed to "tests"
(located at /home/tests).

Change-Id: I462b88a814931dc2d4f1e72d07e3daf64768a399
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/144994
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-04-29 22:09:28 +00:00
Paul Berry
4d1ca6316f Migration: fix mock SDK path for testing CLI on windows.
Bug: https://github.com/dart-lang/sdk/issues/41678
Change-Id: I191699a5b9f39445be1bccad5e1e44d6b568d486
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/145441
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Janice Collins <jcollins@google.com>
2020-04-29 19:11:54 +00:00
Paul Berry
c6f94c3224 Migrtaion: add a hook to allow the preview server to be shut down in unit tests.
Without this, it's possible for a unit test failure to result in a
preview server remaining open, which can prevent test execution from
terminating.

Change-Id: I8a11056da5bea003dfa46e3871a241e8f5ce8cc1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/145440
Reviewed-by: Janice Collins <jcollins@google.com>
2020-04-29 19:11:54 +00:00
Mike Fairhurst
2693b80dfd [nnbd_migration] Do basic categorization of edit types to suppress noise.
We really should switch this, if possible, to use the edit kind APIs
that the preview tool uses, so that we can categorize this without
guesswork.

However this will keep it as a rough list, and I don't know if we need
anything fancier that currently -- and it will no longer produce noise
if new changes are added.

(currently produces "and 0 other changes" when running on flutter, so
it's probably mostly comprehensive currently).

Change-Id: I9cb2662995af340346a61d38eba3469927a0f4ef
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/145160
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
2020-04-29 17:22:44 +00:00