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 import 'dart:async'; | 5 import 'dart:async'; |
6 | 6 |
7 import 'package:analysis_server/src/services/correction/status.dart'; | 7 import 'package:analysis_server/src/services/correction/status.dart'; |
8 import 'package:analysis_server/src/services/refactoring/convert_getter_to_metho
d.dart'; | 8 import 'package:analysis_server/src/services/refactoring/convert_getter_to_metho
d.dart'; |
9 import 'package:analysis_server/src/services/refactoring/convert_method_to_gette
r.dart'; | 9 import 'package:analysis_server/src/services/refactoring/convert_method_to_gette
r.dart'; |
10 import 'package:analysis_server/src/services/refactoring/extract_local.dart'; | 10 import 'package:analysis_server/src/services/refactoring/extract_local.dart'; |
11 import 'package:analysis_server/src/services/refactoring/extract_method.dart'; | 11 import 'package:analysis_server/src/services/refactoring/extract_method.dart'; |
12 import 'package:analysis_server/src/services/refactoring/inline_local.dart'; | 12 import 'package:analysis_server/src/services/refactoring/inline_local.dart'; |
13 import 'package:analysis_server/src/services/refactoring/inline_method.dart'; | 13 import 'package:analysis_server/src/services/refactoring/inline_method.dart'; |
14 import 'package:analysis_server/src/services/refactoring/move_file.dart'; | |
15 import 'package:analysis_server/src/services/refactoring/rename_class_member.dar
t'; | 14 import 'package:analysis_server/src/services/refactoring/rename_class_member.dar
t'; |
16 import 'package:analysis_server/src/services/refactoring/rename_constructor.dart
'; | 15 import 'package:analysis_server/src/services/refactoring/rename_constructor.dart
'; |
17 import 'package:analysis_server/src/services/refactoring/rename_import.dart'; | 16 import 'package:analysis_server/src/services/refactoring/rename_import.dart'; |
18 import 'package:analysis_server/src/services/refactoring/rename_label.dart'; | 17 import 'package:analysis_server/src/services/refactoring/rename_label.dart'; |
19 import 'package:analysis_server/src/services/refactoring/rename_library.dart'; | 18 import 'package:analysis_server/src/services/refactoring/rename_library.dart'; |
20 import 'package:analysis_server/src/services/refactoring/rename_local.dart'; | 19 import 'package:analysis_server/src/services/refactoring/rename_local.dart'; |
21 import 'package:analysis_server/src/services/refactoring/rename_unit_member.dart
'; | 20 import 'package:analysis_server/src/services/refactoring/rename_unit_member.dart
'; |
22 import 'package:analysis_server/src/services/search/search_engine.dart'; | 21 import 'package:analysis_server/src/services/search/search_engine.dart'; |
23 import 'package:analyzer/dart/ast/ast.dart'; | 22 import 'package:analyzer/dart/ast/ast.dart'; |
24 import 'package:analyzer/dart/element/element.dart'; | 23 import 'package:analyzer/dart/element/element.dart'; |
25 import 'package:analyzer/file_system/file_system.dart'; | |
26 import 'package:analyzer/src/dart/element/ast_provider.dart'; | 24 import 'package:analyzer/src/dart/element/ast_provider.dart'; |
27 import 'package:analyzer/src/generated/engine.dart'; | |
28 import 'package:analyzer/src/generated/source.dart'; | |
29 import 'package:analyzer_plugin/protocol/protocol_common.dart' | 25 import 'package:analyzer_plugin/protocol/protocol_common.dart' |
30 show RefactoringMethodParameter, SourceChange; | 26 show RefactoringMethodParameter, SourceChange; |
31 | 27 |
32 /** | 28 /** |
33 * [Refactoring] to convert getters into normal [MethodDeclaration]s. | 29 * [Refactoring] to convert getters into normal [MethodDeclaration]s. |
34 */ | 30 */ |
35 abstract class ConvertGetterToMethodRefactoring implements Refactoring { | 31 abstract class ConvertGetterToMethodRefactoring implements Refactoring { |
36 /** | 32 /** |
37 * Returns a new [ConvertMethodToGetterRefactoring] instance for converting | 33 * Returns a new [ConvertMethodToGetterRefactoring] instance for converting |
38 * [element] and all the corresponding hierarchy elements. | 34 * [element] and all the corresponding hierarchy elements. |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 */ | 280 */ |
285 bool get isDeclaration; | 281 bool get isDeclaration; |
286 | 282 |
287 /** | 283 /** |
288 * The name of the method (or function) being inlined. | 284 * The name of the method (or function) being inlined. |
289 */ | 285 */ |
290 String get methodName; | 286 String get methodName; |
291 } | 287 } |
292 | 288 |
293 /** | 289 /** |
294 * [Refactoring] to move/rename a file. | |
295 */ | |
296 abstract class MoveFileRefactoring implements Refactoring { | |
297 /** | |
298 * Returns a new [MoveFileRefactoring] instance. | |
299 */ | |
300 factory MoveFileRefactoring( | |
301 ResourceProvider resourceProvider, | |
302 SearchEngine searchEngine, | |
303 AnalysisContext context, | |
304 Source source, | |
305 String oldFile) { | |
306 return new MoveFileRefactoringImpl( | |
307 resourceProvider, searchEngine, context, source, oldFile); | |
308 } | |
309 | |
310 /** | |
311 * The new file path to which the given file is being moved. | |
312 */ | |
313 void set newFile(String newName); | |
314 } | |
315 | |
316 /** | |
317 * Abstract interface for all refactorings. | 290 * Abstract interface for all refactorings. |
318 */ | 291 */ |
319 abstract class Refactoring { | 292 abstract class Refactoring { |
320 /** | 293 /** |
321 * The ids of source edits that are not known to be valid. | 294 * The ids of source edits that are not known to be valid. |
322 * | 295 * |
323 * An edit is not known to be valid if there was insufficient type information | 296 * An edit is not known to be valid if there was insufficient type information |
324 * for the server to be able to determine whether or not the code needs to be | 297 * for the server to be able to determine whether or not the code needs to be |
325 * modified, such as when a member is being renamed and there is a reference | 298 * modified, such as when a member is being renamed and there is a reference |
326 * to a member from an unknown type. This field will be omitted if the change | 299 * to a member from an unknown type. This field will be omitted if the change |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 _map[unitElement] = unit; | 434 _map[unitElement] = unit; |
462 } | 435 } |
463 return unit; | 436 return unit; |
464 } | 437 } |
465 | 438 |
466 CompilationUnitElement getUnitElement(Element element) { | 439 CompilationUnitElement getUnitElement(Element element) { |
467 return element.getAncestor((e) => e is CompilationUnitElement) | 440 return element.getAncestor((e) => e is CompilationUnitElement) |
468 as CompilationUnitElement; | 441 as CompilationUnitElement; |
469 } | 442 } |
470 } | 443 } |
OLD | NEW |