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

Side by Side Diff: pkg/analysis_server/test/services/search/search_engine_test.dart

Issue 2949823002: Remove unused implementation of SearchEngine and rename the driver-based implementation (Closed)
Patch Set: Created 3 years, 6 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
« no previous file with comments | « pkg/analysis_server/test/services/search/hierarchy_test.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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 import 'dart:async'; 5 import 'dart:async';
6 6
7 import 'package:analysis_server/src/services/search/search_engine.dart'; 7 import 'package:analysis_server/src/services/search/search_engine.dart';
8 import 'package:analysis_server/src/services/search/search_engine_internal2.dart '; 8 import 'package:analysis_server/src/services/search/search_engine_internal.dart' ;
9 import 'package:analyzer/dart/element/element.dart'; 9 import 'package:analyzer/dart/element/element.dart';
10 import 'package:analyzer/file_system/file_system.dart'; 10 import 'package:analyzer/file_system/file_system.dart';
11 import 'package:analyzer/file_system/memory_file_system.dart'; 11 import 'package:analyzer/file_system/memory_file_system.dart';
12 import 'package:analyzer/src/dart/analysis/driver.dart'; 12 import 'package:analyzer/src/dart/analysis/driver.dart';
13 import 'package:analyzer/src/dart/analysis/file_state.dart'; 13 import 'package:analyzer/src/dart/analysis/file_state.dart';
14 import 'package:analyzer/src/generated/engine.dart'; 14 import 'package:analyzer/src/generated/engine.dart';
15 import 'package:analyzer/src/generated/sdk.dart'; 15 import 'package:analyzer/src/generated/sdk.dart';
16 import 'package:analyzer/src/generated/source.dart'; 16 import 'package:analyzer/src/generated/source.dart';
17 import 'package:front_end/src/base/performace_logger.dart'; 17 import 'package:front_end/src/base/performace_logger.dart';
18 import 'package:front_end/src/incremental/byte_store.dart'; 18 import 'package:front_end/src/incremental/byte_store.dart';
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 class B extends A {} 57 class B extends A {}
58 class C implements B {} 58 class C implements B {}
59 '''); 59 ''');
60 60
61 var driver = _newDriver(); 61 var driver = _newDriver();
62 driver.addFile(p); 62 driver.addFile(p);
63 63
64 var resultA = await driver.getResult(p); 64 var resultA = await driver.getResult(p);
65 ClassElement element = resultA.unit.element.types[0]; 65 ClassElement element = resultA.unit.element.types[0];
66 66
67 var searchEngine = new SearchEngineImpl2([driver]); 67 var searchEngine = new SearchEngineImpl([driver]);
68 Set<ClassElement> subtypes = await searchEngine.searchAllSubtypes(element); 68 Set<ClassElement> subtypes = await searchEngine.searchAllSubtypes(element);
69 expect(subtypes, hasLength(3)); 69 expect(subtypes, hasLength(3));
70 expect(subtypes, contains(predicate((ClassElement e) => e.name == 'A'))); 70 expect(subtypes, contains(predicate((ClassElement e) => e.name == 'A')));
71 expect(subtypes, contains(predicate((ClassElement e) => e.name == 'B'))); 71 expect(subtypes, contains(predicate((ClassElement e) => e.name == 'B')));
72 expect(subtypes, contains(predicate((ClassElement e) => e.name == 'C'))); 72 expect(subtypes, contains(predicate((ClassElement e) => e.name == 'C')));
73 } 73 }
74 74
75 test_searchAllSubtypes_acrossDrivers() async { 75 test_searchAllSubtypes_acrossDrivers() async {
76 var a = _p('/test/a.dart'); 76 var a = _p('/test/a.dart');
77 var b = _p('/test/b.dart'); 77 var b = _p('/test/b.dart');
(...skipping 14 matching lines...) Expand all
92 92
93 var driver1 = _newDriver(); 93 var driver1 = _newDriver();
94 var driver2 = _newDriver(); 94 var driver2 = _newDriver();
95 95
96 driver1.addFile(a); 96 driver1.addFile(a);
97 driver2.addFile(b); 97 driver2.addFile(b);
98 98
99 var resultA = await driver1.getResult(a); 99 var resultA = await driver1.getResult(a);
100 ClassElement element = resultA.unit.element.types[0]; 100 ClassElement element = resultA.unit.element.types[0];
101 101
102 var searchEngine = new SearchEngineImpl2([driver1, driver2]); 102 var searchEngine = new SearchEngineImpl([driver1, driver2]);
103 Set<ClassElement> subtypes = await searchEngine.searchAllSubtypes(element); 103 Set<ClassElement> subtypes = await searchEngine.searchAllSubtypes(element);
104 expect(subtypes, hasLength(3)); 104 expect(subtypes, hasLength(3));
105 expect(subtypes, contains(predicate((ClassElement e) => e.name == 'A'))); 105 expect(subtypes, contains(predicate((ClassElement e) => e.name == 'A')));
106 expect(subtypes, contains(predicate((ClassElement e) => e.name == 'B'))); 106 expect(subtypes, contains(predicate((ClassElement e) => e.name == 'B')));
107 expect(subtypes, contains(predicate((ClassElement e) => e.name == 'C'))); 107 expect(subtypes, contains(predicate((ClassElement e) => e.name == 'C')));
108 } 108 }
109 109
110 test_searchMemberDeclarations() async { 110 test_searchMemberDeclarations() async {
111 var a = _p('/test/a.dart'); 111 var a = _p('/test/a.dart');
112 var b = _p('/test/b.dart'); 112 var b = _p('/test/b.dart');
(...skipping 18 matching lines...) Expand all
131 var driver1 = _newDriver(); 131 var driver1 = _newDriver();
132 var driver2 = _newDriver(); 132 var driver2 = _newDriver();
133 133
134 driver1.addFile(a); 134 driver1.addFile(a);
135 driver2.addFile(b); 135 driver2.addFile(b);
136 136
137 while (scheduler.isAnalyzing) { 137 while (scheduler.isAnalyzing) {
138 await new Future.delayed(new Duration(milliseconds: 1)); 138 await new Future.delayed(new Duration(milliseconds: 1));
139 } 139 }
140 140
141 var searchEngine = new SearchEngineImpl2([driver1, driver2]); 141 var searchEngine = new SearchEngineImpl([driver1, driver2]);
142 List<SearchMatch> matches = 142 List<SearchMatch> matches =
143 await searchEngine.searchMemberDeclarations('test'); 143 await searchEngine.searchMemberDeclarations('test');
144 expect(matches, hasLength(2)); 144 expect(matches, hasLength(2));
145 145
146 void assertHasElement(String name, int nameOffset) { 146 void assertHasElement(String name, int nameOffset) {
147 expect( 147 expect(
148 matches, 148 matches,
149 contains(predicate((SearchMatch m) => 149 contains(predicate((SearchMatch m) =>
150 m.kind == MatchKind.DECLARATION && 150 m.kind == MatchKind.DECLARATION &&
151 m.element.name == name && 151 m.element.name == name &&
(...skipping 26 matching lines...) Expand all
178 p.test = 1; 178 p.test = 1;
179 } 179 }
180 '''); 180 ''');
181 181
182 var driver1 = _newDriver(); 182 var driver1 = _newDriver();
183 var driver2 = _newDriver(); 183 var driver2 = _newDriver();
184 184
185 driver1.addFile(a); 185 driver1.addFile(a);
186 driver2.addFile(b); 186 driver2.addFile(b);
187 187
188 var searchEngine = new SearchEngineImpl2([driver1, driver2]); 188 var searchEngine = new SearchEngineImpl([driver1, driver2]);
189 List<SearchMatch> matches = 189 List<SearchMatch> matches =
190 await searchEngine.searchMemberReferences('test'); 190 await searchEngine.searchMemberReferences('test');
191 expect(matches, hasLength(2)); 191 expect(matches, hasLength(2));
192 expect( 192 expect(
193 matches, 193 matches,
194 contains(predicate((SearchMatch m) => 194 contains(predicate((SearchMatch m) =>
195 m.element.name == 'foo' || m.kind == MatchKind.READ))); 195 m.element.name == 'foo' || m.kind == MatchKind.READ)));
196 expect( 196 expect(
197 matches, 197 matches,
198 contains(predicate((SearchMatch m) => 198 contains(predicate((SearchMatch m) =>
(...skipping 19 matching lines...) Expand all
218 218
219 var driver1 = _newDriver(); 219 var driver1 = _newDriver();
220 var driver2 = _newDriver(); 220 var driver2 = _newDriver();
221 221
222 driver1.addFile(a); 222 driver1.addFile(a);
223 driver2.addFile(b); 223 driver2.addFile(b);
224 224
225 var resultA = await driver1.getResult(a); 225 var resultA = await driver1.getResult(a);
226 ClassElement element = resultA.unit.element.types[0]; 226 ClassElement element = resultA.unit.element.types[0];
227 227
228 var searchEngine = new SearchEngineImpl2([driver1, driver2]); 228 var searchEngine = new SearchEngineImpl([driver1, driver2]);
229 List<SearchMatch> matches = await searchEngine.searchReferences(element); 229 List<SearchMatch> matches = await searchEngine.searchReferences(element);
230 expect(matches, hasLength(2)); 230 expect(matches, hasLength(2));
231 expect( 231 expect(
232 matches, contains(predicate((SearchMatch m) => m.element.name == 'a'))); 232 matches, contains(predicate((SearchMatch m) => m.element.name == 'a')));
233 expect( 233 expect(
234 matches, contains(predicate((SearchMatch m) => m.element.name == 'b'))); 234 matches, contains(predicate((SearchMatch m) => m.element.name == 'b')));
235 } 235 }
236 236
237 test_searchTopLevelDeclarations() async { 237 test_searchTopLevelDeclarations() async {
238 var a = _p('/test/a.dart'); 238 var a = _p('/test/a.dart');
(...skipping 15 matching lines...) Expand all
254 var driver1 = _newDriver(); 254 var driver1 = _newDriver();
255 var driver2 = _newDriver(); 255 var driver2 = _newDriver();
256 256
257 driver1.addFile(a); 257 driver1.addFile(a);
258 driver2.addFile(b); 258 driver2.addFile(b);
259 259
260 while (scheduler.isAnalyzing) { 260 while (scheduler.isAnalyzing) {
261 await new Future.delayed(new Duration(milliseconds: 1)); 261 await new Future.delayed(new Duration(milliseconds: 1));
262 } 262 }
263 263
264 var searchEngine = new SearchEngineImpl2([driver1, driver2]); 264 var searchEngine = new SearchEngineImpl([driver1, driver2]);
265 List<SearchMatch> matches = 265 List<SearchMatch> matches =
266 await searchEngine.searchTopLevelDeclarations('.*'); 266 await searchEngine.searchTopLevelDeclarations('.*');
267 expect( 267 expect(
268 matches.where((match) => !match.libraryElement.isInSdk), hasLength(4)); 268 matches.where((match) => !match.libraryElement.isInSdk), hasLength(4));
269 269
270 void assertHasElement(String name) { 270 void assertHasElement(String name) {
271 expect( 271 expect(
272 matches, 272 matches,
273 contains(predicate((SearchMatch m) => 273 contains(predicate((SearchMatch m) =>
274 m.kind == MatchKind.DECLARATION && m.element.name == name))); 274 m.kind == MatchKind.DECLARATION && m.element.name == name)));
(...skipping 13 matching lines...) Expand all
288 contentOverlay, 288 contentOverlay,
289 null, 289 null,
290 new SourceFactory( 290 new SourceFactory(
291 [new DartUriResolver(sdk), new ResourceUriResolver(provider)], 291 [new DartUriResolver(sdk), new ResourceUriResolver(provider)],
292 null, 292 null,
293 provider), 293 provider),
294 new AnalysisOptionsImpl()..strongMode = true); 294 new AnalysisOptionsImpl()..strongMode = true);
295 295
296 String _p(String path) => provider.convertPath(path); 296 String _p(String path) => provider.convertPath(path);
297 } 297 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/test/services/search/hierarchy_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698