Commit Graph

936 Commits

Author SHA1 Message Date
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 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
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
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 8d79c1f470 Migration: allow assignment to de-promote local variables.
Fixes #41411.

Bug: https://github.com/dart-lang/sdk/issues/41411
Change-Id: Ia88216e3327f42ee1d93143afb2a66839cf05a2b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/144161
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-04-28 13:54:28 +00:00
Konstantin Shcheglov eada4d8d65 Implement Factor in flow analysis.
Bug: https://github.com/dart-lang/sdk/issues/40014
Change-Id: I8d21d3c3368495d9d0dbb1cd52317b053657a176
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/144804
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-04-27 18:47:08 +00:00
Paul Berry c80ff5f5f7 Migration: nicer text for command-line option errors
Previously we just printed the result of calling Exception.toString(),
so the exception class name appeared in the output.

Change-Id: I789d4e5524cd8614d688252644b80898fd2cda17
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/144882
Reviewed-by: Janice Collins <jcollins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-04-27 16:33:23 +00:00
Paul Berry cbdfc7f7ba Migration: add --apply-changes support to new CLI
Change-Id: I803747d09501be4cfa982ae6b3449e84d5752e3c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/144881
Reviewed-by: Janice Collins <jcollins@google.com>
2020-04-27 16:33:23 +00:00
Paul Berry b2773e38da Migration: add --no-web-preview support to new CLI
Change-Id: I2fe106ab2a48cdba610990b747ae3b9e1ef1d086
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/144861
Reviewed-by: Janice Collins <jcollins@google.com>
2020-04-27 16:33:23 +00:00
Paul Berry 8d188a1a9f Migration: begin implementing CLI for the migration tool outside analysis server.
This will allow us to publish the migration tool on pub, so that we
can ship improvements to it that aren't coupled to SDK releases.

As of this CL, basic read-only functionality of the preview site is
working.  However, the ability to apply migrations and add hints to
existing code has not yet been tested.

Change-Id: Ib1588e741efa7be7861fa75b962fd1565765e794
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/144808
Reviewed-by: Janice Collins <jcollins@google.com>
2020-04-27 16:33:23 +00:00
Mike Fairhurst 8236400594 [nnbd_migration] Change edit links to no longer be generic "post links"
Originally, edit links were implemented as generic "post links," that
had no special handling except to fire a post request.

At this point, this is no longer the case. We at least want to
specialize the error message, and we have TODOs to do more
specialization (targeted reloading of the UI).

Note that 'edit-link' is already a class, it refers to the edits the
migration tool suggests as the migration. Therefore I used the class
'add-hint-link' instead of 'edit-link.'

Lastly, post-links were styled like buttons. But they are not the only
links that should be styled as buttons now, so just use that class
instead of having special styling.

Change-Id: I8241a5ec24e6a290b94a75327c06257abdfc011b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/144660
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
2020-04-24 20:14:57 +00:00
Paul Berry 71ade62d09 Fix invalid downcast in pkg/nnbd_migration
Change-Id: Ie2a61f08a57ed741939c63a9ac7e07cf7f19c74f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/144780
Commit-Queue: Paul Berry <paulberry@google.com>
Auto-Submit: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-04-24 17:32:43 +00:00
Paul Berry 319843b6ff Migration: Further decouple NonNullableFix from DartFixListener.
NonNullableFix now communicates with DartFixListener through the
abstract interface DartFixListenerInterface; this will allow us to
build a version of DartFixListenerInterface that doesn't require the
analysis server.

Change-Id: I106d769b0e6ed49a916e2f1665a7e31a9a63be86
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/144471
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Janice Collins <jcollins@google.com>
2020-04-24 10:06:53 +00:00
Paul Berry 4787fc190b Decouple migration logic from AnalysisDriver.
The migration logic doesn't need to access the AnalysisDriver object;
it just needs access to the AnalysisSession (which the driver holds).
By changing the interface so that it requests the session directly, we
pave the way for making a version of the migration tool that doesn't
require the analysis server.

Change-Id: Ib99725bbb2c1728a4c57b46659e9d94cbfe65ee0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/144470
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Janice Collins <jcollins@google.com>
2020-04-24 10:06:53 +00:00
Paul Berry b0173c1d3e Begin to decouple nnbd_migration tool from analysis_server.
This removes most of the imports from nnbd_migration to
analysis_server by replacing them with abstract interfaces that are in
turn implemented by classes in analysis_server.

Change-Id: I9be9a5bd69b1664f0fea9ff3b6ba4678f134f0e9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/144468
Reviewed-by: Janice Collins <jcollins@google.com>
2020-04-24 10:06:53 +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
Sam Rawlins 29bc716241 Migrator: Add a late inference component
Fixes #38747

Change-Id: I045a6481424c75828eb7ae1e71c890b10e9d402c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/144244
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-04-21 23:54:54 +00:00
Paul Berry dd883c749d Remove inadvertent imports from nnbd_migration to analysis_server
Change-Id: I001d00d5f1a8d4c503523f9ec4b09b38a908d8ae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/144301
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-04-21 21:55:19 +00:00
Paul Berry 52b04b3d28 Migration: code inside a switch statement should not imply non-null intent.
Fixes #41407.

Change-Id: Iec9a520bbbab6f55da569ecc863d92674c351207
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/144160
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2020-04-20 19:09:32 +00:00
Paul Berry 4c8da7543e Migration: handle field formal parameters properly in FixBuilder.
Previously, all parameters returned by
MigrationResolutionHooksImpl.getExecutableParameters were synthetic
ones that came from translating the executable element's decorated
function type to its final post-migration type.  Synthetic parameters
can't be field formal parameters, so this meant that when the
FixBuilder was re-resolving a constructor containing field formal
parameters, references to the field in the constructor body would get
incorrectly interpreted as pointing to the parameter rather than the
field, and that would cause them to be subject to promotion.

The fix is to only return synthetic parameters from
MigrationResolutionHooksImpl.getExecutableParameters when the
executable in question is in a library *not* being migrated.  When
it's in a library that *is* being migrated, we can just return all of
the executable's parameters without translating them, because we know
that the parameters themselves have been visited by the NodeBuilder
and EdgeBuilder, hence they all have thier own associated decorated
types.

Fixes #41405.

Change-Id: I5e3c411dc92fe242a959a5670b9253fbccea2b31
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/144122
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2020-04-20 19:09:32 +00:00
Paul Berry b471ac55a0 Migration: apply guards to conditional branch expression values.
Consider the following code:

  int f(int i) => i == null ? null : i + 1;

Previously, migration would mark the return type of `f` as nullable
even if `i` was non-nullable.  This happened because the edge
connecting the explicit `null` (in the "then branch" of the
conditional) to the return type of `f` is created after visiting the
conditional expression, so the condition guards are no longer in
scope.

With this CL, we create an extra graph node when needed to ensure that
the guard is applied to the expression type.

Change-Id: Ie00eea0b431905241612c6661d69bdb55c0910d2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/144121
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2020-04-20 19:09:32 +00:00
Paul Berry 925e3fe782 Migration: detect weak-only code in conditional expressions.
This change adds the ability to detect when one branch of a
conditional expression is weak-only due to nullability.  For example,
in the following code:

  int f(int/*!*/ i) => i == null ? g(null) : i;
  int g(int j) => ...;

the call to `g` can only happen in weak checking mode.  The migrator
also now understands that j only needs to be nullable if i is
nullable.

Fixes #41555.
Partially addresses #41551.

Bug: https://github.com/dart-lang/sdk/issues/41555
Change-Id: I02c9c3072f0104db0f1a5b432fb1f2f8f06d5282
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/144120
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2020-04-20 19:09:32 +00:00
Sam Rawlins a4c49f8fce migration_tool: Dummy edges
Helps with https://github.com/dart-lang/sdk/issues/40509 and
https://github.com/dart-lang/sdk/issues/38747

Change-Id: Iac7208ee38dcc6c0b055f9e46c2d755ad0388488
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/143962
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-04-20 18:14:32 +00:00
Paul Berry 5eb399388e Migration: when not removing weak-only code, visit all subexpressions.
In the FixBuilder, when we are discarding one of the branches of an
if-statement or if-element due to it being weak-only, we only visit
the branch we're keeping; this avoids trying to make changes to code
that's being removed.  However, if we are keeping both branches and
simply warning about one of them being weak-only, then we need to
visit both branches so that fixes are applied to both of them.

Change-Id: I26a1bfcb5f2ef4a111b1117637bce74e42d3db07
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/144000
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2020-04-20 17:26:26 +00:00
Paul Berry a2c9dc18d5 Migration: fix EditPlanner.addCommentPostfix when isInformative = true.
Previously, the spaces inserted by EditPlanner.addCommentPostfix
didn't carry the correct isInformative flag, so they would show up in
final migrated output.

Change-Id: I100ba88040ebff9ae5d406c49b242f6fb17ce7b8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/143887
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-04-20 12:43:46 +00:00
Mike Fairhurst 3de4d76b4a [nnbd_migration] Use offsets instead of column numbers in traces
Change-Id: I37f44c1a4713106e15b346739354b73592d208d5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/143721
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
2020-04-17 19:07:44 +00:00
Paul Berry d52dc104d4 Migration: instead of removing weak-only code, warn about it.
Previously we considered such code "dead", but it's not really dead
until Dart 3.0.  Removing it changes weak mode semantics, and we don't
want to do that automatically.

Fixes #41231

Change-Id: I6a88f016b4f3fcba160dcb738558867219715cbb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/143941
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-04-17 17:27:59 +00:00
Paul Berry e221b998b7 Add test cases and TODO reference for #41551
Change-Id: I98cb02eca2143df8ed1c836919ee93bd43f366b6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/143885
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2020-04-17 17:27:59 +00:00
Paul Berry 4747672929 Migration: fix preview output when accepting a /*late*/ hint.
Change-Id: I383be37cc86d3c83f5b2b332ae14ce35516f858d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/143563
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2020-04-17 00:17:15 +00:00
Paul Berry a72e0e3412 Migration: don't double count edits when accepting hints
Technically, accepting a hint requires two edits, one to remove the
`/*` and one to remove the `*/`.  But we only want it to show up as
one edit in the "Proposed Edits" pane.

Fixes #38471

Change-Id: Ica7880a2ffab98715a1c9f3bbe723363fd481086
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/143484
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2020-04-17 00:17:15 +00:00
Paul Berry fdc13e3f43 Migration: remove hints when performing migration.
Previously, if we migrated a code snippet like this:

  void f(int/*?*/ i) {
    /*late*/ int j = i/*!*/;
  }

the migration result would leave the hints and add the hinted text,
resulting in:

  void f(int?/*?*/ i) {
    /*late*/ late int j = i!/*!*/;
  }

We now simply remove the `/*` and `*/` surrounding each hint (with
whitespace corrections as needed), to produce:

  void f(int? i) {
    late int j = i!;
  }

Change-Id: Ic4e1216cb4693d73d71c9ab1a37d5cc15b8ef334
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/143460
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2020-04-17 00:17:15 +00:00
Paul Berry 07ef4dee72 Migration: add offset/end getters to NodeProducingEditPlan.
Currently these are just equal to sourceNode.offset and sourceNode.end
respectively.  In a follow-up CL, I'll introduce situations in they
might differ (in particular, the edit might include changes to a
nullability comment that precedes or follows the sourceNode).

Change-Id: I1c728454bafe9b154662dbb4c21d28fc62415abf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/143340
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2020-04-14 23:33:46 +00:00
Paul Berry 1d3105e0b3 Migration: prioritize changes differently if they're due to hints.
Change-Id: I4dfdd0287e488dfac21923c71741d2218a2c070c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/143334
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2020-04-14 23:33:46 +00:00
Paul Berry 46b49d23ec Migration: track multiple fix reasons for expressions with complex types.
Change-Id: I1a1f78377ed64504e5315b5096914219dc625e78
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/143188
Reviewed-by: Janice Collins <jcollins@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2020-04-14 23:33:46 +00:00