| 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 library services.refactoring; | 5 library services.refactoring; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/src/services/correction/change.dart'; | 9 import 'package:analysis_server/src/services/correction/change.dart'; |
| 10 import 'package:analysis_server/src/services/correction/status.dart'; | 10 import 'package:analysis_server/src/services/correction/status.dart'; |
| 11 import 'package:analysis_server/src/services/search/search_engine.dart'; | 11 import 'package:analysis_server/src/services/refactoring/extract_local.dart'; |
| 12 import 'package:analysis_server/src/services/refactoring/rename_class_member.dar
t'; | 12 import 'package:analysis_server/src/services/refactoring/rename_class_member.dar
t'; |
| 13 import 'package:analysis_server/src/services/refactoring/rename_constructor.dart
'; | 13 import 'package:analysis_server/src/services/refactoring/rename_constructor.dart
'; |
| 14 import 'package:analysis_server/src/services/refactoring/rename_import.dart'; | 14 import 'package:analysis_server/src/services/refactoring/rename_import.dart'; |
| 15 import 'package:analysis_server/src/services/refactoring/rename_library.dart'; | 15 import 'package:analysis_server/src/services/refactoring/rename_library.dart'; |
| 16 import 'package:analysis_server/src/services/refactoring/rename_local.dart'; | 16 import 'package:analysis_server/src/services/refactoring/rename_local.dart'; |
| 17 import 'package:analysis_server/src/services/refactoring/rename_unit_member.dart
'; | 17 import 'package:analysis_server/src/services/refactoring/rename_unit_member.dart
'; |
| 18 import 'package:analysis_server/src/services/search/search_engine.dart'; |
| 19 import 'package:analyzer/src/generated/ast.dart'; |
| 18 import 'package:analyzer/src/generated/element.dart'; | 20 import 'package:analyzer/src/generated/element.dart'; |
| 19 | 21 |
| 20 | 22 |
| 21 /** | 23 /** |
| 24 * [Refactoring] to extract an expression into a local variable declaration. |
| 25 */ |
| 26 abstract class ExtractLocalRefactoring implements Refactoring { |
| 27 /** |
| 28 * Returns a new [ExtractLocalRefactoring] instance. |
| 29 */ |
| 30 factory ExtractLocalRefactoring(CompilationUnit unit, int selectionOffset, |
| 31 int selectionLength) { |
| 32 return new ExtractLocalRefactoringImpl( |
| 33 unit, |
| 34 selectionOffset, |
| 35 selectionLength); |
| 36 } |
| 37 |
| 38 /** |
| 39 * True if all occurrences of the expression within the scope in which the |
| 40 * variable will be defined should be replaced by a reference to the local |
| 41 * variable. The expression used to initiate the refactoring will always be |
| 42 * replaced. |
| 43 */ |
| 44 void set extractAll(bool extractAll); |
| 45 |
| 46 /** |
| 47 * The lengths of the expressions that would be replaced by a reference to the |
| 48 * variable. The lengths correspond to the offsets. In other words, for a |
| 49 * given expression, if the offset of that expression is offsets[i], then the |
| 50 * length of that expression is lengths[i]. |
| 51 */ |
| 52 List<int> get lengths; |
| 53 |
| 54 /** |
| 55 * The name that the local variable should be given. |
| 56 */ |
| 57 void set name(String name); |
| 58 |
| 59 /** |
| 60 * The proposed names for the local variable. |
| 61 * |
| 62 * The first proposal should be used as the "best guess" (if it exists). |
| 63 */ |
| 64 List<String> get names; |
| 65 |
| 66 /** |
| 67 * The offsets of the expressions that would be replaced by a reference to |
| 68 * the variable. |
| 69 */ |
| 70 List<int> get offsets; |
| 71 |
| 72 /** |
| 73 * Validates that the [name] is a valid identifier and is appropriate for |
| 74 * local variable. |
| 75 * |
| 76 * It does not perform all the checks (such as checking for conflicts with any |
| 77 * existing names in any of the scopes containing the current name), as many |
| 78 * of these checkes require search engine. Use [checkFinalConditions] for this |
| 79 * level of checking. |
| 80 */ |
| 81 RefactoringStatus checkName(); |
| 82 } |
| 83 |
| 84 |
| 85 /** |
| 22 * Abstract interface for all refactorings. | 86 * Abstract interface for all refactorings. |
| 23 */ | 87 */ |
| 24 abstract class Refactoring { | 88 abstract class Refactoring { |
| 25 /** | 89 /** |
| 26 * The ids of source edits that are not known to be valid. | 90 * The ids of source edits that are not known to be valid. |
| 27 * | 91 * |
| 28 * An edit is not known to be valid if there was insufficient type information | 92 * An edit is not known to be valid if there was insufficient type information |
| 29 * for the server to be able to determine whether or not the code needs to be | 93 * for the server to be able to determine whether or not the code needs to be |
| 30 * modified, such as when a member is being renamed and there is a reference | 94 * modified, such as when a member is being renamed and there is a reference |
| 31 * to a member from an unknown type. This field will be omitted if the change | 95 * to a member from an unknown type. This field will be omitted if the change |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 * Validates that the [newName] is a valid identifier and is appropriate for | 183 * Validates that the [newName] is a valid identifier and is appropriate for |
| 120 * the type of the [Element] being renamed. | 184 * the type of the [Element] being renamed. |
| 121 * | 185 * |
| 122 * It does not perform all the checks (such as checking for conflicts with any | 186 * It does not perform all the checks (such as checking for conflicts with any |
| 123 * existing names in any of the scopes containing the current name), as many | 187 * existing names in any of the scopes containing the current name), as many |
| 124 * of these checkes require search engine. Use [checkFinalConditions] for this | 188 * of these checkes require search engine. Use [checkFinalConditions] for this |
| 125 * level of checking. | 189 * level of checking. |
| 126 */ | 190 */ |
| 127 RefactoringStatus checkNewName(); | 191 RefactoringStatus checkNewName(); |
| 128 } | 192 } |
| OLD | NEW |