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

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

Issue 752833002: refactor import caching to exclude suggestions for inherited members (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: cleanup unused imports Created 6 years 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/dart_completion_cache.da rt';
12 import 'package:analysis_server/src/services/completion/dart_completion_manager. dart'; 13 import 'package:analysis_server/src/services/completion/dart_completion_manager. dart';
13 import 'package:analysis_server/src/services/completion/imported_computer.dart'; 14 import 'package:analysis_server/src/services/completion/imported_computer.dart';
14 import 'package:analysis_server/src/services/completion/invocation_computer.dart '; 15 import 'package:analysis_server/src/services/completion/invocation_computer.dart ';
15 import 'package:analysis_server/src/services/completion/local_computer.dart'; 16 import 'package:analysis_server/src/services/completion/local_computer.dart';
16 import 'package:analysis_server/src/services/index/index.dart'; 17 import 'package:analysis_server/src/services/index/index.dart';
17 import 'package:analysis_server/src/services/index/local_memory_index.dart'; 18 import 'package:analysis_server/src/services/index/local_memory_index.dart';
18 import 'package:analysis_server/src/services/search/search_engine_internal.dart' ; 19 import 'package:analysis_server/src/services/search/search_engine_internal.dart' ;
19 import 'package:analyzer/src/generated/ast.dart'; 20 import 'package:analyzer/src/generated/ast.dart';
20 import 'package:analyzer/src/generated/element.dart'; 21 import 'package:analyzer/src/generated/element.dart';
21 import 'package:analyzer/src/generated/engine.dart'; 22 import 'package:analyzer/src/generated/engine.dart';
22 import 'package:analyzer/src/generated/source.dart'; 23 import 'package:analyzer/src/generated/source.dart';
23 import 'package:unittest/unittest.dart'; 24 import 'package:unittest/unittest.dart';
24 25
25 import '../../abstract_context.dart'; 26 import '../../abstract_context.dart';
26 27
28 int suggestionComparator(CompletionSuggestion s1, CompletionSuggestion s2) {
29 String c1 = s1.completion.toLowerCase();
30 String c2 = s2.completion.toLowerCase();
31 return c1.compareTo(c2);
32 }
33
27 abstract class AbstractCompletionTest extends AbstractContextTest { 34 abstract class AbstractCompletionTest extends AbstractContextTest {
28 Index index; 35 Index index;
29 SearchEngineImpl searchEngine; 36 SearchEngineImpl searchEngine;
30 DartCompletionComputer computer; 37 DartCompletionComputer computer;
31 String testFile = '/completionTest.dart'; 38 String testFile = '/completionTest.dart';
32 Source testSource; 39 Source testSource;
33 CompilationUnit testUnit; 40 CompilationUnit testUnit;
34 int completionOffset; 41 int completionOffset;
35 AstNode completionNode; 42 AstNode completionNode;
36 bool _computeFastCalled = false; 43 bool _computeFastCalled = false;
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 } 471 }
465 return computer.computeFull(request).then(assertFunction); 472 return computer.computeFull(request).then(assertFunction);
466 } 473 }
467 474
468 void failedCompletion(String message, 475 void failedCompletion(String message,
469 [Iterable<CompletionSuggestion> completions]) { 476 [Iterable<CompletionSuggestion> completions]) {
470 StringBuffer sb = new StringBuffer(message); 477 StringBuffer sb = new StringBuffer(message);
471 if (completions != null) { 478 if (completions != null) {
472 sb.write('\n found'); 479 sb.write('\n found');
473 completions.toList() 480 completions.toList()
474 ..sort((CompletionSuggestion s1, CompletionSuggestion s2) { 481 ..sort(suggestionComparator)
475 String c1 = s1.completion.toLowerCase();
476 String c2 = s2.completion.toLowerCase();
477 return c1.compareTo(c2);
478 })
479 ..forEach((CompletionSuggestion suggestion) { 482 ..forEach((CompletionSuggestion suggestion) {
480 sb.write('\n ${suggestion.completion} -> $suggestion'); 483 sb.write('\n ${suggestion.completion} -> $suggestion');
481 }); 484 });
482 } 485 }
483 if (completionNode != null) { 486 if (completionNode != null) {
484 sb.write('\n in'); 487 sb.write('\n in');
485 AstNode node = completionNode; 488 AstNode node = completionNode;
486 while (node != null) { 489 while (node != null) {
487 sb.write('\n ${node.runtimeType}'); 490 sb.write('\n ${node.runtimeType}');
488 node = node.parent; 491 node = node.parent;
(...skipping 1563 matching lines...) Expand 10 before | Expand all | Expand 10 after
2052 assertNotSuggested('bar2'); 2055 assertNotSuggested('bar2');
2053 assertNotSuggested('_B'); 2056 assertNotSuggested('_B');
2054 assertSuggestLocalClass('Y'); 2057 assertSuggestLocalClass('Y');
2055 assertSuggestLocalClass('C'); 2058 assertSuggestLocalClass('C');
2056 assertSuggestLocalVariable('f', null); 2059 assertSuggestLocalVariable('f', null);
2057 assertNotSuggested('x'); 2060 assertNotSuggested('x');
2058 assertNotSuggested('e'); 2061 assertNotSuggested('e');
2059 }); 2062 });
2060 } 2063 }
2061 } 2064 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698