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/plugin/protocol/protocol.dart' | 9 import 'package:analysis_server/plugin/protocol/protocol.dart' |
10 show RefactoringMethodParameter, SourceChange; | 10 show RefactoringMethodParameter, SourceChange; |
(...skipping 13 matching lines...) Expand all Loading... |
24 import 'package:analysis_server/src/services/refactoring/rename_local.dart'; | 24 import 'package:analysis_server/src/services/refactoring/rename_local.dart'; |
25 import 'package:analysis_server/src/services/refactoring/rename_unit_member.dart
'; | 25 import 'package:analysis_server/src/services/refactoring/rename_unit_member.dart
'; |
26 import 'package:analysis_server/src/services/search/search_engine.dart'; | 26 import 'package:analysis_server/src/services/search/search_engine.dart'; |
27 import 'package:analyzer/dart/ast/ast.dart'; | 27 import 'package:analyzer/dart/ast/ast.dart'; |
28 import 'package:analyzer/dart/element/element.dart'; | 28 import 'package:analyzer/dart/element/element.dart'; |
29 import 'package:analyzer/file_system/file_system.dart'; | 29 import 'package:analyzer/file_system/file_system.dart'; |
30 import 'package:analyzer/src/generated/engine.dart'; | 30 import 'package:analyzer/src/generated/engine.dart'; |
31 import 'package:analyzer/src/generated/source.dart'; | 31 import 'package:analyzer/src/generated/source.dart'; |
32 | 32 |
33 /** | 33 /** |
| 34 * Completes with the resolved [CompilationUnit] that contains the [element]. |
| 35 */ |
| 36 typedef Future<CompilationUnit> GetResolvedUnit(Element element); |
| 37 |
| 38 /** |
34 * [Refactoring] to convert getters into normal [MethodDeclaration]s. | 39 * [Refactoring] to convert getters into normal [MethodDeclaration]s. |
35 */ | 40 */ |
36 abstract class ConvertGetterToMethodRefactoring implements Refactoring { | 41 abstract class ConvertGetterToMethodRefactoring implements Refactoring { |
37 /** | 42 /** |
38 * Returns a new [ConvertMethodToGetterRefactoring] instance for converting | 43 * Returns a new [ConvertMethodToGetterRefactoring] instance for converting |
39 * [element] and all the corresponding hierarchy elements. | 44 * [element] and all the corresponding hierarchy elements. |
40 */ | 45 */ |
41 factory ConvertGetterToMethodRefactoring( | 46 factory ConvertGetterToMethodRefactoring( |
42 SearchEngine searchEngine, PropertyAccessorElement element) { | 47 SearchEngine searchEngine, PropertyAccessorElement element) { |
43 return new ConvertGetterToMethodRefactoringImpl(searchEngine, element); | 48 return new ConvertGetterToMethodRefactoringImpl(searchEngine, element); |
44 } | 49 } |
45 } | 50 } |
46 | 51 |
47 /** | 52 /** |
48 * [Refactoring] to convert normal [MethodDeclaration]s into getters. | 53 * [Refactoring] to convert normal [MethodDeclaration]s into getters. |
49 */ | 54 */ |
50 abstract class ConvertMethodToGetterRefactoring implements Refactoring { | 55 abstract class ConvertMethodToGetterRefactoring implements Refactoring { |
51 /** | 56 /** |
52 * Returns a new [ConvertMethodToGetterRefactoring] instance for converting | 57 * Returns a new [ConvertMethodToGetterRefactoring] instance for converting |
53 * [element] and all the corresponding hierarchy elements. | 58 * [element] and all the corresponding hierarchy elements. |
54 */ | 59 */ |
55 factory ConvertMethodToGetterRefactoring( | 60 factory ConvertMethodToGetterRefactoring(SearchEngine searchEngine, |
56 SearchEngine searchEngine, ExecutableElement element) { | 61 GetResolvedUnit getResolvedUnit, ExecutableElement element) { |
57 return new ConvertMethodToGetterRefactoringImpl(searchEngine, element); | 62 return new ConvertMethodToGetterRefactoringImpl( |
| 63 searchEngine, getResolvedUnit, element); |
58 } | 64 } |
59 } | 65 } |
60 | 66 |
61 /** | 67 /** |
62 * [Refactoring] to extract an expression into a local variable declaration. | 68 * [Refactoring] to extract an expression into a local variable declaration. |
63 */ | 69 */ |
64 abstract class ExtractLocalRefactoring implements Refactoring { | 70 abstract class ExtractLocalRefactoring implements Refactoring { |
65 /** | 71 /** |
66 * Returns a new [ExtractLocalRefactoring] instance. | 72 * Returns a new [ExtractLocalRefactoring] instance. |
67 */ | 73 */ |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 String get variableName; | 247 String get variableName; |
242 } | 248 } |
243 | 249 |
244 /** | 250 /** |
245 * [Refactoring] to inline an [ExecutableElement]. | 251 * [Refactoring] to inline an [ExecutableElement]. |
246 */ | 252 */ |
247 abstract class InlineMethodRefactoring implements Refactoring { | 253 abstract class InlineMethodRefactoring implements Refactoring { |
248 /** | 254 /** |
249 * Returns a new [InlineMethodRefactoring] instance. | 255 * Returns a new [InlineMethodRefactoring] instance. |
250 */ | 256 */ |
251 factory InlineMethodRefactoring( | 257 factory InlineMethodRefactoring(SearchEngine searchEngine, |
252 SearchEngine searchEngine, | 258 GetResolvedUnit getResolvedUnit, CompilationUnit unit, int offset) { |
253 GetResolvedUnitContainingElement getResolvedUnit, | |
254 CompilationUnit unit, | |
255 int offset) { | |
256 return new InlineMethodRefactoringImpl( | 259 return new InlineMethodRefactoringImpl( |
257 searchEngine, getResolvedUnit, unit, offset); | 260 searchEngine, getResolvedUnit, unit, offset); |
258 } | 261 } |
259 | 262 |
260 /** | 263 /** |
261 * The name of the class enclosing the method being inlined. | 264 * The name of the class enclosing the method being inlined. |
262 * If not a class member is being inlined, then `null`. | 265 * If not a class member is being inlined, then `null`. |
263 */ | 266 */ |
264 String get className; | 267 String get className; |
265 | 268 |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 * Validates that the [newName] is a valid identifier and is appropriate for | 425 * Validates that the [newName] is a valid identifier and is appropriate for |
423 * the type of the [Element] being renamed. | 426 * the type of the [Element] being renamed. |
424 * | 427 * |
425 * It does not perform all the checks (such as checking for conflicts with any | 428 * It does not perform all the checks (such as checking for conflicts with any |
426 * existing names in any of the scopes containing the current name), as many | 429 * existing names in any of the scopes containing the current name), as many |
427 * of these checkes require search engine. Use [checkFinalConditions] for this | 430 * of these checkes require search engine. Use [checkFinalConditions] for this |
428 * level of checking. | 431 * level of checking. |
429 */ | 432 */ |
430 RefactoringStatus checkNewName(); | 433 RefactoringStatus checkNewName(); |
431 } | 434 } |
OLD | NEW |