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

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

Issue 540503002: Integrate INLINE_LOCAL_VARIABLE into the server. (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 | « no previous file | pkg/analysis_server/test/edit/refactoring_test.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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 _RefactoringManager(this.server, this.searchEngine) { 178 _RefactoringManager(this.server, this.searchEngine) {
179 _reset(); 179 _reset();
180 } 180 }
181 181
182 bool get _hasFatalError { 182 bool get _hasFatalError {
183 return initStatus.hasFatalError || 183 return initStatus.hasFatalError ||
184 optionsStatus.hasFatalError || 184 optionsStatus.hasFatalError ||
185 finalStatus.hasFatalError; 185 finalStatus.hasFatalError;
186 } 186 }
187 187
188 /**
189 * Checks if [refactoring] requires options.
190 */
191 bool get _requiresOptions {
192 if (refactoring is InlineLocalRefactoring) {
193 return false;
194 }
195 return true;
196 }
197
188 void getRefactoring(Request request) { 198 void getRefactoring(Request request) {
189 // prepare for processing the request 199 // prepare for processing the request
190 requestId = request.id; 200 requestId = request.id;
191 result = new EditGetRefactoringResult(<RefactoringProblem>[]); 201 result = new EditGetRefactoringResult(<RefactoringProblem>[]);
192 // process the request 202 // process the request
193 var params = new EditGetRefactoringParams.fromRequest(request); 203 var params = new EditGetRefactoringParams.fromRequest(request);
194 _init(params.kind, params.file, params.offset, params.length).then((_) { 204 _init(params.kind, params.file, params.offset, params.length).then((_) {
195 if (_hasFatalError) { 205 if (_hasFatalError) {
196 return _sendResultResponse(); 206 return _sendResultResponse();
197 } 207 }
198 // set options 208 // set options
199 if (params.options == null) { 209 if (_requiresOptions) {
200 return _sendResultResponse(); 210 if (params.options == null) {
201 } 211 return _sendResultResponse();
202 optionsStatus = _setOptions(params, request); 212 }
203 if (_hasFatalError) { 213 optionsStatus = _setOptions(params, request);
204 return _sendResultResponse(); 214 if (_hasFatalError) {
215 return _sendResultResponse();
216 }
205 } 217 }
206 // done if just validation 218 // done if just validation
207 if (params.validateOnly) { 219 if (params.validateOnly) {
208 return _sendResultResponse(); 220 return _sendResultResponse();
209 } 221 }
210 // validation and create change 222 // validation and create change
211 refactoring.checkFinalConditions().then((_finalStatus) { 223 refactoring.checkFinalConditions().then((_finalStatus) {
212 finalStatus = _finalStatus; 224 finalStatus = _finalStatus;
213 if (_hasFatalError) { 225 if (_hasFatalError) {
214 return _sendResultResponse(); 226 return _sendResultResponse();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 } 262 }
251 if (kind == RefactoringKind.EXTRACT_METHOD) { 263 if (kind == RefactoringKind.EXTRACT_METHOD) {
252 List<CompilationUnit> units = server.getResolvedCompilationUnits(file); 264 List<CompilationUnit> units = server.getResolvedCompilationUnits(file);
253 if (units.isNotEmpty) { 265 if (units.isNotEmpty) {
254 refactoring = 266 refactoring =
255 new ExtractMethodRefactoring(searchEngine, units[0], offset, length) ; 267 new ExtractMethodRefactoring(searchEngine, units[0], offset, length) ;
256 feedback = 268 feedback =
257 new ExtractMethodFeedback(offset, length, null, [], false, [], [], [ ]); 269 new ExtractMethodFeedback(offset, length, null, [], false, [], [], [ ]);
258 } 270 }
259 } 271 }
272 if (kind == RefactoringKind.INLINE_LOCAL_VARIABLE) {
273 List<CompilationUnit> units = server.getResolvedCompilationUnits(file);
274 if (units.isNotEmpty) {
275 refactoring =
276 new InlineLocalRefactoring(searchEngine, units[0], offset);
277 }
278 }
260 if (kind == RefactoringKind.INLINE_METHOD) { 279 if (kind == RefactoringKind.INLINE_METHOD) {
261 List<CompilationUnit> units = server.getResolvedCompilationUnits(file); 280 List<CompilationUnit> units = server.getResolvedCompilationUnits(file);
262 if (units.isNotEmpty) { 281 if (units.isNotEmpty) {
263 refactoring = new InlineMethodRefactoring(searchEngine, units[0], offset ); 282 refactoring =
283 new InlineMethodRefactoring(searchEngine, units[0], offset);
264 } 284 }
265 } 285 }
266 if (kind == RefactoringKind.RENAME) { 286 if (kind == RefactoringKind.RENAME) {
267 List<AstNode> nodes = server.getNodesAtOffset(file, offset); 287 List<AstNode> nodes = server.getNodesAtOffset(file, offset);
268 List<Element> elements = server.getElementsAtOffset(file, offset); 288 List<Element> elements = server.getElementsAtOffset(file, offset);
269 if (nodes.isNotEmpty && elements.isNotEmpty) { 289 if (nodes.isNotEmpty && elements.isNotEmpty) {
270 AstNode node = nodes[0]; 290 AstNode node = nodes[0];
271 Element element = elements[0]; 291 Element element = elements[0];
272 refactoring = new RenameRefactoring(searchEngine, element); 292 refactoring = new RenameRefactoring(searchEngine, element);
273 feedback = new RenameFeedback(node.offset, node.length); 293 feedback = new RenameFeedback(node.offset, node.length);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 new ExtractMethodOptions.fromRefactoringParams(params, request); 365 new ExtractMethodOptions.fromRefactoringParams(params, request);
346 extractRefactoring.createGetter = extractOptions.createGetter; 366 extractRefactoring.createGetter = extractOptions.createGetter;
347 extractRefactoring.extractAll = extractOptions.extractAll; 367 extractRefactoring.extractAll = extractOptions.extractAll;
348 extractRefactoring.name = extractOptions.name; 368 extractRefactoring.name = extractOptions.name;
349 if (extractOptions.parameters != null) { 369 if (extractOptions.parameters != null) {
350 extractRefactoring.parameters = extractOptions.parameters; 370 extractRefactoring.parameters = extractOptions.parameters;
351 } 371 }
352 extractRefactoring.returnType = extractOptions.returnType; 372 extractRefactoring.returnType = extractOptions.returnType;
353 return extractRefactoring.checkName(); 373 return extractRefactoring.checkName();
354 } 374 }
375 if (refactoring is InlineLocalRefactoring) {
376 return new RefactoringStatus();
377 }
355 if (refactoring is InlineMethodRefactoring) { 378 if (refactoring is InlineMethodRefactoring) {
356 InlineMethodRefactoring inlineRefactoring = this.refactoring; 379 InlineMethodRefactoring inlineRefactoring = this.refactoring;
357 InlineMethodOptions inlineOptions = 380 InlineMethodOptions inlineOptions =
358 new InlineMethodOptions.fromRefactoringParams(params, request); 381 new InlineMethodOptions.fromRefactoringParams(params, request);
359 inlineRefactoring.deleteSource = inlineOptions.deleteSource; 382 inlineRefactoring.deleteSource = inlineOptions.deleteSource;
360 inlineRefactoring.inlineAll = inlineOptions.inlineAll; 383 inlineRefactoring.inlineAll = inlineOptions.inlineAll;
361 return new RefactoringStatus(); 384 return new RefactoringStatus();
362 } 385 }
363 if (refactoring is RenameRefactoring) { 386 if (refactoring is RenameRefactoring) {
364 RenameRefactoring renameRefactoring = refactoring; 387 RenameRefactoring renameRefactoring = refactoring;
365 RenameOptions renameOptions = 388 RenameOptions renameOptions =
366 new RenameOptions.fromRefactoringParams(params, request); 389 new RenameOptions.fromRefactoringParams(params, request);
367 renameRefactoring.newName = renameOptions.newName; 390 renameRefactoring.newName = renameOptions.newName;
368 return renameRefactoring.checkNewName(); 391 return renameRefactoring.checkNewName();
369 } 392 }
370 return new RefactoringStatus(); 393 return new RefactoringStatus();
371 } 394 }
372 } 395 }
OLDNEW
« 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