| 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 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 } | 250 } |
| 251 if (kind == RefactoringKind.EXTRACT_METHOD) { | 251 if (kind == RefactoringKind.EXTRACT_METHOD) { |
| 252 List<CompilationUnit> units = server.getResolvedCompilationUnits(file); | 252 List<CompilationUnit> units = server.getResolvedCompilationUnits(file); |
| 253 if (units.isNotEmpty) { | 253 if (units.isNotEmpty) { |
| 254 refactoring = | 254 refactoring = |
| 255 new ExtractMethodRefactoring(searchEngine, units[0], offset, length)
; | 255 new ExtractMethodRefactoring(searchEngine, units[0], offset, length)
; |
| 256 feedback = | 256 feedback = |
| 257 new ExtractMethodFeedback(offset, length, null, [], false, [], [], [
]); | 257 new ExtractMethodFeedback(offset, length, null, [], false, [], [], [
]); |
| 258 } | 258 } |
| 259 } | 259 } |
| 260 if (kind == RefactoringKind.INLINE_METHOD) { |
| 261 List<CompilationUnit> units = server.getResolvedCompilationUnits(file); |
| 262 if (units.isNotEmpty) { |
| 263 refactoring = new InlineMethodRefactoring(searchEngine, units[0], offset
); |
| 264 } |
| 265 } |
| 260 if (kind == RefactoringKind.RENAME) { | 266 if (kind == RefactoringKind.RENAME) { |
| 261 List<AstNode> nodes = server.getNodesAtOffset(file, offset); | 267 List<AstNode> nodes = server.getNodesAtOffset(file, offset); |
| 262 List<Element> elements = server.getElementsAtOffset(file, offset); | 268 List<Element> elements = server.getElementsAtOffset(file, offset); |
| 263 if (nodes.isNotEmpty && elements.isNotEmpty) { | 269 if (nodes.isNotEmpty && elements.isNotEmpty) { |
| 264 AstNode node = nodes[0]; | 270 AstNode node = nodes[0]; |
| 265 Element element = elements[0]; | 271 Element element = elements[0]; |
| 266 refactoring = new RenameRefactoring(searchEngine, element); | 272 refactoring = new RenameRefactoring(searchEngine, element); |
| 267 feedback = new RenameFeedback(node.offset, node.length); | 273 feedback = new RenameFeedback(node.offset, node.length); |
| 268 } | 274 } |
| 269 } | 275 } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 298 | 304 |
| 299 void _reset() { | 305 void _reset() { |
| 300 refactoring = null; | 306 refactoring = null; |
| 301 feedback = null; | 307 feedback = null; |
| 302 initStatus = new RefactoringStatus(); | 308 initStatus = new RefactoringStatus(); |
| 303 optionsStatus = new RefactoringStatus(); | 309 optionsStatus = new RefactoringStatus(); |
| 304 finalStatus = new RefactoringStatus(); | 310 finalStatus = new RefactoringStatus(); |
| 305 } | 311 } |
| 306 | 312 |
| 307 void _sendResultResponse() { | 313 void _sendResultResponse() { |
| 308 result.feedback = feedback.toJson(); | 314 if (feedback != null) { |
| 315 result.feedback = feedback.toJson(); |
| 316 } |
| 309 // set problems | 317 // set problems |
| 310 { | 318 { |
| 311 RefactoringStatus status = new RefactoringStatus(); | 319 RefactoringStatus status = new RefactoringStatus(); |
| 312 status.addStatus(initStatus); | 320 status.addStatus(initStatus); |
| 313 status.addStatus(optionsStatus); | 321 status.addStatus(optionsStatus); |
| 314 status.addStatus(finalStatus); | 322 status.addStatus(finalStatus); |
| 315 result.problems = status.problems; | 323 result.problems = status.problems; |
| 316 } | 324 } |
| 317 // send the response | 325 // send the response |
| 318 server.sendResponse(result.toResponse(requestId)); | 326 server.sendResponse(result.toResponse(requestId)); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 337 new ExtractMethodOptions.fromRefactoringParams(params, request); | 345 new ExtractMethodOptions.fromRefactoringParams(params, request); |
| 338 extractRefactoring.createGetter = extractOptions.createGetter; | 346 extractRefactoring.createGetter = extractOptions.createGetter; |
| 339 extractRefactoring.extractAll = extractOptions.extractAll; | 347 extractRefactoring.extractAll = extractOptions.extractAll; |
| 340 extractRefactoring.name = extractOptions.name; | 348 extractRefactoring.name = extractOptions.name; |
| 341 if (extractOptions.parameters != null) { | 349 if (extractOptions.parameters != null) { |
| 342 extractRefactoring.parameters = extractOptions.parameters; | 350 extractRefactoring.parameters = extractOptions.parameters; |
| 343 } | 351 } |
| 344 extractRefactoring.returnType = extractOptions.returnType; | 352 extractRefactoring.returnType = extractOptions.returnType; |
| 345 return extractRefactoring.checkName(); | 353 return extractRefactoring.checkName(); |
| 346 } | 354 } |
| 355 if (refactoring is InlineMethodRefactoring) { |
| 356 InlineMethodRefactoring inlineRefactoring = this.refactoring; |
| 357 InlineMethodOptions inlineOptions = |
| 358 new InlineMethodOptions.fromRefactoringParams(params, request); |
| 359 inlineRefactoring.deleteSource = inlineOptions.deleteSource; |
| 360 inlineRefactoring.inlineAll = inlineOptions.inlineAll; |
| 361 return new RefactoringStatus(); |
| 362 } |
| 347 if (refactoring is RenameRefactoring) { | 363 if (refactoring is RenameRefactoring) { |
| 348 RenameRefactoring renameRefactoring = refactoring; | 364 RenameRefactoring renameRefactoring = refactoring; |
| 349 RenameOptions renameOptions = | 365 RenameOptions renameOptions = |
| 350 new RenameOptions.fromRefactoringParams(params, request); | 366 new RenameOptions.fromRefactoringParams(params, request); |
| 351 renameRefactoring.newName = renameOptions.newName; | 367 renameRefactoring.newName = renameOptions.newName; |
| 352 return renameRefactoring.checkNewName(); | 368 return renameRefactoring.checkNewName(); |
| 353 } | 369 } |
| 354 return new RefactoringStatus(); | 370 return new RefactoringStatus(); |
| 355 } | 371 } |
| 356 } | 372 } |
| OLD | NEW |