| Index: pkg/analysis_server/lib/src/edit/edit_domain.dart
|
| diff --git a/pkg/analysis_server/lib/src/edit/edit_domain.dart b/pkg/analysis_server/lib/src/edit/edit_domain.dart
|
| index 3213537a6c4fa338dbed956c171fc1056262927c..fa0f8497469537cbe3cbdae0ab624e4c682d959f 100644
|
| --- a/pkg/analysis_server/lib/src/edit/edit_domain.dart
|
| +++ b/pkg/analysis_server/lib/src/edit/edit_domain.dart
|
| @@ -32,6 +32,10 @@ bool test_simulateRefactoringException_change = false;
|
| bool test_simulateRefactoringException_final = false;
|
| bool test_simulateRefactoringException_init = false;
|
|
|
| +bool test_simulateRefactoringReset_afterCreateChange = false;
|
| +bool test_simulateRefactoringReset_afterFinalConditions = false;
|
| +bool test_simulateRefactoringReset_afterInitialConditions = false;
|
| +
|
| /**
|
| * Instances of the class [EditDomainHandler] implement a [RequestHandler]
|
| * that handles requests in the edit domain.
|
| @@ -452,6 +456,7 @@ class _RefactoringManager {
|
| }
|
| // validation and create change
|
| finalStatus = await refactoring.checkFinalConditions();
|
| + _checkForReset_afterFinalConditions();
|
| if (_hasFatalError) {
|
| _sendResultResponse();
|
| return;
|
| @@ -463,15 +468,47 @@ class _RefactoringManager {
|
| // create change
|
| result.change = await refactoring.createChange();
|
| result.potentialEdits = nullIfEmpty(refactoring.potentialEditIds);
|
| + _checkForReset_afterCreateChange();
|
| _sendResultResponse();
|
| }, onError: (exception, stackTrace) {
|
| - server.instrumentationService.logException(exception, stackTrace);
|
| - server.sendResponse(
|
| - new Response.serverError(_request, exception, stackTrace));
|
| + if (exception is _ResetError) {
|
| + cancel();
|
| + } else {
|
| + server.instrumentationService.logException(exception, stackTrace);
|
| + server.sendResponse(
|
| + new Response.serverError(_request, exception, stackTrace));
|
| + }
|
| _reset();
|
| });
|
| }
|
|
|
| + void _checkForReset_afterCreateChange() {
|
| + if (test_simulateRefactoringReset_afterCreateChange) {
|
| + _reset();
|
| + }
|
| + if (refactoring == null) {
|
| + throw new _ResetError();
|
| + }
|
| + }
|
| +
|
| + void _checkForReset_afterFinalConditions() {
|
| + if (test_simulateRefactoringReset_afterFinalConditions) {
|
| + _reset();
|
| + }
|
| + if (refactoring == null) {
|
| + throw new _ResetError();
|
| + }
|
| + }
|
| +
|
| + void _checkForReset_afterInitialConditions() {
|
| + if (test_simulateRefactoringReset_afterInitialConditions) {
|
| + _reset();
|
| + }
|
| + if (refactoring == null) {
|
| + throw new _ResetError();
|
| + }
|
| + }
|
| +
|
| /**
|
| * Initializes this context to perform a refactoring with the specified
|
| * parameters. The existing [Refactoring] is reused or created as needed.
|
| @@ -581,6 +618,7 @@ class _RefactoringManager {
|
| }
|
| // check initial conditions
|
| initStatus = await refactoring.checkInitialConditions();
|
| + _checkForReset_afterInitialConditions();
|
| if (refactoring is ExtractLocalRefactoring) {
|
| ExtractLocalRefactoring refactoring = this.refactoring;
|
| ExtractLocalVariableFeedback feedback = this.feedback;
|
| @@ -692,3 +730,9 @@ class _RefactoringManager {
|
| return new RefactoringStatus();
|
| }
|
| }
|
| +
|
| +/**
|
| + * [_RefactoringManager] throws instances of this class internally to stop
|
| + * processing in a manager that was reset.
|
| + */
|
| +class _ResetError {}
|
|
|