Commit Graph

20 Commits

Author SHA1 Message Date
Konstantin Shcheglov 26d9fbbd04 Add getResolvedUnit2(), deprecate getResolvedUnit().
Change-Id: I0217fefb2747f2f9bd757bc041b53acaf3d1a8f1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195495
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-04-16 21:33:54 +00:00
Sam Rawlins f6dba2b25f dart migrate: Separate HintAction and HintActionKind into separate file
This addresses a cyclic dependency build issue in google3.

Change-Id: I3ea917f7216e120b827577bde60b874a9bad52af
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/180240
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2021-01-20 21:54:53 +00:00
Sam Rawlins 416cfa7c41 Migrator: Add /*required*/ hints when meta not imported.
Currently the migrator can add `@required` from the preview, which will crash
the preview upon rerunning, if package:meta is not imported.

This change instead adds a /*required*/ hint when meta is not imported.

Additionally, /*required*/ is understood by the migrator just as if it were
`@required`.

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

Change-Id: I1ea532246b956feacedd179146372b13c65003df
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/169900
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-11-02 17:30:59 +00:00
Paul Berry e20415403a Fix InfoBuilder._explainUnit to handle iterable method call renames.
The method we use to rename method calls to Iterable
(e.g. `firstWhere` -> `firstWhereOrNull`) causes a pair of consecutive
AtomicEdit objects to be generated: one to remove the old name
followed by one to add the new name.  This was causing
InfoBuilder._explainUnit to update its output offsets incorrectly,
because it waited until after processing all of the AtomicEdit objects
pointing to a single source offset before updating the output offset.
What it needs to do instead is update the output offset (in the
variable called `offset`) after processing every single AtomicEdit.

Change-Id: I8ad51e20d4021c62c45542cec7f0f54a9ff3cf26
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/169000
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-10-25 16:23:45 +00:00
Paul Berry d751681647 Sort declarations in info_builder_test.dart
Change-Id: I00caa1860f93f2fb8cfcdf9fa571f9cd0cc880b3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168980
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-10-23 20:01:22 +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
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 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
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
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
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 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
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 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 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 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
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 eab774c255 Move much of migration tool UI code into pkg/nnbd_migration
Change-Id: Ia3b388b274c908dcc6f9cb9ee4bf004b82681c43
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/144320
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2020-04-23 23:43:42 +00:00