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

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

Issue 787663004: cache suggestions on change in priority sources (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge 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
« no previous file with comments | « pkg/analysis_server/lib/src/services/completion/imported_computer.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.toplevel; 5 library test.services.completion.toplevel;
6 6
7 import 'package:analysis_server/src/protocol.dart'; 7 import 'package:analysis_server/src/protocol.dart';
8 import 'package:analysis_server/src/services/completion/completion_manager.dart' ; 8 import 'package:analysis_server/src/services/completion/completion_manager.dart' ;
9 import 'package:analysis_server/src/services/completion/dart_completion_cache.da rt'; 9 import 'package:analysis_server/src/services/completion/dart_completion_cache.da rt';
10 import 'package:analysis_server/src/services/completion/dart_completion_manager. dart'; 10 import 'package:analysis_server/src/services/completion/dart_completion_manager. dart';
(...skipping 21 matching lines...) Expand all
32 fail('expected $completion to be cached'); 32 fail('expected $completion to be cached');
33 } 33 }
34 } 34 }
35 35
36 /** 36 /**
37 * Assert that the ImportedComputer uses cached results to produce identical 37 * Assert that the ImportedComputer uses cached results to produce identical
38 * suggestions to the original set of suggestions. 38 * suggestions to the original set of suggestions.
39 */ 39 */
40 @override 40 @override
41 void assertCachedCompute(_) { 41 void assertCachedCompute(_) {
42 if (!(computer as ImportedComputer).shouldWaitForLowPrioritySuggestions) {
43 return;
44 }
42 expect(request.unit.element, isNotNull); 45 expect(request.unit.element, isNotNull);
43 List<CompletionSuggestion> oldSuggestions = request.suggestions; 46 List<CompletionSuggestion> oldSuggestions = request.suggestions;
44 /* 47 /*
45 * Simulate a source change to flush the cached compilation unit 48 * Simulate a source change to flush the cached compilation unit
46 */ 49 */
47 ChangeSet changes = new ChangeSet(); 50 ChangeSet changes = new ChangeSet();
48 changes.addedSource(testSource); 51 changes.addedSource(testSource);
49 context.applyChanges(changes); 52 context.applyChanges(changes);
50 /* 53 /*
51 * Calculate a new completion at the same location 54 * Calculate a new completion at the same location
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 @override 140 @override
138 test_Block_inherited_imported() { 141 test_Block_inherited_imported() {
139 return super.test_Block_inherited_imported().then((_) { 142 return super.test_Block_inherited_imported().then((_) {
140 assertCached('E'); 143 assertCached('E');
141 assertCached('F'); 144 assertCached('F');
142 assertNotCached('e1'); 145 assertNotCached('e1');
143 assertNotCached('i2'); 146 assertNotCached('i2');
144 assertNotCached('m1'); 147 assertNotCached('m1');
145 }); 148 });
146 } 149 }
150
151 test_Block_partial_results() {
152 // Block BlockFunctionBody MethodDeclaration
153 addSource('/testAB.dart', '''
154 export "dart:math" hide max;
155 class A {int x;}
156 @deprecated D1() {int x;}
157 class _B { }''');
158 addSource('/testCD.dart', '''
159 String T1;
160 var _T2;
161 class C { }
162 class D { }''');
163 addSource('/testEEF.dart', '''
164 class EE { }
165 class F { }''');
166 addSource('/testG.dart', 'class G { }');
167 addSource('/testH.dart', '''
168 class H { }
169 int T3;
170 var _T4;'''); // not imported
171 addTestSource('''
172 import "/testAB.dart";
173 import "/testCD.dart" hide D;
174 import "/testEEF.dart" show EE;
175 import "/testG.dart" as g;
176 int T5;
177 var _T6;
178 Z D2() {int x;}
179 class X {a() {var f; {var x;} ^ var r;} void b() { }}
180 class Z { }''');
181 (computer as ImportedComputer).shouldWaitForLowPrioritySuggestions = false;
182 computeFast();
183 return computeFull((bool result) {
184 assertSuggestImportedClass('C');
185 // Assert computer does not wait for or include low priority results
186 // from non-imported libraries unless instructed to do so.
187 assertNotSuggested('H');
188 });
189 }
147 } 190 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/services/completion/imported_computer.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698