Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(62)

Side by Side Diff: dart/pkg/analysis_server/test/services/completion/completion_test_util.dart

Issue 931103003: Version 1.9.0-dev.8.2 (Closed) Base URL: http://dart.googlecode.com/svn/trunk/
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library test.services.completion.util; 5 library test.services.completion.util;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/src/protocol.dart' as protocol show Element, 9 import 'package:analysis_server/src/protocol.dart' as protocol show Element,
10 ElementKind; 10 ElementKind;
11 import 'package:analysis_server/src/protocol.dart' hide Element, ElementKind; 11 import 'package:analysis_server/src/protocol.dart' hide Element, ElementKind;
12 import 'package:analysis_server/src/services/completion/common_usage_computer.da rt';
12 import 'package:analysis_server/src/services/completion/completion_manager.dart' ; 13 import 'package:analysis_server/src/services/completion/completion_manager.dart' ;
13 import 'package:analysis_server/src/services/completion/dart_completion_cache.da rt'; 14 import 'package:analysis_server/src/services/completion/dart_completion_cache.da rt';
14 import 'package:analysis_server/src/services/completion/dart_completion_manager. dart'; 15 import 'package:analysis_server/src/services/completion/dart_completion_manager. dart';
15 import 'package:analysis_server/src/services/completion/imported_computer.dart'; 16 import 'package:analysis_server/src/services/completion/imported_computer.dart';
16 import 'package:analysis_server/src/services/completion/invocation_computer.dart '; 17 import 'package:analysis_server/src/services/completion/invocation_computer.dart ';
17 import 'package:analysis_server/src/services/index/index.dart'; 18 import 'package:analysis_server/src/services/index/index.dart';
18 import 'package:analysis_server/src/services/index/local_memory_index.dart'; 19 import 'package:analysis_server/src/services/index/local_memory_index.dart';
19 import 'package:analysis_server/src/services/search/search_engine_internal.dart' ; 20 import 'package:analysis_server/src/services/search/search_engine_internal.dart' ;
20 import 'package:analyzer/src/generated/ast.dart'; 21 import 'package:analyzer/src/generated/ast.dart';
21 import 'package:analyzer/src/generated/element.dart'; 22 import 'package:analyzer/src/generated/element.dart';
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 } 444 }
444 } 445 }
445 446
446 bool computeFast() { 447 bool computeFast() {
447 _computeFastCalled = true; 448 _computeFastCalled = true;
448 _completionManager = new DartCompletionManager( 449 _completionManager = new DartCompletionManager(
449 context, 450 context,
450 searchEngine, 451 searchEngine,
451 testSource, 452 testSource,
452 cache, 453 cache,
453 [computer]); 454 [computer],
455 new CommonUsageComputer({}));
454 var result = _completionManager.computeFast(request); 456 var result = _completionManager.computeFast(request);
455 expect(request.replacementOffset, isNotNull); 457 expect(request.replacementOffset, isNotNull);
456 expect(request.replacementLength, isNotNull); 458 expect(request.replacementLength, isNotNull);
457 return result.isEmpty; 459 return result.isEmpty;
458 } 460 }
459 461
460 Future computeFull(assertFunction(bool result), {bool fullAnalysis: true}) { 462 Future computeFull(assertFunction(bool result), {bool fullAnalysis: true}) {
461 if (!_computeFastCalled) { 463 if (!_computeFastCalled) {
462 expect(computeFast(), isFalse); 464 expect(computeFast(), isFalse);
463 } 465 }
(...skipping 2025 matching lines...) Expand 10 before | Expand all | Expand 10 after
2489 assertNotSuggested('m'); 2491 assertNotSuggested('m');
2490 assertNotSuggested('_n'); 2492 assertNotSuggested('_n');
2491 assertNotSuggested('a'); 2493 assertNotSuggested('a');
2492 assertNotSuggested('A'); 2494 assertNotSuggested('A');
2493 assertNotSuggested('X'); 2495 assertNotSuggested('X');
2494 assertNotSuggested('Object'); 2496 assertNotSuggested('Object');
2495 assertNotSuggested('=='); 2497 assertNotSuggested('==');
2496 }); 2498 });
2497 } 2499 }
2498 2500
2501 test_new_instance() {
2502 addTestSource('import "dart:math"; class A {x() {new Random().^}}');
2503 computeFast();
2504 return computeFull((bool result) {
2505 assertSuggestInvocationMethod('nextBool', 'Random', 'bool');
2506 assertSuggestInvocationMethod('nextDouble', 'Random', 'double');
2507 assertSuggestInvocationMethod('nextInt', 'Random', 'int');
2508 assertNotSuggested('Random');
2509 assertNotSuggested('Object');
2510 assertNotSuggested('A');
2511 });
2512 }
2513
2499 test_partFile_TypeName() { 2514 test_partFile_TypeName() {
2500 // SimpleIdentifier TypeName ConstructorName 2515 // SimpleIdentifier TypeName ConstructorName
2501 addSource('/testB.dart', ''' 2516 addSource('/testB.dart', '''
2502 lib B; 2517 lib B;
2503 int T1; 2518 int T1;
2504 F1() { } 2519 F1() { }
2505 class X {X.c(); X._d(); z() {}}'''); 2520 class X {X.c(); X._d(); z() {}}''');
2506 addSource('/testA.dart', ''' 2521 addSource('/testA.dart', '''
2507 library libA; 2522 library libA;
2508 import "/testB.dart"; 2523 import "/testB.dart";
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
2967 assertNotSuggested('bar2'); 2982 assertNotSuggested('bar2');
2968 assertNotSuggested('_B'); 2983 assertNotSuggested('_B');
2969 assertSuggestLocalClass('Y'); 2984 assertSuggestLocalClass('Y');
2970 assertSuggestLocalClass('C'); 2985 assertSuggestLocalClass('C');
2971 assertSuggestLocalVariable('f', null); 2986 assertSuggestLocalVariable('f', null);
2972 assertNotSuggested('x'); 2987 assertNotSuggested('x');
2973 assertNotSuggested('e'); 2988 assertNotSuggested('e');
2974 }); 2989 });
2975 } 2990 }
2976 } 2991 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698