Skip to content

Migration tool should show a more useful error when there are multiple analysis contexts #42141

@stereotype441

Description

@stereotype441

If migration is attempted on a directory containing multiple analysis contexts, the following exception occurs:

Generating migration suggestions...
Bad state: Too many elements
#0      List.single (dart:core-patch/growable_array.dart:237:5)
#1      MigrationCli.run.<anonymous closure> (package:nnbd_migration/migration_cli.dart:378:38)
#2      MigrationCli.run.<anonymous closure> (package:nnbd_migration/migration_cli.dart:372:67)
#3      MigrationCli._withProgress (package:nnbd_migration/migration_cli.dart:627:21)
#4      MigrationCli.run (package:nnbd_migration/migration_cli.dart:371:11)
#5      MigrateCommand.run (package:nnbd_migration/migration_cli.dart:205:15)
#6      CommandRunner.runCommand (package:args/command_runner.dart:197:27)
#7      DartdevRunner.runCommand (package:dartdev/dartdev.dart:62:24)
#8      CommandRunner.run.<anonymous closure> (package:args/command_runner.dart:112:25)
#9      new Future.sync (dart:async/future.dart:222:31)
#10     CommandRunner.run (package:args/command_runner.dart:112:14)
#11     main (file:///usr/local/google/home/paulberry/dart-new/sdk/pkg/dartdev/bin/dartdev.dart:14:35)
#12     _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:299:32)
#13     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)

In an ideal world the migration tool would be able to handle multiple analysis contexts, however at a minimum we should output a helpful error message to the user rather than crashing.

(See #42140 for one way of reproducing this error)

Metadata

Metadata

Assignees

Labels

NNBDIssues related to NNBD Releasearea-migration (deprecated)Deprecated: this label is no longer actively used (was: issues with the `dart migrate` tool).

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions