| 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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 Refactoring refactoring; | 173 Refactoring refactoring; |
| 174 HasToJson feedback; | 174 HasToJson feedback; |
| 175 RefactoringStatus initStatus; | 175 RefactoringStatus initStatus; |
| 176 RefactoringStatus optionsStatus; | 176 RefactoringStatus optionsStatus; |
| 177 RefactoringStatus finalStatus; | 177 RefactoringStatus finalStatus; |
| 178 | 178 |
| 179 String requestId; | 179 String requestId; |
| 180 EditGetRefactoringResult result; | 180 EditGetRefactoringResult result; |
| 181 | 181 |
| 182 _RefactoringManager(this.server, this.searchEngine) { | 182 _RefactoringManager(this.server, this.searchEngine) { |
| 183 server.addAnalysisServerListener( |
| 184 new _ResetRefactoringManagerAnalysisServerListener(this)); |
| 183 _reset(); | 185 _reset(); |
| 184 } | 186 } |
| 185 | 187 |
| 186 bool get _hasFatalError { | 188 bool get _hasFatalError { |
| 187 return initStatus.hasFatalError || | 189 return initStatus.hasFatalError || |
| 188 optionsStatus.hasFatalError || | 190 optionsStatus.hasFatalError || |
| 189 finalStatus.hasFatalError; | 191 finalStatus.hasFatalError; |
| 190 } | 192 } |
| 191 | 193 |
| 192 /** | 194 /** |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 RenameRefactoring refactoring = this.refactoring; | 357 RenameRefactoring refactoring = this.refactoring; |
| 356 RenameFeedback feedback = this.feedback; | 358 RenameFeedback feedback = this.feedback; |
| 357 feedback.elementKindName = refactoring.elementKindName; | 359 feedback.elementKindName = refactoring.elementKindName; |
| 358 feedback.oldName = refactoring.oldName; | 360 feedback.oldName = refactoring.oldName; |
| 359 } | 361 } |
| 360 return initStatus; | 362 return initStatus; |
| 361 }); | 363 }); |
| 362 } | 364 } |
| 363 | 365 |
| 364 void _reset() { | 366 void _reset() { |
| 367 kind = null; |
| 368 offset = null; |
| 369 length = null; |
| 365 refactoring = null; | 370 refactoring = null; |
| 366 feedback = null; | 371 feedback = null; |
| 367 initStatus = new RefactoringStatus(); | 372 initStatus = new RefactoringStatus(); |
| 368 optionsStatus = new RefactoringStatus(); | 373 optionsStatus = new RefactoringStatus(); |
| 369 finalStatus = new RefactoringStatus(); | 374 finalStatus = new RefactoringStatus(); |
| 370 } | 375 } |
| 371 | 376 |
| 372 void _sendResultResponse() { | 377 void _sendResultResponse() { |
| 373 if (feedback != null) { | 378 if (feedback != null) { |
| 374 result.feedback = feedback; | 379 result.feedback = feedback; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 } | 424 } |
| 420 if (refactoring is RenameRefactoring) { | 425 if (refactoring is RenameRefactoring) { |
| 421 RenameRefactoring renameRefactoring = refactoring; | 426 RenameRefactoring renameRefactoring = refactoring; |
| 422 RenameOptions renameOptions = params.options; | 427 RenameOptions renameOptions = params.options; |
| 423 renameRefactoring.newName = renameOptions.newName; | 428 renameRefactoring.newName = renameOptions.newName; |
| 424 return renameRefactoring.checkNewName(); | 429 return renameRefactoring.checkNewName(); |
| 425 } | 430 } |
| 426 return new RefactoringStatus(); | 431 return new RefactoringStatus(); |
| 427 } | 432 } |
| 428 } | 433 } |
| 434 |
| 435 |
| 436 /** |
| 437 * A [AnalysisServerListener] that resets [_RefactoringManager] when analysis |
| 438 * is started in the [AnalysisServer]. |
| 439 */ |
| 440 class _ResetRefactoringManagerAnalysisServerListener implements |
| 441 AnalysisServerListener { |
| 442 final _RefactoringManager refactoringManager; |
| 443 |
| 444 _ResetRefactoringManagerAnalysisServerListener(this.refactoringManager); |
| 445 |
| 446 @override |
| 447 void analysisComplete() { |
| 448 } |
| 449 |
| 450 @override |
| 451 void analysisStarted(engine.AnalysisContext context) { |
| 452 refactoringManager._reset(); |
| 453 } |
| 454 } |
| OLD | NEW |