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

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

Issue 484733003: Import analysis_services.dart into analysis_server.dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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 'dart:async';
8
9 import 'package:analysis_services/correction/change.dart';
10 import 'package:analysis_services/correction/status.dart';
11 import 'package:analysis_services/search/search_engine.dart';
12 import 'package:analysis_services/src/refactoring/rename_class_member.dart';
13 import 'package:analysis_services/src/refactoring/rename_constructor.dart';
14 import 'package:analysis_services/src/refactoring/rename_import.dart';
15 import 'package:analysis_services/src/refactoring/rename_library.dart';
16 import 'package:analysis_services/src/refactoring/rename_local.dart';
17 import 'package:analysis_services/src/refactoring/rename_unit_member.dart';
18 import 'package:analyzer/src/generated/element.dart';
19
20
21 /**
22 * Abstract interface for all refactorings.
23 */
24 abstract class Refactoring {
25 /**
26 * The ids of source edits that are not known to be valid.
27 *
28 * 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
30 * 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
32 * field is omitted or if there are no potential edits for the refactoring.
33 */
34 List<String> get potentialEditIds;
35
36 /**
37 * Returns the human readable name of this [Refactoring].
38 */
39 String get refactoringName;
40
41 /**
42 * Checks all conditions - [checkInitialConditions] and
43 * [checkFinalConditions] to decide if refactoring can be performed.
44 */
45 Future<RefactoringStatus> checkAllConditions();
46
47 /**
48 * Validates environment to check if this refactoring can be performed.
49 *
50 * This check may be slow, because many refactorings use search engine.
51 */
52 Future<RefactoringStatus> checkFinalConditions();
53
54 /**
55 * Validates arguments to check if this refactoring can be performed.
56 *
57 * This check should be quick because it is used often as arguments change.
58 */
59 Future<RefactoringStatus> checkInitialConditions();
60
61 /**
62 * Returns the [Change] to apply to perform this refactoring.
63 */
64 Future<Change> createChange();
65
66 /**
67 * Returs `true` if the [Change] created by refactoring may be unsafe,
68 * so we want user to review the [Change] to ensure that he understands it.
69 */
70 bool requiresPreview();
71 }
72
73
74 /**
75 * Abstract [Refactoring] for renaming some [Element].
76 */
77 abstract class RenameRefactoring implements Refactoring {
78 /**
79 * Returns a new [RenameRefactoring] instance for renaming [element],
80 * maybe `null` if there is no support for renaming [Element]s of the given
81 * type.
82 */
83 factory RenameRefactoring(SearchEngine searchEngine, Element element) {
84 if (element is PropertyAccessorElement) {
85 element = (element as PropertyAccessorElement).variable;
86 }
87 if (element.enclosingElement is CompilationUnitElement) {
88 return new RenameUnitMemberRefactoringImpl(searchEngine, element);
89 }
90 if (element is ConstructorElement) {
91 return new RenameConstructorRefactoringImpl(searchEngine, element);
92 }
93 if (element is ImportElement) {
94 return new RenameImportRefactoringImpl(searchEngine, element);
95 }
96 if (element is LibraryElement) {
97 return new RenameLibraryRefactoringImpl(searchEngine, element);
98 }
99 if (element is LocalElement) {
100 return new RenameLocalRefactoringImpl(searchEngine, element);
101 }
102 if (element.enclosingElement is ClassElement) {
103 return new RenameClassMemberRefactoringImpl(searchEngine, element);
104 }
105 return null;
106 }
107
108 /**
109 * Sets the new name for the [Element].
110 */
111 void set newName(String newName);
112
113 /**
114 * Returns the old name of the [Element] being renamed.
115 */
116 String get oldName;
117
118 /**
119 * Validates that the [newName] is a valid identifier and is appropriate for
120 * the type of the [Element] being renamed.
121 *
122 * 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
124 * of these checkes require search engine. Use [checkFinalConditions] for this
125 * level of checking.
126 */
127 RefactoringStatus checkNewName();
128 }
OLDNEW
« no previous file with comments | « pkg/analysis_services/lib/json.dart ('k') | pkg/analysis_services/lib/search/element_visitors.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698