Rename migration visitors to reflect terminology in the design doc

Change-Id: I9e554356032700bbbac93df4e754fa1fc1c67041
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/104484
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
diff --git a/pkg/analysis_server/lib/src/nullability/decorated_type_operations.dart b/pkg/analysis_server/lib/src/nullability/decorated_type_operations.dart
index 59164ce..0788209 100644
--- a/pkg/analysis_server/lib/src/nullability/decorated_type_operations.dart
+++ b/pkg/analysis_server/lib/src/nullability/decorated_type_operations.dart
@@ -2,8 +2,8 @@
 // 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:analysis_server/src/nullability/constraint_variable_gatherer.dart';
 import 'package:analysis_server/src/nullability/decorated_type.dart';
+import 'package:analysis_server/src/nullability/node_builder.dart';
 import 'package:analyzer/dart/element/element.dart';
 import 'package:analyzer/dart/element/type_system.dart';
 import 'package:analyzer/src/dart/resolver/flow_analysis.dart';
diff --git a/pkg/analysis_server/lib/src/nullability/constraint_gatherer.dart b/pkg/analysis_server/lib/src/nullability/graph_builder.dart
similarity index 98%
rename from pkg/analysis_server/lib/src/nullability/constraint_gatherer.dart
rename to pkg/analysis_server/lib/src/nullability/graph_builder.dart
index f4bd6dd..4e48af8 100644
--- a/pkg/analysis_server/lib/src/nullability/constraint_gatherer.dart
+++ b/pkg/analysis_server/lib/src/nullability/graph_builder.dart
@@ -3,9 +3,9 @@
 // BSD-style license that can be found in the LICENSE file.
 
 import 'package:analysis_server/src/nullability/conditional_discard.dart';
-import 'package:analysis_server/src/nullability/constraint_variable_gatherer.dart';
 import 'package:analysis_server/src/nullability/decorated_type.dart';
 import 'package:analysis_server/src/nullability/expression_checks.dart';
+import 'package:analysis_server/src/nullability/node_builder.dart';
 import 'package:analysis_server/src/nullability/nullability_node.dart';
 import 'package:analyzer/dart/ast/ast.dart';
 import 'package:analyzer/dart/ast/token.dart';
@@ -17,14 +17,14 @@
 import 'package:analyzer/src/generated/source.dart';
 import 'package:meta/meta.dart';
 
-/// Visitor that gathers nullability migration constraints from code to be
+/// Visitor that builds nullability graph edges by examining code to be
 /// migrated.
 ///
 /// The return type of each `visit...` method is a [DecoratedType] indicating
 /// the static type of the visited expression, along with the constraint
 /// variables that will determine its nullability.  For `visit...` methods that
 /// don't visit expressions, `null` will be returned.
-class ConstraintGatherer extends GeneralizingAstVisitor<DecoratedType> {
+class GraphBuilder extends GeneralizingAstVisitor<DecoratedType> {
   /// The repository of constraint variables and decorated types (from a
   /// previous pass over the source code).
   final VariableRepository _variables;
@@ -73,7 +73,7 @@
   /// or expression.
   bool _inConditionalControlFlow = false;
 
-  ConstraintGatherer(TypeProvider typeProvider, this._variables, this._graph,
+  GraphBuilder(TypeProvider typeProvider, this._variables, this._graph,
       this._source, this._permissive)
       : _notNullType =
             DecoratedType(typeProvider.objectType, NullabilityNode.never),
diff --git a/pkg/analysis_server/lib/src/nullability/constraint_variable_gatherer.dart b/pkg/analysis_server/lib/src/nullability/node_builder.dart
similarity index 94%
rename from pkg/analysis_server/lib/src/nullability/constraint_variable_gatherer.dart
rename to pkg/analysis_server/lib/src/nullability/node_builder.dart
index 5d86653..39ad145 100644
--- a/pkg/analysis_server/lib/src/nullability/constraint_variable_gatherer.dart
+++ b/pkg/analysis_server/lib/src/nullability/node_builder.dart
@@ -14,14 +14,13 @@
 import 'package:analyzer/src/generated/resolver.dart';
 import 'package:analyzer/src/generated/source.dart';
 
-/// Visitor that gathers constraint variables for nullability migration from
-/// code to be migrated.
+/// Visitor that builds nullability nodes based on visiting code to be migrated.
 ///
 /// The return type of each `visit...` method is a [DecoratedType] indicating
 /// the static type of the element declared by the visited node, along with the
 /// constraint variables that will determine its nullability.  For `visit...`
 /// methods that don't visit declarations, `null` will be returned.
-class ConstraintVariableGatherer extends GeneralizingAstVisitor<DecoratedType> {
+class NodeBuilder extends GeneralizingAstVisitor<DecoratedType> {
   /// Constraint variables and decorated types are stored here.
   final VariableRecorder _variables;
 
@@ -42,8 +41,8 @@
 
   final TypeProvider _typeProvider;
 
-  ConstraintVariableGatherer(this._variables, this._source, this._permissive,
-      this._graph, this._typeProvider);
+  NodeBuilder(this._variables, this._source, this._permissive, this._graph,
+      this._typeProvider);
 
   /// Creates and stores a [DecoratedType] object corresponding to the given
   /// [type] AST, and returns it.
@@ -195,7 +194,7 @@
 /// code being migrated.
 ///
 /// This data structure records the results of the first pass of migration
-/// ([ConstraintVariableGatherer], which finds all the variables that need to be
+/// ([NodeBuilder], which finds all the variables that need to be
 /// constrained).
 abstract class VariableRecorder {
   /// Associates decorated type information with the given [element].
@@ -217,7 +216,7 @@
 ///
 /// This data structure allows the second pass of migration
 /// ([ConstraintGatherer], which builds all the constraints) to access the
-/// results of the first ([ConstraintVariableGatherer], which finds all the
+/// results of the first ([NodeBuilder], which finds all the
 /// variables that need to be constrained).
 abstract class VariableRepository {
   /// Retrieves the [DecoratedType] associated with the static type of the given
diff --git a/pkg/analysis_server/lib/src/nullability/transitional_api.dart b/pkg/analysis_server/lib/src/nullability/transitional_api.dart
index b7cd542..69b4d89 100644
--- a/pkg/analysis_server/lib/src/nullability/transitional_api.dart
+++ b/pkg/analysis_server/lib/src/nullability/transitional_api.dart
@@ -3,10 +3,10 @@
 // BSD-style license that can be found in the LICENSE file.
 
 import 'package:analysis_server/src/nullability/conditional_discard.dart';
-import 'package:analysis_server/src/nullability/constraint_gatherer.dart';
-import 'package:analysis_server/src/nullability/constraint_variable_gatherer.dart';
 import 'package:analysis_server/src/nullability/decorated_type.dart';
 import 'package:analysis_server/src/nullability/expression_checks.dart';
+import 'package:analysis_server/src/nullability/graph_builder.dart';
+import 'package:analysis_server/src/nullability/node_builder.dart';
 import 'package:analysis_server/src/nullability/nullability_node.dart';
 import 'package:analyzer/dart/ast/ast.dart';
 import 'package:analyzer/dart/element/element.dart';
@@ -122,12 +122,12 @@
   }
 
   void prepareInput(CompilationUnit unit, TypeProvider typeProvider) {
-    unit.accept(ConstraintVariableGatherer(_variables,
-        unit.declaredElement.source, _permissive, _graph, typeProvider));
+    unit.accept(NodeBuilder(_variables, unit.declaredElement.source,
+        _permissive, _graph, typeProvider));
   }
 
   void processInput(CompilationUnit unit, TypeProvider typeProvider) {
-    unit.accept(ConstraintGatherer(typeProvider, _variables, _graph,
+    unit.accept(GraphBuilder(typeProvider, _variables, _graph,
         unit.declaredElement.source, _permissive));
   }
 }
diff --git a/pkg/analysis_server/test/src/nullability/migration_visitor_test.dart b/pkg/analysis_server/test/src/nullability/migration_visitor_test.dart
index e4914fa..d40cb56 100644
--- a/pkg/analysis_server/test/src/nullability/migration_visitor_test.dart
+++ b/pkg/analysis_server/test/src/nullability/migration_visitor_test.dart
@@ -3,10 +3,10 @@
 // BSD-style license that can be found in the LICENSE file.
 
 import 'package:analysis_server/src/nullability/conditional_discard.dart';
-import 'package:analysis_server/src/nullability/constraint_gatherer.dart';
-import 'package:analysis_server/src/nullability/constraint_variable_gatherer.dart';
 import 'package:analysis_server/src/nullability/decorated_type.dart';
 import 'package:analysis_server/src/nullability/expression_checks.dart';
+import 'package:analysis_server/src/nullability/graph_builder.dart';
+import 'package:analysis_server/src/nullability/node_builder.dart';
 import 'package:analysis_server/src/nullability/nullability_node.dart';
 import 'package:analysis_server/src/nullability/transitional_api.dart';
 import 'package:analyzer/dart/ast/ast.dart';
@@ -21,13 +21,23 @@
 
 main() {
   defineReflectiveSuite(() {
-    defineReflectiveTests(ConstraintGathererTest);
-    defineReflectiveTests(ConstraintVariableGathererTest);
+    defineReflectiveTests(GraphBuilderTest);
+    defineReflectiveTests(NodeBuilderTest);
   });
 }
 
 @reflectiveTest
-class ConstraintGathererTest extends ConstraintsTestBase {
+class GraphBuilderTest extends MigrationVisitorTestBase {
+  /// Analyzes the given source code, producing constraint variables and
+  /// constraints for it.
+  @override
+  Future<CompilationUnit> analyze(String code) async {
+    var unit = await super.analyze(code);
+    unit.accept(
+        GraphBuilder(typeProvider, _variables, graph, testSource, false));
+    return unit;
+  }
+
   void assertConditional(
       NullabilityNode node, NullabilityNode left, NullabilityNode right) {
     var conditionalNode = node as NullabilityNodeForLUB;
@@ -727,20 +737,79 @@
   }
 }
 
-abstract class ConstraintsTestBase extends MigrationVisitorTestBase {
-  /// Analyzes the given source code, producing constraint variables and
-  /// constraints for it.
-  @override
+class MigrationVisitorTestBase extends AbstractSingleUnitTest {
+  final _Variables _variables;
+
+  FindNode findNode;
+
+  final NullabilityGraph graph;
+
+  MigrationVisitorTestBase() : this._(NullabilityGraph());
+
+  MigrationVisitorTestBase._(this.graph) : _variables = _Variables(graph);
+
+  NullabilityNode get always => NullabilityNode.always;
+
+  NullabilityNode get never => NullabilityNode.never;
+
+  TypeProvider get typeProvider => testAnalysisResult.typeProvider;
+
   Future<CompilationUnit> analyze(String code) async {
-    var unit = await super.analyze(code);
-    unit.accept(
-        ConstraintGatherer(typeProvider, _variables, graph, testSource, false));
-    return unit;
+    await resolveTestUnit(code);
+    testUnit.accept(
+        NodeBuilder(_variables, testSource, false, graph, typeProvider));
+    findNode = FindNode(code, testUnit);
+    return testUnit;
+  }
+
+  void assertEdge(NullabilityNode source, NullabilityNode destination,
+      {@required bool hard}) {
+    var edges = getEdges(source, destination);
+    if (edges.length == 0) {
+      fail('Expected edge $source -> $destination, found none');
+    } else if (edges.length != 1) {
+      fail('Found multiple edges $source -> $destination');
+    } else {
+      var edge = edges[0];
+      expect(edge.hard, hard);
+    }
+  }
+
+  void assertNoEdge(NullabilityNode source, NullabilityNode destination) {
+    var edges = getEdges(source, destination);
+    if (edges.isNotEmpty) {
+      fail('Expected no edge $source -> $destination, found ${edges.length}');
+    }
+  }
+
+  /// Gets the [DecoratedType] associated with the type annotation whose text
+  /// is [text].
+  DecoratedType decoratedTypeAnnotation(String text) {
+    return _variables.decoratedTypeAnnotation(
+        testSource, findNode.typeAnnotation(text));
+  }
+
+  List<NullabilityEdge> getEdges(
+          NullabilityNode source, NullabilityNode destination) =>
+      graph
+          .getUpstreamEdges(destination)
+          .where((e) => e.primarySource == source)
+          .toList();
+
+  NullabilityNode possiblyOptionalParameter(String text) {
+    return _variables
+        .possiblyOptionalParameter(findNode.defaultParameter(text));
+  }
+
+  /// Gets the [ConditionalDiscard] information associated with the statement
+  /// whose text is [text].
+  ConditionalDiscard statementDiscard(String text) {
+    return _variables.conditionalDiscard(findNode.statement(text));
   }
 }
 
 @reflectiveTest
-class ConstraintVariableGathererTest extends MigrationVisitorTestBase {
+class NodeBuilderTest extends MigrationVisitorTestBase {
   /// Gets the [DecoratedType] associated with the function declaration whose
   /// name matches [search].
   DecoratedType decoratedFunctionType(String search) =>
@@ -881,77 +950,6 @@
   }
 }
 
-class MigrationVisitorTestBase extends AbstractSingleUnitTest {
-  final _Variables _variables;
-
-  FindNode findNode;
-
-  final NullabilityGraph graph;
-
-  MigrationVisitorTestBase() : this._(NullabilityGraph());
-
-  MigrationVisitorTestBase._(this.graph) : _variables = _Variables(graph);
-
-  NullabilityNode get always => NullabilityNode.always;
-
-  NullabilityNode get never => NullabilityNode.never;
-
-  TypeProvider get typeProvider => testAnalysisResult.typeProvider;
-
-  Future<CompilationUnit> analyze(String code) async {
-    await resolveTestUnit(code);
-    testUnit.accept(ConstraintVariableGatherer(
-        _variables, testSource, false, graph, typeProvider));
-    findNode = FindNode(code, testUnit);
-    return testUnit;
-  }
-
-  void assertEdge(NullabilityNode source, NullabilityNode destination,
-      {@required bool hard}) {
-    var edges = getEdges(source, destination);
-    if (edges.length == 0) {
-      fail('Expected edge $source -> $destination, found none');
-    } else if (edges.length != 1) {
-      fail('Found multiple edges $source -> $destination');
-    } else {
-      var edge = edges[0];
-      expect(edge.hard, hard);
-    }
-  }
-
-  void assertNoEdge(NullabilityNode source, NullabilityNode destination) {
-    var edges = getEdges(source, destination);
-    if (edges.isNotEmpty) {
-      fail('Expected no edge $source -> $destination, found ${edges.length}');
-    }
-  }
-
-  /// Gets the [DecoratedType] associated with the type annotation whose text
-  /// is [text].
-  DecoratedType decoratedTypeAnnotation(String text) {
-    return _variables.decoratedTypeAnnotation(
-        testSource, findNode.typeAnnotation(text));
-  }
-
-  List<NullabilityEdge> getEdges(
-          NullabilityNode source, NullabilityNode destination) =>
-      graph
-          .getUpstreamEdges(destination)
-          .where((e) => e.primarySource == source)
-          .toList();
-
-  NullabilityNode possiblyOptionalParameter(String text) {
-    return _variables
-        .possiblyOptionalParameter(findNode.defaultParameter(text));
-  }
-
-  /// Gets the [ConditionalDiscard] information associated with the statement
-  /// whose text is [text].
-  ConditionalDiscard statementDiscard(String text) {
-    return _variables.conditionalDiscard(findNode.statement(text));
-  }
-}
-
 /// Mock representation of constraint variables.
 class _Variables extends Variables {
   final _conditionalDiscard = <AstNode, ConditionalDiscard>{};