anchor.diff:  // BSD-style license that can be found in the LICENSE file.
   
   import 'dart:async';
  +import 'dart:math';
   
  +import 'package:analysis_server/src/protocol_server.dart';
  +import 'package:analysis_server/src/services/completion/completion_core.dart';
  +import 'package:analysis_server/src/services/completion/completion_performance.dart';
  +import 'package:analysis_server/src/services/completion/dart/completion_manager.dart';
   import 'package:analyzer/dart/analysis/analysis_context_collection.dart';
   import 'package:analyzer/dart/ast/ast.dart';
   import 'package:analyzer/dart/ast/syntactic_entity.dart';
  
positive.code:       }
      }
    }
    print("done");
  }
  
  class CompletionMetricVisitor extends RecursiveAstVisitor {
    List<int> offsets;
  
    CompletionMetricVisitor() {
      offsets = <int>[];
    }
  
    safelyRecordOffset(SyntacticEntity entity) {
      if (entity != null && entity.offset > 0 && entity.length > 0) {
        // print("${entity.toString()} ${entity.offset}");
        offsets.add(entity.offset);
      }
    }
  
    @override
    visitDoStatement(DoStatement node) {
      safelyRecordOffset(node.doKeyword);
      return super.visitDoStatement(node);
    }
  
    @override
    visitIfStatement(IfStatement node) {
      safelyRecordOffset(node.ifKeyword);
      return super.visitIfStatement(node);
    }
  
    @override
    visitSimpleIdentifier(SimpleIdentifier node) {
      safelyRecordOffset(node);
      return super.visitSimpleIdentifier(node);
    }
  }
  
negative.code: import 'package:analyzer/file_system/physical_file_system.dart';
  import 'package:analyzer/src/generated/engine.dart';
  
  int includedCount = 0;
  int notIncludedCount = 0;
  
  /// Sort by relevance first, highest to lowest, and then by the completion, alphabetically
  Comparator<CompletionSuggestion> _completionComparator = (sug1, sug2) {
    if (sug1.relevance == sug2.relevance) {
      return sug1.completion.compareTo(sug2.completion);
    }
    return sug2.relevance.compareTo(sug1.relevance);
  };
  
  main() {
    List<String> analysisRoots = [""];
    _computeCompletionMetrics(PhysicalResourceProvider.INSTANCE, analysisRoots);
  }
  
  /// TODO(jwren) put the following methods into a class
  Future _computeCompletionMetrics(
      ResourceProvider resourceProvider, List<String> analysisRoots) async {
    for (var root in analysisRoots) {
      print('Analyzing root... $root');
      final collection = AnalysisContextCollection(
        includedPaths: [root],
        resourceProvider: resourceProvider,
  