Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(87)

Side by Side Diff: pkg/analysis_services/lib/refactoring/refactoring.dart

Issue 458063002: Initial work on refactorings. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixes for review comments Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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/search/search_engine.dart';
10 import 'package:analysis_services/src/refactoring/rename_local.dart';
11 import 'package:analyzer/src/generated/element.dart';
12
13
14 /**
15 * Abstract interface for all refactorings.
16 */
17 abstract class Refactoring {
18 /**
19 * Returns the human readable name of this [Refactoring].
20 */
21 String get refactoringName;
22
23 /**
24 * Checks all conditions - [checkInitialConditions] and
25 * [checkFinalConditions] to decide if refactoring can be performed.
26 */
27 RefactoringStatus checkAllConditions();
28
29 /**
30 * Validates environment to check if this refactoring can be performed.
31 *
32 * This check may be slow, because many refactorings use search engine.
33 */
34 RefactoringStatus checkFinalConditions();
35
36 /**
37 * Validates arguments to check if this refactoring can be performed.
38 *
39 * This check should be quick because it is used often as arguments change.
40 */
41 RefactoringStatus checkInitialConditions();
42
43 /**
44 * Returns the [Change] to apply to perform this refactoring.
45 */
46 Change createChange();
47
48 /**
49 * Returs `true` if the [Change] created by refactoring may be unsafe,
50 * so we want user to review the [Change] to ensure that he understands it.
51 */
52 bool requiresPreview();
53 }
54
55
56 /**
57 * Abstract [Refactoring] for renaming some [Element].
58 */
59 abstract class RenameRefactoring implements Refactoring {
60 /**
61 * Returns a new [RenameRefactoring] instance for renaming [element],
62 * maybe `null` if there is no support for renaming [Element]s of the given
63 * type.
64 */
65 factory RenameRefactoring(SearchEngine searchEngine, Element element) {
66 if (element is LocalElement) {
67 return new RenameLocalRefactoringImpl(searchEngine, element);
68 }
69 return null;
70 }
71
72 /**
73 * Sets the new name for the [Element].
74 */
75 void set newName(String newName);
76
77 /**
78 * Returns the old name of the [Element] being renamed.
79 */
80 String get oldName;
81
82 /**
83 * Validates that the [newName] is a valid identifier and is appropriate for
84 * the type of the [Element] being renamed.
85 *
86 * It does not perform all the checks (such as checking for conflicts with any
87 * existing names in any of the scopes containing the current name), as many
88 * of these checkes require search engine. Use [checkFinalConditions] for this
89 * level of checking.
90 */
91 RefactoringStatus checkNewName();
92 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698