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

Side by Side Diff: pkg/analysis_server/lib/src/edit/edit_domain.dart

Issue 576473003: Split refactoring problems into init, options and final. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/analysis_server/doc/api.html ('k') | pkg/analysis_server/lib/src/generated_protocol.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 * An object managing a single [Refactoring] instance. 152 * An object managing a single [Refactoring] instance.
153 * 153 *
154 * The instance is identified by its kind, file, offset and length. 154 * The instance is identified by its kind, file, offset and length.
155 * It is initialized when the a set of parameters is given for the first time. 155 * It is initialized when the a set of parameters is given for the first time.
156 * All subsequent requests are performed on this [Refactoring] instance. 156 * All subsequent requests are performed on this [Refactoring] instance.
157 * 157 *
158 * Once new set of parameters is received, the previous [Refactoring] instance 158 * Once new set of parameters is received, the previous [Refactoring] instance
159 * is invalidated and a new one is created and initialized. 159 * is invalidated and a new one is created and initialized.
160 */ 160 */
161 class _RefactoringManager { 161 class _RefactoringManager {
162 static const List<RefactoringProblem> EMPTY_PROBLEM_LIST = const
163 <RefactoringProblem>[
164 ];
165
162 final AnalysisServer server; 166 final AnalysisServer server;
163 final SearchEngine searchEngine; 167 final SearchEngine searchEngine;
164 168
165 RefactoringKind kind; 169 RefactoringKind kind;
166 String file; 170 String file;
167 int offset; 171 int offset;
168 int length; 172 int length;
169 Refactoring refactoring; 173 Refactoring refactoring;
170 HasToJson feedback; 174 HasToJson feedback;
171 RefactoringStatus initStatus; 175 RefactoringStatus initStatus;
(...skipping 19 matching lines...) Expand all
191 bool get _requiresOptions { 195 bool get _requiresOptions {
192 if (refactoring is InlineLocalRefactoring) { 196 if (refactoring is InlineLocalRefactoring) {
193 return false; 197 return false;
194 } 198 }
195 return true; 199 return true;
196 } 200 }
197 201
198 void getRefactoring(Request request) { 202 void getRefactoring(Request request) {
199 // prepare for processing the request 203 // prepare for processing the request
200 requestId = request.id; 204 requestId = request.id;
201 result = new EditGetRefactoringResult(<RefactoringProblem>[]); 205 result = new EditGetRefactoringResult(
206 EMPTY_PROBLEM_LIST,
207 EMPTY_PROBLEM_LIST,
208 EMPTY_PROBLEM_LIST);
202 // process the request 209 // process the request
203 var params = new EditGetRefactoringParams.fromRequest(request); 210 var params = new EditGetRefactoringParams.fromRequest(request);
204 _init(params.kind, params.file, params.offset, params.length).then((_) { 211 _init(params.kind, params.file, params.offset, params.length).then((_) {
205 if (initStatus.hasFatalError) { 212 if (initStatus.hasFatalError) {
206 return _sendResultResponse(); 213 return _sendResultResponse();
207 } 214 }
208 // set options 215 // set options
209 if (_requiresOptions) { 216 if (_requiresOptions) {
210 if (params.options == null) { 217 if (params.options == null) {
211 optionsStatus = new RefactoringStatus(); 218 optionsStatus = new RefactoringStatus();
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 initStatus = new RefactoringStatus(); 361 initStatus = new RefactoringStatus();
355 optionsStatus = new RefactoringStatus(); 362 optionsStatus = new RefactoringStatus();
356 finalStatus = new RefactoringStatus(); 363 finalStatus = new RefactoringStatus();
357 } 364 }
358 365
359 void _sendResultResponse() { 366 void _sendResultResponse() {
360 if (feedback != null) { 367 if (feedback != null) {
361 result.feedback = feedback; 368 result.feedback = feedback;
362 } 369 }
363 // set problems 370 // set problems
364 { 371 result.initialProblems = initStatus.problems;
365 RefactoringStatus status = new RefactoringStatus(); 372 result.optionsProblems = optionsStatus.problems;
366 status.addStatus(initStatus); 373 result.finalProblems = finalStatus.problems;
367 status.addStatus(optionsStatus);
368 status.addStatus(finalStatus);
369 result.problems = status.problems;
370 }
371 // send the response 374 // send the response
372 server.sendResponse(result.toResponse(requestId)); 375 server.sendResponse(result.toResponse(requestId));
373 // done with this request 376 // done with this request
374 requestId = null; 377 requestId = null;
375 result = null; 378 result = null;
376 } 379 }
377 380
378 RefactoringStatus _setOptions(EditGetRefactoringParams params) { 381 RefactoringStatus _setOptions(EditGetRefactoringParams params) {
379 if (refactoring is ExtractLocalRefactoring) { 382 if (refactoring is ExtractLocalRefactoring) {
380 ExtractLocalRefactoring extractRefactoring = refactoring; 383 ExtractLocalRefactoring extractRefactoring = refactoring;
(...skipping 23 matching lines...) Expand all
404 } 407 }
405 if (refactoring is RenameRefactoring) { 408 if (refactoring is RenameRefactoring) {
406 RenameRefactoring renameRefactoring = refactoring; 409 RenameRefactoring renameRefactoring = refactoring;
407 RenameOptions renameOptions = params.options; 410 RenameOptions renameOptions = params.options;
408 renameRefactoring.newName = renameOptions.newName; 411 renameRefactoring.newName = renameOptions.newName;
409 return renameRefactoring.checkNewName(); 412 return renameRefactoring.checkNewName();
410 } 413 }
411 return new RefactoringStatus(); 414 return new RefactoringStatus();
412 } 415 }
413 } 416 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/doc/api.html ('k') | pkg/analysis_server/lib/src/generated_protocol.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698