Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 library services.refactoring; | |
| 6 | |
| 7 import 'package:analysis_services/correction/change.dart'; | |
| 8 import 'package:analysis_services/correction/status.dart'; | |
| 9 import 'package:analysis_services/refactoring/progress_monitor.dart'; | |
| 10 import 'package:analysis_services/search/search_engine.dart'; | |
| 11 import 'package:analysis_services/src/refactoring/rename_local.dart'; | |
| 12 import 'package:analyzer/src/generated/element.dart'; | |
| 13 | |
| 14 | |
| 15 /** | |
| 16 * Returns a [RenameRefactoring] instance for renaming [element], may be `null` | |
| 17 * if there is no support for renaming [Element]s of the given type. | |
| 18 */ | |
| 19 RenameRefactoring createRenameRefactoring(SearchEngine searchEngine, | |
|
Brian Wilkerson
2014/08/11 16:27:47
I don't see the value in a top-level function that
scheglov
2014/08/11 18:06:25
Done.
However actually I missed some code.
This fu
Brian Wilkerson
2014/08/11 18:45:29
I generally wouldn't, but in this case (given that
| |
| 20 Element element) { | |
| 21 return new RenameLocalRefactoringImpl(searchEngine, element); | |
| 22 } | |
| 23 | |
| 24 /** | |
| 25 * Abstract interface for all refactorings. | |
| 26 */ | |
| 27 abstract class Refactoring { | |
| 28 /** | |
| 29 * Returns the human readable name of this [Refactoring]. | |
| 30 */ | |
| 31 String get refactoringName; | |
| 32 | |
| 33 /** | |
| 34 * Checks all conditions - [checkInitialConditions] and | |
| 35 * [checkFinalConditions] to decide if refactoring can be performed. | |
| 36 */ | |
| 37 RefactoringStatus checkAllConditions(ProgressMonitor pm); | |
| 38 | |
| 39 /** | |
| 40 * Validates environment to check if this refactoring can be performed. | |
| 41 * | |
| 42 * This check may be slow, because many refactorings use search engine. | |
| 43 */ | |
| 44 RefactoringStatus checkFinalConditions(ProgressMonitor pm); | |
| 45 | |
| 46 /** | |
| 47 * Validates arguments to check if this refactoring can be performed. | |
| 48 * | |
| 49 * This check should be quick because it is used often as arguments change. | |
| 50 */ | |
| 51 RefactoringStatus checkInitialConditions(ProgressMonitor pm); | |
| 52 | |
| 53 /** | |
| 54 * Returns the [Change] to apply to perform this refactoring. | |
| 55 */ | |
| 56 Change createChange(ProgressMonitor pm); | |
| 57 | |
| 58 /** | |
| 59 * Returs `true` if the [Change] created by refactoring may be unsafe, | |
| 60 * so we want user to review the [Change] to ensure that he understands it. | |
| 61 */ | |
| 62 bool requiresPreview(); | |
| 63 } | |
| 64 | |
| 65 | |
| 66 /** | |
| 67 * Abstract [Refactoring] for renaming some [Element]. | |
| 68 */ | |
| 69 abstract class RenameRefactoring implements Refactoring { | |
| 70 /** | |
| 71 * Returns the current name of the [Element]. | |
| 72 */ | |
| 73 String get currentName; | |
| 74 | |
| 75 /** | |
| 76 * Sets the new name for the [Element]. | |
| 77 */ | |
| 78 void set newName(String newName); | |
| 79 | |
| 80 /** | |
| 81 * Validates [newName]. | |
|
Brian Wilkerson
2014/08/11 16:27:47
The more information in comments the better. Perha
scheglov
2014/08/11 18:06:25
Done.
| |
| 82 */ | |
| 83 RefactoringStatus checkNewName(String newName); | |
| 84 } | |
| OLD | NEW |