OLD | NEW |
---|---|
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.domain.completion; | 5 library test.domain.completion; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 import 'package:analysis_server/completion/completion_core.dart' | 9 import 'package:analysis_server/completion/completion_core.dart' |
10 show CompletionRequest, CompletionResult; | 10 show CompletionRequest, CompletionResult; |
11 import 'package:analysis_server/src/analysis_server.dart'; | 11 import 'package:analysis_server/src/analysis_server.dart'; |
12 import 'package:analysis_server/src/channel/channel.dart'; | 12 import 'package:analysis_server/src/channel/channel.dart'; |
13 import 'package:analysis_server/src/constants.dart'; | 13 import 'package:analysis_server/src/constants.dart'; |
14 import 'package:analysis_server/src/context_manager.dart'; | 14 import 'package:analysis_server/src/context_manager.dart'; |
15 import 'package:analysis_server/src/domain_analysis.dart'; | 15 import 'package:analysis_server/src/domain_analysis.dart'; |
16 import 'package:analysis_server/src/domain_completion.dart'; | 16 import 'package:analysis_server/src/domain_completion.dart'; |
17 import 'package:analysis_server/src/plugin/server_plugin.dart'; | 17 import 'package:analysis_server/src/plugin/server_plugin.dart'; |
18 import 'package:analysis_server/src/protocol.dart'; | 18 import 'package:analysis_server/src/protocol.dart'; |
19 import 'package:analysis_server/src/services/completion/completion_manager.dart' ; | 19 import 'package:analysis_server/src/services/completion/completion_manager.dart' ; |
20 import 'package:analysis_server/src/services/completion/dart_completion_manager. dart'; | 20 import 'package:analysis_server/src/services/completion/dart_completion_manager. dart'; |
21 import 'package:analysis_server/src/services/index/index.dart' show Index; | 21 import 'package:analysis_server/src/services/index/index.dart' show Index; |
22 import 'package:analysis_server/src/services/index/local_memory_index.dart'; | 22 import 'package:analysis_server/src/services/index/local_memory_index.dart'; |
23 import 'package:analysis_server/src/services/search/search_engine.dart'; | 23 import 'package:analysis_server/src/services/search/search_engine.dart'; |
24 import 'package:analyzer/file_system/file_system.dart'; | 24 import 'package:analyzer/file_system/file_system.dart'; |
25 import 'package:analyzer/instrumentation/instrumentation.dart'; | 25 import 'package:analyzer/instrumentation/instrumentation.dart'; |
26 import 'package:analyzer/source/pub_package_map_provider.dart'; | 26 import 'package:analyzer/source/pub_package_map_provider.dart'; |
27 import 'package:analyzer/src/generated/ast.dart'; | |
27 import 'package:analyzer/src/generated/engine.dart'; | 28 import 'package:analyzer/src/generated/engine.dart'; |
28 import 'package:analyzer/src/generated/sdk.dart'; | 29 import 'package:analyzer/src/generated/sdk.dart'; |
29 import 'package:analyzer/src/generated/source.dart'; | 30 import 'package:analyzer/src/generated/source.dart'; |
30 import 'package:plugin/manager.dart'; | 31 import 'package:plugin/manager.dart'; |
31 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 32 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
32 import 'package:unittest/unittest.dart'; | 33 import 'package:unittest/unittest.dart'; |
33 | 34 |
34 import 'analysis_abstract.dart'; | 35 import 'analysis_abstract.dart'; |
35 import 'mock_sdk.dart'; | 36 import 'mock_sdk.dart'; |
36 import 'mocks.dart'; | 37 import 'mocks.dart'; |
(...skipping 11 matching lines...) Expand all Loading... | |
48 AnalysisDomainHandler analysisDomain; | 49 AnalysisDomainHandler analysisDomain; |
49 Test_CompletionDomainHandler completionDomain; | 50 Test_CompletionDomainHandler completionDomain; |
50 Request request; | 51 Request request; |
51 int requestCount = 0; | 52 int requestCount = 0; |
52 String testFile2 = '/project/bin/test2.dart'; | 53 String testFile2 = '/project/bin/test2.dart'; |
53 | 54 |
54 AnalysisServer createAnalysisServer(Index index) { | 55 AnalysisServer createAnalysisServer(Index index) { |
55 ExtensionManager manager = new ExtensionManager(); | 56 ExtensionManager manager = new ExtensionManager(); |
56 ServerPlugin serverPlugin = new ServerPlugin(); | 57 ServerPlugin serverPlugin = new ServerPlugin(); |
57 manager.processPlugins([serverPlugin]); | 58 manager.processPlugins([serverPlugin]); |
58 return new Test_AnalysisServer( | 59 return new Test_AnalysisServer(super.serverChannel, super.resourceProvider, |
59 super.serverChannel, | 60 super.packageMapProvider, index, serverPlugin, |
60 super.resourceProvider, | 61 new AnalysisServerOptions(), new MockSdk(), |
61 super.packageMapProvider, | |
62 index, | |
63 serverPlugin, | |
64 new AnalysisServerOptions(), | |
65 new MockSdk(), | |
66 InstrumentationService.NULL_SERVICE); | 62 InstrumentationService.NULL_SERVICE); |
67 } | 63 } |
68 | 64 |
69 @override | 65 @override |
70 Index createIndex() { | 66 Index createIndex() { |
71 return createLocalMemoryIndex(); | 67 return createLocalMemoryIndex(); |
72 } | 68 } |
73 | 69 |
74 void sendRequest(String path) { | 70 void sendRequest(String path) { |
75 String id = (++requestCount).toString(); | 71 String id = (++requestCount).toString(); |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
261 | 257 |
262 @reflectiveTest | 258 @reflectiveTest |
263 class CompletionTest extends AbstractAnalysisTest { | 259 class CompletionTest extends AbstractAnalysisTest { |
264 String completionId; | 260 String completionId; |
265 int completionOffset; | 261 int completionOffset; |
266 int replacementOffset; | 262 int replacementOffset; |
267 int replacementLength; | 263 int replacementLength; |
268 List<CompletionSuggestion> suggestions = []; | 264 List<CompletionSuggestion> suggestions = []; |
269 bool suggestionsDone = false; | 265 bool suggestionsDone = false; |
270 | 266 |
271 String addTestFile(String content, {offset}) { | 267 String addTestFile(String content, {int offset}) { |
272 completionOffset = content.indexOf('^'); | 268 completionOffset = content.indexOf('^'); |
273 if (offset != null) { | 269 if (offset != null) { |
274 expect(completionOffset, -1, reason: 'cannot supply offset and ^'); | 270 expect(completionOffset, -1, reason: 'cannot supply offset and ^'); |
275 completionOffset = offset; | 271 completionOffset = offset; |
276 return super.addTestFile(content); | 272 return super.addTestFile(content); |
277 } | 273 } |
278 expect(completionOffset, isNot(equals(-1)), reason: 'missing ^'); | 274 expect(completionOffset, isNot(equals(-1)), reason: 'missing ^'); |
279 int nextOffset = content.indexOf('^', completionOffset + 1); | 275 int nextOffset = content.indexOf('^', completionOffset + 1); |
280 expect(nextOffset, equals(-1), reason: 'too many ^'); | 276 expect(nextOffset, equals(-1), reason: 'too many ^'); |
281 return super.addTestFile(content.substring(0, completionOffset) + | 277 return super.addTestFile(content.substring(0, completionOffset) + |
282 content.substring(completionOffset + 1)); | 278 content.substring(completionOffset + 1)); |
283 } | 279 } |
284 | 280 |
285 void assertHasResult(CompletionSuggestionKind kind, String completion, | 281 void assertHasResult(CompletionSuggestionKind kind, String completion, |
286 [int relevance = DART_RELEVANCE_DEFAULT, | 282 {int relevance: DART_RELEVANCE_DEFAULT, |
287 bool isDeprecated = false, | 283 bool isDeprecated: false, |
288 bool isPotential = false]) { | 284 bool isPotential: false, |
285 int selectionOffset}) { | |
289 var cs; | 286 var cs; |
290 suggestions.forEach((s) { | 287 suggestions.forEach((s) { |
291 if (s.completion == completion) { | 288 if (s.completion == completion) { |
292 if (cs == null) { | 289 if (cs == null) { |
293 cs = s; | 290 cs = s; |
294 } else { | 291 } else { |
295 fail('expected exactly one $completion but found > 1'); | 292 fail('expected exactly one $completion but found > 1'); |
296 } | 293 } |
297 } | 294 } |
298 }); | 295 }); |
299 if (cs == null) { | 296 if (cs == null) { |
300 var completions = suggestions.map((s) => s.completion).toList(); | 297 var completions = suggestions.map((s) => s.completion).toList(); |
301 fail('expected "$completion" but found\n $completions'); | 298 fail('expected "$completion" but found\n $completions'); |
302 } | 299 } |
303 expect(cs.kind, equals(kind)); | 300 expect(cs.kind, equals(kind)); |
304 expect(cs.relevance, equals(relevance)); | 301 expect(cs.relevance, equals(relevance)); |
305 expect(cs.selectionOffset, equals(completion.length)); | 302 expect(cs.selectionOffset, selectionOffset ?? completion.length); |
306 expect(cs.selectionLength, equals(0)); | 303 expect(cs.selectionLength, equals(0)); |
307 expect(cs.isDeprecated, equals(isDeprecated)); | 304 expect(cs.isDeprecated, equals(isDeprecated)); |
308 expect(cs.isPotential, equals(isPotential)); | 305 expect(cs.isPotential, equals(isPotential)); |
309 } | 306 } |
310 | 307 |
311 void assertNoResult(String completion) { | 308 void assertNoResult(String completion) { |
312 if (suggestions.any((cs) => cs.completion == completion)) { | 309 if (suggestions.any((cs) => cs.completion == completion)) { |
313 fail('did not expect completion: $completion'); | 310 fail('did not expect completion: $completion'); |
314 } | 311 } |
315 } | 312 } |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
379 '''); | 376 '''); |
380 return getSuggestions().then((_) { | 377 return getSuggestions().then((_) { |
381 expect(replacementOffset, equals(completionOffset)); | 378 expect(replacementOffset, equals(completionOffset)); |
382 expect(replacementLength, equals(0)); | 379 expect(replacementLength, equals(0)); |
383 assertHasResult(CompletionSuggestionKind.INVOCATION, 'Object'); | 380 assertHasResult(CompletionSuggestionKind.INVOCATION, 'Object'); |
384 assertHasResult(CompletionSuggestionKind.INVOCATION, 'HtmlElement'); | 381 assertHasResult(CompletionSuggestionKind.INVOCATION, 'HtmlElement'); |
385 assertNoResult('test'); | 382 assertNoResult('test'); |
386 }); | 383 }); |
387 } | 384 } |
388 | 385 |
386 test_imports_incremental() async { | |
387 addTestFile('''library foo; | |
388 e^ | |
389 import "dart:async"; | |
390 import "package:foo/foo.dart"; | |
391 class foo { }'''); | |
392 await waitForTasksFinished(); | |
393 server.updateContent('uc1', {testFile: new AddContentOverlay(testCode)}); | |
394 server.updateContent('uc2', { | |
395 testFile: | |
396 new ChangeContentOverlay([new SourceEdit(completionOffset, 0, 'xp')]) | |
397 }); | |
398 completionOffset += 2; | |
399 await getSuggestions(); | |
400 expect(replacementOffset, completionOffset - 3); | |
401 expect(replacementLength, 3); | |
402 String completion = 'export'; | |
Brian Wilkerson
2015/08/12 13:59:25
(I'd actually find it easier to read without the l
danrubel
2015/08/15 19:17:16
Done.
| |
403 assertHasResult(CompletionSuggestionKind.KEYWORD, completion, | |
404 relevance: DART_RELEVANCE_HIGH); | |
Brian Wilkerson
2015/08/12 13:59:25
Should we also test for the absence of invalid sug
danrubel
2015/08/15 19:17:16
Good point. Added.
| |
405 } | |
406 | |
407 test_imports_partial() async { | |
408 addTestFile('''^ | |
409 import "package:foo/foo.dart"; | |
410 import "package:bar/bar.dart"; | |
411 class Baz { }'''); | |
412 | |
413 // Wait for analysis then edit the content | |
414 await waitForTasksFinished(); | |
415 String revisedContent = testCode.substring(0, completionOffset) + | |
416 'i' + | |
417 testCode.substring(completionOffset); | |
418 ++completionOffset; | |
419 server.handleRequest(new AnalysisUpdateContentParams( | |
420 {testFile: new AddContentOverlay(revisedContent)}).toRequest('add1')); | |
421 | |
422 // Request code completion immediately after edit | |
423 Response response = handleSuccessfulRequest(new CompletionGetSuggestionsPara ms( | |
424 testFile, completionOffset).toRequest('0')); | |
425 completionId = response.id; | |
426 assertValidId(completionId); | |
427 await waitForTasksFinished(); | |
428 expect(replacementOffset, completionOffset - 1); | |
429 expect(replacementLength, 1); | |
430 String completion = 'import'; | |
431 assertHasResult(CompletionSuggestionKind.KEYWORD, completion, | |
432 relevance: DART_RELEVANCE_HIGH); | |
Brian Wilkerson
2015/08/12 13:59:25
We should also test for 'export', 'library' and 'p
danrubel
2015/08/15 19:17:16
Done.
| |
433 } | |
434 | |
389 test_imports_prefixed() { | 435 test_imports_prefixed() { |
390 addTestFile(''' | 436 addTestFile(''' |
391 import 'dart:html' as foo; | 437 import 'dart:html' as foo; |
392 main() {^} | 438 main() {^} |
393 '''); | 439 '''); |
394 return getSuggestions().then((_) { | 440 return getSuggestions().then((_) { |
395 expect(replacementOffset, equals(completionOffset)); | 441 expect(replacementOffset, equals(completionOffset)); |
396 expect(replacementLength, equals(0)); | 442 expect(replacementLength, equals(0)); |
397 assertHasResult(CompletionSuggestionKind.INVOCATION, 'Object'); | 443 assertHasResult(CompletionSuggestionKind.INVOCATION, 'Object'); |
398 assertHasResult(CompletionSuggestionKind.INVOCATION, 'foo'); | 444 assertHasResult(CompletionSuggestionKind.INVOCATION, 'foo'); |
(...skipping 18 matching lines...) Expand all Loading... | |
417 expect(replacementLength, equals(0)); | 463 expect(replacementLength, equals(0)); |
418 assertHasResult(CompletionSuggestionKind.INVOCATION, 'b'); | 464 assertHasResult(CompletionSuggestionKind.INVOCATION, 'b'); |
419 }); | 465 }); |
420 } | 466 } |
421 | 467 |
422 test_keyword() { | 468 test_keyword() { |
423 addTestFile('library A; cl^'); | 469 addTestFile('library A; cl^'); |
424 return getSuggestions().then((_) { | 470 return getSuggestions().then((_) { |
425 expect(replacementOffset, equals(completionOffset - 2)); | 471 expect(replacementOffset, equals(completionOffset - 2)); |
426 expect(replacementLength, equals(2)); | 472 expect(replacementLength, equals(2)); |
427 assertHasResult( | 473 assertHasResult(CompletionSuggestionKind.KEYWORD, 'export', |
428 CompletionSuggestionKind.KEYWORD, 'export', DART_RELEVANCE_HIGH); | 474 relevance: DART_RELEVANCE_HIGH); |
Brian Wilkerson
2015/08/12 13:59:25
I think we're suggesting 'export' at this point so
danrubel
2015/08/15 19:17:16
That is correct.
| |
429 assertHasResult( | 475 assertHasResult(CompletionSuggestionKind.KEYWORD, 'class', |
430 CompletionSuggestionKind.KEYWORD, 'class', DART_RELEVANCE_HIGH); | 476 relevance: DART_RELEVANCE_HIGH); |
431 }); | 477 }); |
432 } | 478 } |
433 | 479 |
434 test_local_named_constructor() { | 480 test_local_named_constructor() { |
435 addTestFile('class A {A.c(); x() {new A.^}}'); | 481 addTestFile('class A {A.c(); x() {new A.^}}'); |
436 return getSuggestions().then((_) { | 482 return getSuggestions().then((_) { |
437 expect(replacementOffset, equals(completionOffset)); | 483 expect(replacementOffset, equals(completionOffset)); |
438 expect(replacementLength, equals(0)); | 484 expect(replacementLength, equals(0)); |
439 assertHasResult(CompletionSuggestionKind.INVOCATION, 'c'); | 485 assertHasResult(CompletionSuggestionKind.INVOCATION, 'c'); |
440 assertNoResult('A'); | 486 assertNoResult('A'); |
441 }); | 487 }); |
442 } | 488 } |
443 | 489 |
444 test_locals() { | 490 test_locals() { |
445 addTestFile('class A {var a; x() {var b;^}} class DateTime { }'); | 491 addTestFile('class A {var a; x() {var b;^}} class DateTime { }'); |
446 return getSuggestions().then((_) { | 492 return getSuggestions().then((_) { |
447 expect(replacementOffset, equals(completionOffset)); | 493 expect(replacementOffset, equals(completionOffset)); |
448 expect(replacementLength, equals(0)); | 494 expect(replacementLength, equals(0)); |
449 assertHasResult(CompletionSuggestionKind.INVOCATION, 'A'); | 495 assertHasResult(CompletionSuggestionKind.INVOCATION, 'A'); |
450 assertHasResult( | 496 assertHasResult(CompletionSuggestionKind.INVOCATION, 'a', |
451 CompletionSuggestionKind.INVOCATION, 'a', DART_RELEVANCE_LOCAL_FIELD); | 497 relevance: DART_RELEVANCE_LOCAL_FIELD); |
452 assertHasResult(CompletionSuggestionKind.INVOCATION, 'b', | 498 assertHasResult(CompletionSuggestionKind.INVOCATION, 'b', |
453 DART_RELEVANCE_LOCAL_VARIABLE); | 499 relevance: DART_RELEVANCE_LOCAL_VARIABLE); |
454 assertHasResult(CompletionSuggestionKind.INVOCATION, 'x', | 500 assertHasResult(CompletionSuggestionKind.INVOCATION, 'x', |
455 DART_RELEVANCE_LOCAL_METHOD); | 501 relevance: DART_RELEVANCE_LOCAL_METHOD); |
456 assertHasResult(CompletionSuggestionKind.INVOCATION, 'DateTime'); | 502 assertHasResult(CompletionSuggestionKind.INVOCATION, 'DateTime'); |
457 }); | 503 }); |
458 } | 504 } |
459 | 505 |
460 test_offset_past_eof() { | 506 test_offset_past_eof() { |
461 addTestFile('main() { }', offset: 300); | 507 addTestFile('main() { }', offset: 300); |
462 return getSuggestions().then((_) { | 508 return getSuggestions().then((_) { |
463 expect(replacementOffset, equals(300)); | 509 expect(replacementOffset, equals(300)); |
464 expect(replacementLength, equals(0)); | 510 expect(replacementLength, equals(0)); |
465 expect(suggestionsDone, true); | 511 expect(suggestionsDone, true); |
466 expect(suggestions.length, 0); | 512 expect(suggestions.length, 0); |
467 }); | 513 }); |
468 } | 514 } |
469 | 515 |
470 test_overrides() { | 516 test_overrides() { |
471 addFile('/libA.dart', 'class A {m() {}}'); | 517 addFile('/libA.dart', 'class A {m() {}}'); |
472 addTestFile(''' | 518 addTestFile(''' |
473 import '/libA.dart'; | 519 import '/libA.dart'; |
474 class B extends A {m() {^}} | 520 class B extends A {m() {^}} |
475 '''); | 521 '''); |
476 return getSuggestions().then((_) { | 522 return getSuggestions().then((_) { |
477 expect(replacementOffset, equals(completionOffset)); | 523 expect(replacementOffset, equals(completionOffset)); |
478 expect(replacementLength, equals(0)); | 524 expect(replacementLength, equals(0)); |
479 assertHasResult(CompletionSuggestionKind.INVOCATION, 'm', | 525 assertHasResult(CompletionSuggestionKind.INVOCATION, 'm', |
480 DART_RELEVANCE_LOCAL_METHOD); | 526 relevance: DART_RELEVANCE_LOCAL_METHOD); |
481 }); | 527 }); |
482 } | 528 } |
483 | 529 |
484 test_partFile() { | 530 test_partFile() { |
485 addFile( | 531 addFile('/project/bin/testA.dart', ''' |
486 '/project/bin/testA.dart', | |
487 ''' | |
488 library libA; | 532 library libA; |
489 part "$testFile"; | 533 part "$testFile"; |
490 import 'dart:html'; | 534 import 'dart:html'; |
491 class A { } | 535 class A { } |
492 '''); | 536 '''); |
493 addTestFile(''' | 537 addTestFile(''' |
494 part of libA; | 538 part of libA; |
495 main() {^}'''); | 539 main() {^}'''); |
496 return getSuggestions().then((_) { | 540 return getSuggestions().then((_) { |
497 expect(replacementOffset, equals(completionOffset)); | 541 expect(replacementOffset, equals(completionOffset)); |
498 expect(replacementLength, equals(0)); | 542 expect(replacementLength, equals(0)); |
499 assertHasResult(CompletionSuggestionKind.INVOCATION, 'Object'); | 543 assertHasResult(CompletionSuggestionKind.INVOCATION, 'Object'); |
500 assertHasResult(CompletionSuggestionKind.INVOCATION, 'HtmlElement'); | 544 assertHasResult(CompletionSuggestionKind.INVOCATION, 'HtmlElement'); |
501 assertHasResult(CompletionSuggestionKind.INVOCATION, 'A'); | 545 assertHasResult(CompletionSuggestionKind.INVOCATION, 'A'); |
502 assertNoResult('test'); | 546 assertNoResult('test'); |
503 }); | 547 }); |
504 } | 548 } |
505 | 549 |
506 test_partFile2() { | 550 test_partFile2() { |
507 addFile( | 551 addFile('/testA.dart', ''' |
508 '/testA.dart', | |
509 ''' | |
510 part of libA; | 552 part of libA; |
511 class A { }'''); | 553 class A { }'''); |
512 addTestFile(''' | 554 addTestFile(''' |
513 library libA; | 555 library libA; |
514 part "/testA.dart"; | 556 part "/testA.dart"; |
515 import 'dart:html'; | 557 import 'dart:html'; |
516 main() {^} | 558 main() {^} |
517 '''); | 559 '''); |
518 return getSuggestions().then((_) { | 560 return getSuggestions().then((_) { |
519 expect(replacementOffset, equals(completionOffset)); | 561 expect(replacementOffset, equals(completionOffset)); |
(...skipping 25 matching lines...) Expand all Loading... | |
545 typedef foo(); | 587 typedef foo(); |
546 var test = ''; | 588 var test = ''; |
547 main() {tes^t} | 589 main() {tes^t} |
548 '''); | 590 '''); |
549 return getSuggestions().then((_) { | 591 return getSuggestions().then((_) { |
550 expect(replacementOffset, equals(completionOffset - 3)); | 592 expect(replacementOffset, equals(completionOffset - 3)); |
551 expect(replacementLength, equals(4)); | 593 expect(replacementLength, equals(4)); |
552 // Suggestions based upon imported elements are partially filtered | 594 // Suggestions based upon imported elements are partially filtered |
553 //assertHasResult(CompletionSuggestionKind.INVOCATION, 'Object'); | 595 //assertHasResult(CompletionSuggestionKind.INVOCATION, 'Object'); |
554 assertHasResult(CompletionSuggestionKind.INVOCATION, 'test', | 596 assertHasResult(CompletionSuggestionKind.INVOCATION, 'test', |
555 DART_RELEVANCE_LOCAL_TOP_LEVEL_VARIABLE); | 597 relevance: DART_RELEVANCE_LOCAL_TOP_LEVEL_VARIABLE); |
556 assertNoResult('HtmlElement'); | 598 assertNoResult('HtmlElement'); |
557 }); | 599 }); |
558 } | 600 } |
559 } | 601 } |
560 | 602 |
561 class MockCache extends CompletionCache { | 603 class MockCache extends CompletionCache { |
562 MockCache(AnalysisContext context, Source source) : super(context, source); | 604 MockCache(AnalysisContext context, Source source) : super(context, source); |
563 } | 605 } |
564 | 606 |
565 class MockCompletionManager implements CompletionManager { | 607 class MockCompletionManager implements CompletionManager { |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
659 ++cancelCount; | 701 ++cancelCount; |
660 return new Future.value(true); | 702 return new Future.value(true); |
661 } | 703 } |
662 | 704 |
663 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 705 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
664 } | 706 } |
665 | 707 |
666 class Test_AnalysisServer extends AnalysisServer { | 708 class Test_AnalysisServer extends AnalysisServer { |
667 final MockContext mockContext = new MockContext(); | 709 final MockContext mockContext = new MockContext(); |
668 | 710 |
669 Test_AnalysisServer( | 711 Test_AnalysisServer(ServerCommunicationChannel channel, |
670 ServerCommunicationChannel channel, | |
671 ResourceProvider resourceProvider, | 712 ResourceProvider resourceProvider, |
672 PubPackageMapProvider packageMapProvider, | 713 PubPackageMapProvider packageMapProvider, Index index, |
673 Index index, | 714 ServerPlugin serverPlugin, AnalysisServerOptions analysisServerOptions, |
674 ServerPlugin serverPlugin, | 715 DartSdk defaultSdk, InstrumentationService instrumentationService) |
675 AnalysisServerOptions analysisServerOptions, | 716 : super(channel, resourceProvider, packageMapProvider, index, |
676 DartSdk defaultSdk, | 717 serverPlugin, analysisServerOptions, defaultSdk, |
677 InstrumentationService instrumentationService) | 718 instrumentationService); |
678 : super( | |
679 channel, | |
680 resourceProvider, | |
681 packageMapProvider, | |
682 index, | |
683 serverPlugin, | |
684 analysisServerOptions, | |
685 defaultSdk, | |
686 instrumentationService); | |
687 | 719 |
688 @override | 720 @override |
689 AnalysisContext getAnalysisContext(String path) { | 721 AnalysisContext getAnalysisContext(String path) { |
690 return mockContext; | 722 return mockContext; |
691 } | 723 } |
692 | 724 |
693 @override | 725 @override |
694 ContextSourcePair getContextSourcePair(String path) { | 726 ContextSourcePair getContextSourcePair(String path) { |
695 ContextSourcePair pair = super.getContextSourcePair(path); | 727 ContextSourcePair pair = super.getContextSourcePair(path); |
696 return new ContextSourcePair(mockContext, pair.source); | 728 return new ContextSourcePair(mockContext, pair.source); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
741 } | 773 } |
742 '''); | 774 '''); |
743 await waitForTasksFinished(); | 775 await waitForTasksFinished(); |
744 Request request = | 776 Request request = |
745 new CompletionGetSuggestionsParams(testFile, 0).toRequest('0'); | 777 new CompletionGetSuggestionsParams(testFile, 0).toRequest('0'); |
746 Response response = handler.handleRequest(request); | 778 Response response = handler.handleRequest(request); |
747 expect(response.error, isNotNull); | 779 expect(response.error, isNotNull); |
748 expect(response.error.code, RequestErrorCode.NO_INDEX_GENERATED); | 780 expect(response.error.code, RequestErrorCode.NO_INDEX_GENERATED); |
749 } | 781 } |
750 } | 782 } |
OLD | NEW |