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.edit.refactoring; | 5 library test.edit.refactoring; |
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/edit/edit_domain.dart'; | 10 import 'package:analysis_server/src/edit/edit_domain.dart'; |
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
646 // end | 646 // end |
647 res(a, b); | 647 res(a, b); |
648 } | 648 } |
649 | 649 |
650 void res(int a, int b) { | 650 void res(int a, int b) { |
651 print(a + b); | 651 print(a + b); |
652 } | 652 } |
653 '''); | 653 '''); |
654 } | 654 } |
655 | 655 |
656 Future<Response> _computeChange() { | 656 Future<Response> _computeChange() async { |
657 return _prepareOptions().then((_) { | 657 await _prepareOptions(); |
658 // send request with the options | 658 // send request with the options |
659 return _sendExtractRequest(); | 659 return _sendExtractRequest(); |
660 }); | |
661 } | 660 } |
662 | 661 |
663 Future<ExtractMethodFeedback> _computeInitialFeedback() { | 662 Future<ExtractMethodFeedback> _computeInitialFeedback() { |
664 return waitForTasksFinished().then((_) { | 663 return waitForTasksFinished().then((_) { |
665 return _sendExtractRequest(); | 664 return _sendExtractRequest(); |
666 }).then((Response response) { | 665 }).then((Response response) { |
667 var result = new EditGetRefactoringResult.fromResponse(response); | 666 var result = new EditGetRefactoringResult.fromResponse(response); |
668 return result.feedback; | 667 return result.feedback; |
669 }); | 668 }); |
670 } | 669 } |
(...skipping 1189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1860 } | 1859 } |
1861 fail('No SourceFileEdit for $testFile in $change'); | 1860 fail('No SourceFileEdit for $testFile in $change'); |
1862 } | 1861 } |
1863 | 1862 |
1864 @override | 1863 @override |
1865 Index createIndex() { | 1864 Index createIndex() { |
1866 return createMemoryIndex(); | 1865 return createMemoryIndex(); |
1867 } | 1866 } |
1868 | 1867 |
1869 Future<EditGetRefactoringResult> getRefactoringResult( | 1868 Future<EditGetRefactoringResult> getRefactoringResult( |
1870 Future<Response> requestSender()) { | 1869 Future<Response> requestSender()) async { |
1871 return waitForTasksFinished().then((_) { | 1870 await waitForTasksFinished(); |
1872 return requestSender().then((Response response) { | 1871 Response response = await requestSender(); |
1873 return new EditGetRefactoringResult.fromResponse(response); | 1872 return new EditGetRefactoringResult.fromResponse(response); |
1874 }); | |
1875 }); | |
1876 } | 1873 } |
1877 | 1874 |
1878 Future<Response> sendRequest( | 1875 Future<Response> sendRequest( |
1879 RefactoringKind kind, int offset, int length, RefactoringOptions options, | 1876 RefactoringKind kind, int offset, int length, RefactoringOptions options, |
1880 [bool validateOnly = false]) { | 1877 [bool validateOnly = false]) { |
1881 Request request = new EditGetRefactoringParams( | 1878 Request request = new EditGetRefactoringParams( |
1882 kind, testFile, offset, length, validateOnly, | 1879 kind, testFile, offset, length, validateOnly, |
1883 options: options) | 1880 options: options) |
1884 .toRequest('0'); | 1881 .toRequest('0'); |
1885 return serverChannel.sendRequest(request); | 1882 return serverChannel.sendRequest(request); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1927 .toRequest('0'); | 1924 .toRequest('0'); |
1928 return _assertErrorResponseNoIndex(request); | 1925 return _assertErrorResponseNoIndex(request); |
1929 } | 1926 } |
1930 | 1927 |
1931 _assertErrorResponseNoIndex(Request request) async { | 1928 _assertErrorResponseNoIndex(Request request) async { |
1932 Response response = await serverChannel.sendRequest(request); | 1929 Response response = await serverChannel.sendRequest(request); |
1933 expect(response.error, isNotNull); | 1930 expect(response.error, isNotNull); |
1934 expect(response.error.code, RequestErrorCode.NO_INDEX_GENERATED); | 1931 expect(response.error.code, RequestErrorCode.NO_INDEX_GENERATED); |
1935 } | 1932 } |
1936 } | 1933 } |
OLD | NEW |