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

Unified Diff: pkg/analysis_server/lib/src/services/refactoring/refactoring.dart

Issue 489973002: Initial 'Extract Local' implementation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: tweaks 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 side-by-side diff with in-line comments
Download patch
Index: pkg/analysis_server/lib/src/services/refactoring/refactoring.dart
diff --git a/pkg/analysis_server/lib/src/services/refactoring/refactoring.dart b/pkg/analysis_server/lib/src/services/refactoring/refactoring.dart
index bf63090e109b2efff74353b010beb2dfcbdd72f3..5c277df432eede8c3f7de8c555749753d329f85f 100644
--- a/pkg/analysis_server/lib/src/services/refactoring/refactoring.dart
+++ b/pkg/analysis_server/lib/src/services/refactoring/refactoring.dart
@@ -8,17 +8,81 @@ import 'dart:async';
import 'package:analysis_server/src/services/correction/change.dart';
import 'package:analysis_server/src/services/correction/status.dart';
-import 'package:analysis_server/src/services/search/search_engine.dart';
+import 'package:analysis_server/src/services/refactoring/extract_local.dart';
import 'package:analysis_server/src/services/refactoring/rename_class_member.dart';
import 'package:analysis_server/src/services/refactoring/rename_constructor.dart';
import 'package:analysis_server/src/services/refactoring/rename_import.dart';
import 'package:analysis_server/src/services/refactoring/rename_library.dart';
import 'package:analysis_server/src/services/refactoring/rename_local.dart';
import 'package:analysis_server/src/services/refactoring/rename_unit_member.dart';
+import 'package:analysis_server/src/services/search/search_engine.dart';
+import 'package:analyzer/src/generated/ast.dart';
import 'package:analyzer/src/generated/element.dart';
/**
+ * [Refactoring] to extract an expression into a local variable declaration.
+ */
+abstract class ExtractLocalRefactoring implements Refactoring {
+ /**
+ * Returns a new [ExtractLocalRefactoring] instance.
+ */
+ factory ExtractLocalRefactoring(CompilationUnit unit, int selectionOffset,
+ int selectionLength) {
+ return new ExtractLocalRefactoringImpl(
+ unit,
+ selectionOffset,
+ selectionLength);
+ }
+
+ /**
+ * True if all occurrences of the expression within the scope in which the
+ * variable will be defined should be replaced by a reference to the local
+ * variable. The expression used to initiate the refactoring will always be
+ * replaced.
+ */
+ void set extractAll(bool extractAll);
+
+ /**
+ * The lengths of the expressions that would be replaced by a reference to the
+ * variable. The lengths correspond to the offsets. In other words, for a
+ * given expression, if the offset of that expression is offsets[i], then the
+ * length of that expression is lengths[i].
+ */
+ List<int> get lengths;
+
+ /**
+ * The name that the local variable should be given.
+ */
+ void set name(String name);
+
+ /**
+ * The proposed names for the local variable.
+ *
+ * The first proposal should be used as the "best guess" (if it exists).
+ */
+ List<String> get names;
+
+ /**
+ * The offsets of the expressions that would be replaced by a reference to
+ * the variable.
+ */
+ List<int> get offsets;
+
+ /**
+ * Validates that the [name] is a valid identifier and is appropriate for
+ * local variable.
+ *
+ * It does not perform all the checks (such as checking for conflicts with any
+ * existing names in any of the scopes containing the current name), as many
+ * of these checkes require search engine. Use [checkFinalConditions] for this
+ * level of checking.
+ */
+ RefactoringStatus checkName();
+}
+
+
+/**
* Abstract interface for all refactorings.
*/
abstract class Refactoring {

Powered by Google App Engine
This is Rietveld 408576698