Migration: Remove transitional API

Change-Id: I9853b7577ba4b39bf1d51f7d03ba3c2d6499e79b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/105412
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
diff --git a/pkg/nnbd_migration/lib/nnbd_migration.dart b/pkg/nnbd_migration/lib/nnbd_migration.dart
index 6508060..eebd31a 100644
--- a/pkg/nnbd_migration/lib/nnbd_migration.dart
+++ b/pkg/nnbd_migration/lib/nnbd_migration.dart
@@ -8,8 +8,11 @@
 import 'package:meta/meta.dart';
 import 'package:nnbd_migration/src/decorated_type.dart' as analyzer;
 import 'package:nnbd_migration/src/expression_checks.dart' as analyzer;
+import 'package:nnbd_migration/src/graph_builder.dart';
+import 'package:nnbd_migration/src/node_builder.dart';
+import 'package:nnbd_migration/src/nullability_node.dart';
 import 'package:nnbd_migration/src/potential_modification.dart' as analyzer;
-import 'package:nnbd_migration/src/transitional_api.dart' as analyzer;
+import 'package:nnbd_migration/src/variables.dart';
 
 /// Kinds of fixes that might be performed by nullability migration.
 class NullabilityFixKind {
@@ -55,13 +58,15 @@
 /// Usage: pass each input source file to [prepareInput].  Then pass each input
 /// source file to [processInput].  Then call [finish] to obtain the
 /// modifications that need to be made to each source file.
-///
-/// TODO(paulberry): figure out whether this API is what we want, and figure out
-/// what file/folder it belongs in.
 class NullabilityMigration {
-  final analyzer.NullabilityMigration _analyzerMigration;
   final NullabilityMigrationListener listener;
 
+  final _variables = Variables();
+
+  final _graph = NullabilityGraph();
+
+  final bool _permissive;
+
   /// Prepares to perform nullability migration.
   ///
   /// If [permissive] is `true`, exception handling logic will try to proceed
@@ -69,11 +74,11 @@
   /// complete.  TODO(paulberry): remove this mode once the migration algorithm
   /// is fully implemented.
   NullabilityMigration(this.listener, {bool permissive: false})
-      : _analyzerMigration =
-            analyzer.NullabilityMigration(permissive ? listener : null);
+      : _permissive = permissive;
 
   void finish() {
-    for (var entry in _analyzerMigration.finish().entries) {
+    _graph.propagate();
+    for (var entry in _variables.getPotentialModifications().entries) {
       var source = entry.key;
       for (var potentialModification in entry.value) {
         var fix = _SingleNullabilityFix(source, potentialModification);
@@ -86,11 +91,15 @@
   }
 
   void prepareInput(ResolvedUnitResult result) {
-    _analyzerMigration.prepareInput(result.unit, result.typeProvider);
+    var unit = result.unit;
+    unit.accept(NodeBuilder(_variables, unit.declaredElement.source,
+        _permissive ? listener : null, _graph, result.typeProvider));
   }
 
   void processInput(ResolvedUnitResult result) {
-    _analyzerMigration.processInput(result.unit, result.typeProvider);
+    var unit = result.unit;
+    unit.accept(GraphBuilder(result.typeProvider, _variables, _graph,
+        unit.declaredElement.source, _permissive ? listener : null));
   }
 }
 
diff --git a/pkg/nnbd_migration/lib/src/transitional_api.dart b/pkg/nnbd_migration/lib/src/transitional_api.dart
deleted file mode 100644
index 0647d28..0000000
--- a/pkg/nnbd_migration/lib/src/transitional_api.dart
+++ /dev/null
@@ -1,55 +0,0 @@
-// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-import 'package:analyzer/dart/ast/ast.dart';
-import 'package:analyzer/src/generated/resolver.dart';
-import 'package:analyzer/src/generated/source.dart';
-import 'package:nnbd_migration/nnbd_migration.dart';
-import 'package:nnbd_migration/src/graph_builder.dart';
-import 'package:nnbd_migration/src/node_builder.dart';
-import 'package:nnbd_migration/src/nullability_node.dart';
-import 'package:nnbd_migration/src/potential_modification.dart';
-import 'package:nnbd_migration/src/variables.dart';
-
-/// Transitional migration API.
-///
-/// Usage: pass each input source file to [prepareInput].  Then pass each input
-/// source file to [processInput].  Then call [finish] to obtain the
-/// modifications that need to be made to each source file.
-///
-/// TODO(paulberry): this implementation keeps a lot of CompilationUnit objects
-/// around.  Can we do better?
-class NullabilityMigration {
-  final NullabilityMigrationListener /*?*/ listener;
-
-  final Variables _variables;
-
-  final NullabilityGraph _graph;
-
-  /// Prepares to perform nullability migration.
-  ///
-  /// If [permissive] is `true`, exception handling logic will try to proceed
-  /// as far as possible even though the migration algorithm is not yet
-  /// complete.  TODO(paulberry): remove this mode once the migration algorithm
-  /// is fully implemented.
-  NullabilityMigration(NullabilityMigrationListener /*?*/ listener)
-      : this._(listener, NullabilityGraph());
-
-  NullabilityMigration._(this.listener, this._graph) : _variables = Variables();
-
-  Map<Source, List<PotentialModification>> finish() {
-    _graph.propagate();
-    return _variables.getPotentialModifications();
-  }
-
-  void prepareInput(CompilationUnit unit, TypeProvider typeProvider) {
-    unit.accept(NodeBuilder(_variables, unit.declaredElement.source, listener,
-        _graph, typeProvider));
-  }
-
-  void processInput(CompilationUnit unit, TypeProvider typeProvider) {
-    unit.accept(GraphBuilder(typeProvider, _variables, _graph,
-        unit.declaredElement.source, listener));
-  }
-}