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

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

Issue 498763003: Initial 'Extract Method' refactoring implementation. (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 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 91a0778be88aca1df6d7e0b44cb445eb6b3818fa..d93b572e7d8359b8b386caa7a9f2abb04be73a7b 100644
--- a/pkg/analysis_server/lib/src/services/refactoring/refactoring.dart
+++ b/pkg/analysis_server/lib/src/services/refactoring/refactoring.dart
@@ -6,9 +6,11 @@ library services.refactoring;
import 'dart:async';
-import 'package:analysis_server/src/protocol2.dart' show SourceChange;
+import 'package:analysis_server/src/protocol2.dart' show
+ RefactoringMethodParameter, SourceChange;
import 'package:analysis_server/src/services/correction/status.dart';
import 'package:analysis_server/src/services/refactoring/extract_local.dart';
+import 'package:analysis_server/src/services/refactoring/extract_method.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';
@@ -83,6 +85,99 @@ abstract class ExtractLocalRefactoring implements Refactoring {
/**
+ * [Refactoring] to extract an [Expression] or [Statement]s into a new method.
+ */
+abstract class ExtractMethodRefactoring implements Refactoring {
+ /**
+ * Returns a new [ExtractMethodRefactoring] instance.
+ */
+ factory ExtractMethodRefactoring(SearchEngine searchEngine,
+ CompilationUnit unit, int selectionOffset, int selectionLength) {
+ return new ExtractMethodRefactoringImpl(
+ searchEngine,
+ unit,
+ selectionOffset,
+ selectionLength);
+ }
+
+ /**
+ * True if a getter could be created rather than a method.
+ */
+ bool get canCreateGetter;
+
+ /**
+ * True if a getter should be created rather than a method.
+ */
+ void set createGetter(bool createGetter);
+
+ /**
+ * True if all occurrences of the expression or statements should be replaced
+ * by an invocation of the method. The expression or statements used to
+ * initiate the refactoring will always be replaced.
+ */
+ void set extractAll(bool extractAll);
+
+ /**
+ * The lengths of the expressions or statements that would be replaced by an
+ * invocation of the method. The lengths correspond to the offsets.
+ * In other words, for a given expression (or block of statements), 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 method should be given.
+ */
+ void set name(String name);
+
+ /**
+ * The proposed names for the method.
+ *
+ * The first proposal should be used as the "best guess" (if it exists).
+ */
+ List<String> get names;
+
+ /**
+ * The offsets of the expressions or statements that would be replaced by an
+ * invocation of the method.
+ */
+ List<int> get offsets;
+
+ /**
+ * The proposed parameters for the method.
+ */
+ List<RefactoringMethodParameter> get parameters;
+
+ /**
+ * The parameters that should be defined for the method.
+ */
+ void set parameters(List<RefactoringMethodParameter> parameters);
+
+ /**
+ * The proposed return type for the method.
+ */
+ String get returnType;
+
+ /**
+ * The return type that should be defined for the method.
+ */
+ void set returnType(String returnType);
+
+ /**
+ * Validates that the [name] is a valid identifier and is appropriate for a
+ * method.
+ *
+ * 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