| 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.analysis_server; | 5 library test.analysis_server; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/plugin/protocol/protocol.dart'; | 9 import 'package:analysis_server/plugin/protocol/protocol.dart'; |
| 10 import 'package:analysis_server/src/analysis_server.dart'; | 10 import 'package:analysis_server/src/analysis_server.dart'; |
| (...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 | 477 |
| 478 Future test_unknownRequest() { | 478 Future test_unknownRequest() { |
| 479 server.handlers = [new EchoHandler()]; | 479 server.handlers = [new EchoHandler()]; |
| 480 var request = new Request('my22', 'randomRequest'); | 480 var request = new Request('my22', 'randomRequest'); |
| 481 return channel.sendRequest(request).then((Response response) { | 481 return channel.sendRequest(request).then((Response response) { |
| 482 expect(response.id, equals('my22')); | 482 expect(response.id, equals('my22')); |
| 483 expect(response.error, isNotNull); | 483 expect(response.error, isNotNull); |
| 484 }); | 484 }); |
| 485 } | 485 } |
| 486 | 486 |
| 487 test_watch_modifyFile_hasOverlay() async { |
| 488 server.serverServices.add(ServerService.STATUS); |
| 489 // configure the project |
| 490 String projectPath = '/root'; |
| 491 String filePath = '/root/test.dart'; |
| 492 resourceProvider.newFolder(projectPath); |
| 493 resourceProvider.newFile(filePath, '// 111'); |
| 494 server.setAnalysisRoots('0', ['/root'], [], {}); |
| 495 await pumpEventQueue(); |
| 496 // add overlay |
| 497 server.updateContent('1', {filePath: new AddContentOverlay('// 222')}); |
| 498 await pumpEventQueue(); |
| 499 // update the file |
| 500 channel.notificationsReceived.clear(); |
| 501 resourceProvider.modifyFile(filePath, '// 333'); |
| 502 await pumpEventQueue(); |
| 503 // the file has an overlay, so the file-system change was ignored |
| 504 expect(channel.notificationsReceived.any((notification) { |
| 505 return notification.event == SERVER_STATUS; |
| 506 }), isFalse); |
| 507 } |
| 508 |
| 487 void _configureSourceFactory(AnalysisContext context) { | 509 void _configureSourceFactory(AnalysisContext context) { |
| 488 var resourceUriResolver = new ResourceUriResolver(resourceProvider); | 510 var resourceUriResolver = new ResourceUriResolver(resourceProvider); |
| 489 var packageUriResolver = new PackageMapUriResolver( | 511 var packageUriResolver = new PackageMapUriResolver( |
| 490 resourceProvider, packageMapProvider.packageMap); | 512 resourceProvider, packageMapProvider.packageMap); |
| 491 context.sourceFactory = | 513 context.sourceFactory = |
| 492 new SourceFactory([packageUriResolver, resourceUriResolver]); | 514 new SourceFactory([packageUriResolver, resourceUriResolver]); |
| 493 } | 515 } |
| 494 } | 516 } |
| 495 | 517 |
| 496 class EchoHandler implements RequestHandler { | 518 class EchoHandler implements RequestHandler { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 514 _MockServerOperation(this.context); | 536 _MockServerOperation(this.context); |
| 515 | 537 |
| 516 @override | 538 @override |
| 517 ServerOperationPriority get priority => ServerOperationPriority.ANALYSIS; | 539 ServerOperationPriority get priority => ServerOperationPriority.ANALYSIS; |
| 518 | 540 |
| 519 @override | 541 @override |
| 520 void perform(AnalysisServer server) { | 542 void perform(AnalysisServer server) { |
| 521 isComplete = true; | 543 isComplete = true; |
| 522 } | 544 } |
| 523 } | 545 } |
| OLD | NEW |