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 import 'dart:async'; | 5 import 'dart:async'; |
6 | 6 |
7 import 'package:analysis_server/plugin/edit/assist/assist_core.dart'; | 7 import 'package:analysis_server/plugin/edit/assist/assist_core.dart'; |
8 import 'package:analysis_server/plugin/edit/assist/assist_dart.dart'; | 8 import 'package:analysis_server/plugin/edit/assist/assist_dart.dart'; |
9 import 'package:analysis_server/plugin/edit/fix/fix_core.dart'; | 9 import 'package:analysis_server/plugin/edit/fix/fix_core.dart'; |
10 import 'package:analysis_server/plugin/edit/fix/fix_dart.dart'; | 10 import 'package:analysis_server/plugin/edit/fix/fix_dart.dart'; |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 // | 393 // |
394 // Prepare the resolved unit. | 394 // Prepare the resolved unit. |
395 // | 395 // |
396 AnalysisResult result = await server.getAnalysisResult(params.file); | 396 AnalysisResult result = await server.getAnalysisResult(params.file); |
397 if (result == null) { | 397 if (result == null) { |
398 server.sendResponse(new Response.importElementsInvalidFile(request)); | 398 server.sendResponse(new Response.importElementsInvalidFile(request)); |
399 } | 399 } |
400 // | 400 // |
401 // Compute the edits required to import the required elements. | 401 // Compute the edits required to import the required elements. |
402 // | 402 // |
403 List<SourceEdit> edits = | 403 ImportElementsComputer computer = |
404 new ImportElementsComputer(result, params.file, params.elements) | 404 new ImportElementsComputer(server.resourceProvider, result); |
405 .compute(); | 405 SourceChange change = await computer.createEdits(params.elements); |
406 // | 406 // |
407 // Send the response. | 407 // Send the response. |
408 // | 408 // |
409 server.sendResponse( | 409 server.sendResponse(new EditImportElementsResult(change.edits[0].edits) |
410 new EditImportElementsResult(edits).toResponse(request.id)); | 410 .toResponse(request.id)); |
411 } | 411 } |
412 | 412 |
413 Future isPostfixCompletionApplicable(Request request) async { | 413 Future isPostfixCompletionApplicable(Request request) async { |
414 var params = new EditGetPostfixCompletionParams.fromRequest(request); | 414 var params = new EditGetPostfixCompletionParams.fromRequest(request); |
415 bool value = false; | 415 bool value = false; |
416 | 416 |
417 AnalysisResult result = await server.getAnalysisResult(params.file); | 417 AnalysisResult result = await server.getAnalysisResult(params.file); |
418 if (result != null) { | 418 if (result != null) { |
419 CompilationUnit unit = result.unit; | 419 CompilationUnit unit = result.unit; |
420 CompilationUnitElement unitElement = | 420 CompilationUnitElement unitElement = |
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1058 } | 1058 } |
1059 return new RefactoringStatus(); | 1059 return new RefactoringStatus(); |
1060 } | 1060 } |
1061 } | 1061 } |
1062 | 1062 |
1063 /** | 1063 /** |
1064 * [_RefactoringManager] throws instances of this class internally to stop | 1064 * [_RefactoringManager] throws instances of this class internally to stop |
1065 * processing in a manager that was reset. | 1065 * processing in a manager that was reset. |
1066 */ | 1066 */ |
1067 class _ResetError {} | 1067 class _ResetError {} |
OLD | NEW |