Chromium Code Reviews| 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 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 390 Future<Null> importElements(Request request) async { | 390 Future<Null> importElements(Request request) async { |
| 391 EditImportElementsParams params = | 391 EditImportElementsParams params = |
| 392 new EditImportElementsParams.fromRequest(request); | 392 new EditImportElementsParams.fromRequest(request); |
| 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 CompilationUnitElement libraryUnit = | |
| 401 result.libraryElement.definingCompilationUnit; | |
| 402 if (libraryUnit != result.unit.element) { | |
| 403 // The file in the request is a part of a library. We need to pass the | |
|
devoncarew
2017/08/15 21:59:30
Just so I understand, if you pass a part into `edi
Brian Wilkerson
2017/08/15 23:32:33
No. If the client passes a part into `edit.importE
| |
| 404 // defining compilation unit to the computer, not the part. | |
| 405 result = await server.getAnalysisResult(libraryUnit.source.fullName); | |
| 406 if (result == null) { | |
| 407 server.sendResponse(new Response.importElementsInvalidFile(request)); | |
| 408 } | |
| 409 } | |
| 400 // | 410 // |
| 401 // Compute the edits required to import the required elements. | 411 // Compute the edits required to import the required elements. |
| 402 // | 412 // |
| 403 ImportElementsComputer computer = | 413 ImportElementsComputer computer = |
| 404 new ImportElementsComputer(server.resourceProvider, result); | 414 new ImportElementsComputer(server.resourceProvider, result); |
| 405 SourceChange change = await computer.createEdits(params.elements); | 415 SourceChange change = await computer.createEdits(params.elements); |
| 406 // | 416 // |
| 407 // Send the response. | 417 // Send the response. |
| 408 // | 418 // |
| 409 server.sendResponse( | 419 server.sendResponse( |
| (...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1058 } | 1068 } |
| 1059 return new RefactoringStatus(); | 1069 return new RefactoringStatus(); |
| 1060 } | 1070 } |
| 1061 } | 1071 } |
| 1062 | 1072 |
| 1063 /** | 1073 /** |
| 1064 * [_RefactoringManager] throws instances of this class internally to stop | 1074 * [_RefactoringManager] throws instances of this class internally to stop |
| 1065 * processing in a manager that was reset. | 1075 * processing in a manager that was reset. |
| 1066 */ | 1076 */ |
| 1067 class _ResetError {} | 1077 class _ResetError {} |
| OLD | NEW |