| 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/src/analysis_server.dart'; | 9 import 'package:analysis_server/src/analysis_server.dart'; |
| 10 import 'package:analysis_server/src/constants.dart'; | 10 import 'package:analysis_server/src/constants.dart'; |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 var params = new EditGetRefactoringParams.fromRequest(request); | 203 var params = new EditGetRefactoringParams.fromRequest(request); |
| 204 _init(params.kind, params.file, params.offset, params.length).then((_) { | 204 _init(params.kind, params.file, params.offset, params.length).then((_) { |
| 205 if (_hasFatalError) { | 205 if (_hasFatalError) { |
| 206 return _sendResultResponse(); | 206 return _sendResultResponse(); |
| 207 } | 207 } |
| 208 // set options | 208 // set options |
| 209 if (_requiresOptions) { | 209 if (_requiresOptions) { |
| 210 if (params.options == null) { | 210 if (params.options == null) { |
| 211 return _sendResultResponse(); | 211 return _sendResultResponse(); |
| 212 } | 212 } |
| 213 optionsStatus = _setOptions(params, request); | 213 optionsStatus = _setOptions(params); |
| 214 if (_hasFatalError) { | 214 if (_hasFatalError) { |
| 215 return _sendResultResponse(); | 215 return _sendResultResponse(); |
| 216 } | 216 } |
| 217 } | 217 } |
| 218 // done if just validation | 218 // done if just validation |
| 219 if (params.validateOnly) { | 219 if (params.validateOnly) { |
| 220 return _sendResultResponse(); | 220 return _sendResultResponse(); |
| 221 } | 221 } |
| 222 // validation and create change | 222 // validation and create change |
| 223 refactoring.checkFinalConditions().then((_finalStatus) { | 223 refactoring.checkFinalConditions().then((_finalStatus) { |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 status.addStatus(finalStatus); | 342 status.addStatus(finalStatus); |
| 343 result.problems = status.problems; | 343 result.problems = status.problems; |
| 344 } | 344 } |
| 345 // send the response | 345 // send the response |
| 346 server.sendResponse(result.toResponse(requestId)); | 346 server.sendResponse(result.toResponse(requestId)); |
| 347 // done with this request | 347 // done with this request |
| 348 requestId = null; | 348 requestId = null; |
| 349 result = null; | 349 result = null; |
| 350 } | 350 } |
| 351 | 351 |
| 352 RefactoringStatus _setOptions(EditGetRefactoringParams params, | 352 RefactoringStatus _setOptions(EditGetRefactoringParams params) { |
| 353 Request request) { | |
| 354 if (refactoring is ExtractLocalRefactoring) { | 353 if (refactoring is ExtractLocalRefactoring) { |
| 355 ExtractLocalRefactoring extractRefactoring = refactoring; | 354 ExtractLocalRefactoring extractRefactoring = refactoring; |
| 356 ExtractLocalVariableOptions extractOptions = | 355 ExtractLocalVariableOptions extractOptions = params.options; |
| 357 new ExtractLocalVariableOptions.fromRefactoringParams(params, request)
; | |
| 358 extractRefactoring.name = extractOptions.name; | 356 extractRefactoring.name = extractOptions.name; |
| 359 extractRefactoring.extractAll = extractOptions.extractAll; | 357 extractRefactoring.extractAll = extractOptions.extractAll; |
| 360 return extractRefactoring.checkName(); | 358 return extractRefactoring.checkName(); |
| 361 } | 359 } |
| 362 if (refactoring is ExtractMethodRefactoring) { | 360 if (refactoring is ExtractMethodRefactoring) { |
| 363 ExtractMethodRefactoring extractRefactoring = this.refactoring; | 361 ExtractMethodRefactoring extractRefactoring = this.refactoring; |
| 364 ExtractMethodOptions extractOptions = | 362 ExtractMethodOptions extractOptions = params.options; |
| 365 new ExtractMethodOptions.fromRefactoringParams(params, request); | |
| 366 extractRefactoring.createGetter = extractOptions.createGetter; | 363 extractRefactoring.createGetter = extractOptions.createGetter; |
| 367 extractRefactoring.extractAll = extractOptions.extractAll; | 364 extractRefactoring.extractAll = extractOptions.extractAll; |
| 368 extractRefactoring.name = extractOptions.name; | 365 extractRefactoring.name = extractOptions.name; |
| 369 if (extractOptions.parameters != null) { | 366 if (extractOptions.parameters != null) { |
| 370 extractRefactoring.parameters = extractOptions.parameters; | 367 extractRefactoring.parameters = extractOptions.parameters; |
| 371 } | 368 } |
| 372 extractRefactoring.returnType = extractOptions.returnType; | 369 extractRefactoring.returnType = extractOptions.returnType; |
| 373 return extractRefactoring.checkName(); | 370 return extractRefactoring.checkName(); |
| 374 } | 371 } |
| 375 if (refactoring is InlineLocalRefactoring) { | |
| 376 return new RefactoringStatus(); | |
| 377 } | |
| 378 if (refactoring is InlineMethodRefactoring) { | 372 if (refactoring is InlineMethodRefactoring) { |
| 379 InlineMethodRefactoring inlineRefactoring = this.refactoring; | 373 InlineMethodRefactoring inlineRefactoring = this.refactoring; |
| 380 InlineMethodOptions inlineOptions = | 374 InlineMethodOptions inlineOptions = params.options; |
| 381 new InlineMethodOptions.fromRefactoringParams(params, request); | |
| 382 inlineRefactoring.deleteSource = inlineOptions.deleteSource; | 375 inlineRefactoring.deleteSource = inlineOptions.deleteSource; |
| 383 inlineRefactoring.inlineAll = inlineOptions.inlineAll; | 376 inlineRefactoring.inlineAll = inlineOptions.inlineAll; |
| 384 return new RefactoringStatus(); | 377 return new RefactoringStatus(); |
| 385 } | 378 } |
| 386 if (refactoring is RenameRefactoring) { | 379 if (refactoring is RenameRefactoring) { |
| 387 RenameRefactoring renameRefactoring = refactoring; | 380 RenameRefactoring renameRefactoring = refactoring; |
| 388 RenameOptions renameOptions = | 381 RenameOptions renameOptions = params.options; |
| 389 new RenameOptions.fromRefactoringParams(params, request); | |
| 390 renameRefactoring.newName = renameOptions.newName; | 382 renameRefactoring.newName = renameOptions.newName; |
| 391 return renameRefactoring.checkNewName(); | 383 return renameRefactoring.checkNewName(); |
| 392 } | 384 } |
| 393 return new RefactoringStatus(); | 385 return new RefactoringStatus(); |
| 394 } | 386 } |
| 395 } | 387 } |
| OLD | NEW |