| 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 edit.domain; | 5 library edit.domain; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/plugin/edit/assist/assist_core.dart'; | 9 import 'package:analysis_server/plugin/edit/assist/assist_core.dart'; |
| 10 import 'package:analysis_server/plugin/edit/fix/fix_core.dart'; | 10 import 'package:analysis_server/plugin/edit/fix/fix_core.dart'; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 _newRefactoringManager(); | 65 _newRefactoringManager(); |
| 66 } | 66 } |
| 67 | 67 |
| 68 Response format(Request request) { | 68 Response format(Request request) { |
| 69 EditFormatParams params = new EditFormatParams.fromRequest(request); | 69 EditFormatParams params = new EditFormatParams.fromRequest(request); |
| 70 String file = params.file; | 70 String file = params.file; |
| 71 | 71 |
| 72 String unformattedSource; | 72 String unformattedSource; |
| 73 try { | 73 try { |
| 74 Source source = server.resourceProvider.getFile(file).createSource(); | 74 Source source = server.resourceProvider.getFile(file).createSource(); |
| 75 unformattedSource = server.overlayState.getContents(source); | 75 if (server.options.enableNewAnalysisDriver) { |
| 76 unformattedSource = server.fileContentOverlay[file]; |
| 77 } else { |
| 78 unformattedSource = server.overlayState.getContents(source); |
| 79 } |
| 76 unformattedSource ??= source.contents.data; | 80 unformattedSource ??= source.contents.data; |
| 77 } catch (e) { | 81 } catch (e) { |
| 78 return new Response.formatInvalidFile(request); | 82 return new Response.formatInvalidFile(request); |
| 79 } | 83 } |
| 80 | 84 |
| 81 int start = params.selectionOffset; | 85 int start = params.selectionOffset; |
| 82 int length = params.selectionLength; | 86 int length = params.selectionLength; |
| 83 | 87 |
| 84 // No need to preserve 0,0 selection | 88 // No need to preserve 0,0 selection |
| 85 if (start == 0 && length == 0) { | 89 if (start == 0 && length == 0) { |
| (...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 806 } | 810 } |
| 807 return new RefactoringStatus(); | 811 return new RefactoringStatus(); |
| 808 } | 812 } |
| 809 } | 813 } |
| 810 | 814 |
| 811 /** | 815 /** |
| 812 * [_RefactoringManager] throws instances of this class internally to stop | 816 * [_RefactoringManager] throws instances of this class internally to stop |
| 813 * processing in a manager that was reset. | 817 * processing in a manager that was reset. |
| 814 */ | 818 */ |
| 815 class _ResetError {} | 819 class _ResetError {} |
| OLD | NEW |