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

Side by Side Diff: pkg/analysis_server/test/analysis/update_content_test.dart

Issue 2912883003: Clean-up several warnings (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 | « no previous file | pkg/analyzer/test/generated/all_the_rest_test.dart » ('j') | 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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 'package:analysis_server/protocol/protocol.dart'; 5 import 'package:analysis_server/protocol/protocol.dart';
6 import 'package:analysis_server/protocol/protocol_generated.dart'; 6 import 'package:analysis_server/protocol/protocol_generated.dart';
7 import 'package:analysis_server/src/analysis_server.dart';
8 import 'package:analysis_server/src/constants.dart'; 7 import 'package:analysis_server/src/constants.dart';
9 import 'package:analysis_server/src/services/index/index.dart'; 8 import 'package:analysis_server/src/services/index/index.dart';
10 import 'package:analyzer/dart/ast/ast.dart'; 9 import 'package:analyzer/dart/ast/ast.dart';
11 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; 10 import 'package:analyzer/dart/ast/standard_resolution_map.dart';
12 import 'package:analyzer/file_system/file_system.dart'; 11 import 'package:analyzer/file_system/file_system.dart';
13 import 'package:analyzer/src/generated/engine.dart'; 12 import 'package:analyzer/src/generated/engine.dart';
14 import 'package:analyzer/src/generated/source.dart'; 13 import 'package:analyzer/src/generated/source.dart';
15 import 'package:analyzer_plugin/protocol/protocol_common.dart' as plugin; 14 import 'package:analyzer_plugin/protocol/protocol_common.dart' as plugin;
16 import 'package:analyzer_plugin/protocol/protocol_common.dart'; 15 import 'package:analyzer_plugin/protocol/protocol_common.dart';
17 import 'package:analyzer_plugin/protocol/protocol_generated.dart' as plugin; 16 import 'package:analyzer_plugin/protocol/protocol_generated.dart' as plugin;
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 expect(e.response.id, id); 95 expect(e.response.id, id);
97 expect(e.response.error.code, RequestErrorCode.INVALID_OVERLAY_CHANGE); 96 expect(e.response.error.code, RequestErrorCode.INVALID_OVERLAY_CHANGE);
98 } 97 }
99 } 98 }
100 99
101 test_indexUnitAfterNopChange() async { 100 test_indexUnitAfterNopChange() async {
102 // AnalysisContext incremental analysis has been removed 101 // AnalysisContext incremental analysis has been removed
103 if (!enableNewAnalysisDriver) return; 102 if (!enableNewAnalysisDriver) return;
104 throw 'is this test used by the new analysis driver?'; 103 throw 'is this test used by the new analysis driver?';
105 104
106 var testUnitMatcher = compilationUnitMatcher(testFile) as dynamic; 105 // var testUnitMatcher = compilationUnitMatcher(testFile) as dynamic;
107 createProject(); 106 // createProject();
108 addTestFile('main() { print(1); }'); 107 // addTestFile('main() { print(1); }');
109 await server.onAnalysisComplete; 108 // await server.onAnalysisComplete;
110 verify(server.index.indexUnit(testUnitMatcher)).times(1); 109 // verify(server.index.indexUnit(testUnitMatcher)).times(1);
111 // add an overlay 110 // // add an overlay
112 server.updateContent( 111 // server.updateContent(
113 '1', {testFile: new AddContentOverlay('main() { print(2); }')}); 112 // '1', {testFile: new AddContentOverlay('main() { print(2); }')});
114 // Perform the next single operation: analysis. 113 // // Perform the next single operation: analysis.
115 // It will schedule an indexing operation. 114 // // It will schedule an indexing operation.
116 await server.test_onOperationPerformed; 115 // await server.test_onOperationPerformed;
117 // Update the file and remove an overlay. 116 // // Update the file and remove an overlay.
118 resourceProvider.updateFile(testFile, 'main() { print(2); }'); 117 // resourceProvider.updateFile(testFile, 'main() { print(2); }');
119 server.updateContent('2', {testFile: new RemoveContentOverlay()}); 118 // server.updateContent('2', {testFile: new RemoveContentOverlay()});
120 // Validate that at the end the unit was indexed. 119 // // Validate that at the end the unit was indexed.
121 await server.onAnalysisComplete; 120 // await server.onAnalysisComplete;
122 verify(server.index.indexUnit(testUnitMatcher)).times(3); 121 // verify(server.index.indexUnit(testUnitMatcher)).times(3);
123 } 122 }
124 123
125 test_multiple_contexts() async { 124 test_multiple_contexts() async {
126 String fooPath = '/project1/foo.dart'; 125 String fooPath = '/project1/foo.dart';
127 resourceProvider.newFile( 126 resourceProvider.newFile(
128 fooPath, 127 fooPath,
129 ''' 128 '''
130 library foo; 129 library foo;
131 import '../project2/baz.dart'; 130 import '../project2/baz.dart';
132 main() { f(); }'''); 131 main() { f(); }''');
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 server.updateContent('2', {filePath: new RemoveContentOverlay()}); 220 server.updateContent('2', {filePath: new RemoveContentOverlay()});
222 expect(_getUserSources(context1), isEmpty); 221 expect(_getUserSources(context1), isEmpty);
223 expect(_getUserSources(context2), isEmpty); 222 expect(_getUserSources(context2), isEmpty);
224 } 223 }
225 224
226 test_removeOverlay_incrementalChange() async { 225 test_removeOverlay_incrementalChange() async {
227 // AnalysisContext incremental analysis has been removed 226 // AnalysisContext incremental analysis has been removed
228 if (!enableNewAnalysisDriver) return; 227 if (!enableNewAnalysisDriver) return;
229 throw 'is this test used by the new analysis driver?'; 228 throw 'is this test used by the new analysis driver?';
230 229
231 createProject(); 230 // createProject();
232 addTestFile('main() { print(1); }'); 231 // addTestFile('main() { print(1); }');
233 await server.onAnalysisComplete; 232 // await server.onAnalysisComplete;
234 CompilationUnit unit = _getTestUnit(); 233 // CompilationUnit unit = _getTestUnit();
235 // add an overlay 234 // // add an overlay
236 server.updateContent( 235 // server.updateContent(
237 '1', {testFile: new AddContentOverlay('main() { print(2); }')}); 236 // '1', {testFile: new AddContentOverlay('main() { print(2); }')});
238 // it was an incremental change 237 // // it was an incremental change
239 await server.onAnalysisComplete; 238 // await server.onAnalysisComplete;
240 expect(_getTestUnit(), same(unit)); 239 // expect(_getTestUnit(), same(unit));
241 // remove overlay 240 // // remove overlay
242 server.updateContent('2', {testFile: new RemoveContentOverlay()}); 241 // server.updateContent('2', {testFile: new RemoveContentOverlay()});
243 // it was an incremental change 242 // // it was an incremental change
244 await server.onAnalysisComplete; 243 // await server.onAnalysisComplete;
245 expect(_getTestUnit(), same(unit)); 244 // expect(_getTestUnit(), same(unit));
246 } 245 }
247 246
248 test_sendNoticesAfterNopChange() async { 247 test_sendNoticesAfterNopChange() async {
249 createProject(); 248 createProject();
250 addTestFile(''); 249 addTestFile('');
251 await server.onAnalysisComplete; 250 await server.onAnalysisComplete;
252 // add an overlay 251 // add an overlay
253 server.updateContent( 252 server.updateContent(
254 '1', {testFile: new AddContentOverlay('main() {} main() {}')}); 253 '1', {testFile: new AddContentOverlay('main() {} main() {}')});
255 await server.onAnalysisComplete; 254 await server.onAnalysisComplete;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 <String, dynamic>{filePath: new RemoveContentOverlay()}) 323 <String, dynamic>{filePath: new RemoveContentOverlay()})
325 .toRequest('2')); 324 .toRequest('2'));
326 params = pluginManager.analysisUpdateContentParams; 325 params = pluginManager.analysisUpdateContentParams;
327 expect(params, isNotNull); 326 expect(params, isNotNull);
328 files = params.files; 327 files = params.files;
329 expect(files, hasLength(1)); 328 expect(files, hasLength(1));
330 overlay = files[filePath]; 329 overlay = files[filePath];
331 expect(overlay, new isInstanceOf<plugin.RemoveContentOverlay>()); 330 expect(overlay, new isInstanceOf<plugin.RemoveContentOverlay>());
332 } 331 }
333 332
334 CompilationUnit _getTestUnit() { 333 // CompilationUnit _getTestUnit() {
335 ContextSourcePair pair = server.getContextSourcePair(testFile); 334 // ContextSourcePair pair = server.getContextSourcePair(testFile);
336 AnalysisContext context = pair.context; 335 // AnalysisContext context = pair.context;
337 Source source = pair.source; 336 // Source source = pair.source;
338 return context.getResolvedCompilationUnit2(source, source); 337 // return context.getResolvedCompilationUnit2(source, source);
339 } 338 // }
340 339
341 List<Source> _getUserSources(AnalysisContext context) { 340 List<Source> _getUserSources(AnalysisContext context) {
342 List<Source> sources = <Source>[]; 341 List<Source> sources = <Source>[];
343 context.sources.forEach((source) { 342 context.sources.forEach((source) {
344 if (source.fullName.startsWith('/User/')) { 343 if (source.fullName.startsWith('/User/')) {
345 sources.add(source); 344 sources.add(source);
346 } 345 }
347 }); 346 });
348 return sources; 347 return sources;
349 } 348 }
350 } 349 }
351 350
352 class _ArgumentMatcher_CompilationUnit extends ArgumentMatcher { 351 class _ArgumentMatcher_CompilationUnit extends ArgumentMatcher {
353 final String file; 352 final String file;
354 353
355 _ArgumentMatcher_CompilationUnit(this.file); 354 _ArgumentMatcher_CompilationUnit(this.file);
356 355
357 @override 356 @override
358 bool matches(arg) { 357 bool matches(arg) {
359 return arg is CompilationUnit && 358 return arg is CompilationUnit &&
360 resolutionMap.elementDeclaredByCompilationUnit(arg).source.fullName == 359 resolutionMap.elementDeclaredByCompilationUnit(arg).source.fullName ==
361 file; 360 file;
362 } 361 }
363 } 362 }
364 363
365 class _MockIndex extends TypedMock implements Index {} 364 class _MockIndex extends TypedMock implements Index {}
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/all_the_rest_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698