Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Unified Diff: pkg/analysis_server/lib/src/edit/edit_domain.dart

Issue 1281983002: Check for reset during 'await' in refactoring manager. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analysis_server/test/edit/refactoring_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 {}
« no previous file with comments | « no previous file | pkg/analysis_server/test/edit/refactoring_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698