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: import 'package:analyzer/file_system/physical_file_system.dart';
  import 'package:analyzer/src/generated/engine.dart';
  
  main() {
    List<String> analysisRoots = [""];
    _computeCompletionMetrics(PhysicalResourceProvider.INSTANCE, analysisRoots);
  }
  
  Future _computeCompletionMetrics(
      ResourceProvider resourceProvider, List<String> analysisRoots) async {
    for (var root in analysisRoots) {
      print('Analyzing... $root');
      final collection = AnalysisContextCollection(
        includedPaths: [root],
        resourceProvider: resourceProvider,
  
negative.code:       }
      }
    }
    print("done $includedCount $notIncludedCount");
  
    final percentIncluded = includedCount / (includedCount + notIncludedCount);
    final percentNotIncluded =
        notIncludedCount / (includedCount + notIncludedCount);
    print("done $percentIncluded% $percentNotIncluded%");
  }
  
  Point<int> _placementInSuggestionList(
      List<CompletionSuggestion> suggestions, String completion) {
    int i = 1;
    for (CompletionSuggestion completionSuggestion in suggestions) {
      if (completionSuggestion.completion == completion) {
        return Point(i, suggestions.length);
      }
      i++;
    }
    return Point(0, 0);
  }
  
  class CompletionMetricVisitor extends RecursiveAstVisitor {
    // TODO(jwren) move this class into a different file
    // TODO(jwren) implement missing visit* methods
  
    List<SyntacticEntity> entities;
  
    CompletionMetricVisitor() {
      entities = <SyntacticEntity>[];
    }
  
    safelyRecordEntity(SyntacticEntity entity) {
      if (entity != null && entity.offset > 0 && entity.length > 0) {
        entities.add(entity);
      }
    }
  
    @override
    visitDoStatement(DoStatement node) {
      safelyRecordEntity(node.doKeyword);
      return super.visitDoStatement(node);
    }
  
    @override
    visitIfStatement(IfStatement node) {
      safelyRecordEntity(node.ifKeyword);
      return super.visitIfStatement(node);
    }
  
    @override
    visitImportDirective(ImportDirective node) {
      safelyRecordEntity(node.keyword);
      safelyRecordEntity(node.asKeyword);
      return super.visitImportDirective(node);
    }
  
    @override
    visitSimpleIdentifier(SimpleIdentifier node) {
      if (!node.inDeclarationContext()) {
        safelyRecordEntity(node);
      }
      return super.visitSimpleIdentifier(node);
    }
  }
  