Chromium Code Reviews| Index: pkg/analysis_services/lib/refactoring/refactoring.dart |
| diff --git a/pkg/analysis_services/lib/refactoring/refactoring.dart b/pkg/analysis_services/lib/refactoring/refactoring.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..1a88b7c30f213dc63c78b87148bca7ec384943fc |
| --- /dev/null |
| +++ b/pkg/analysis_services/lib/refactoring/refactoring.dart |
| @@ -0,0 +1,84 @@ |
| +// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +library services.refactoring; |
| + |
| +import 'package:analysis_services/correction/change.dart'; |
| +import 'package:analysis_services/correction/status.dart'; |
| +import 'package:analysis_services/refactoring/progress_monitor.dart'; |
| +import 'package:analysis_services/search/search_engine.dart'; |
| +import 'package:analysis_services/src/refactoring/rename_local.dart'; |
| +import 'package:analyzer/src/generated/element.dart'; |
| + |
| + |
| +/** |
| + * Returns a [RenameRefactoring] instance for renaming [element], may be `null` |
| + * if there is no support for renaming [Element]s of the given type. |
| + */ |
| +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
|
| + Element element) { |
| + return new RenameLocalRefactoringImpl(searchEngine, element); |
| +} |
| + |
| +/** |
| + * Abstract interface for all refactorings. |
| + */ |
| +abstract class Refactoring { |
| + /** |
| + * Returns the human readable name of this [Refactoring]. |
| + */ |
| + String get refactoringName; |
| + |
| + /** |
| + * Checks all conditions - [checkInitialConditions] and |
| + * [checkFinalConditions] to decide if refactoring can be performed. |
| + */ |
| + RefactoringStatus checkAllConditions(ProgressMonitor pm); |
| + |
| + /** |
| + * Validates environment to check if this refactoring can be performed. |
| + * |
| + * This check may be slow, because many refactorings use search engine. |
| + */ |
| + RefactoringStatus checkFinalConditions(ProgressMonitor pm); |
| + |
| + /** |
| + * Validates arguments to check if this refactoring can be performed. |
| + * |
| + * This check should be quick because it is used often as arguments change. |
| + */ |
| + RefactoringStatus checkInitialConditions(ProgressMonitor pm); |
| + |
| + /** |
| + * Returns the [Change] to apply to perform this refactoring. |
| + */ |
| + Change createChange(ProgressMonitor pm); |
| + |
| + /** |
| + * Returs `true` if the [Change] created by refactoring may be unsafe, |
| + * so we want user to review the [Change] to ensure that he understands it. |
| + */ |
| + bool requiresPreview(); |
| +} |
| + |
| + |
| +/** |
| + * Abstract [Refactoring] for renaming some [Element]. |
| + */ |
| +abstract class RenameRefactoring implements Refactoring { |
| + /** |
| + * Returns the current name of the [Element]. |
| + */ |
| + String get currentName; |
| + |
| + /** |
| + * Sets the new name for the [Element]. |
| + */ |
| + void set newName(String newName); |
| + |
| + /** |
| + * 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.
|
| + */ |
| + RefactoringStatus checkNewName(String newName); |
| +} |