| Index: pkg/analysis_server/lib/src/services/refactoring/extract_method.dart
|
| diff --git a/pkg/analysis_server/lib/src/services/refactoring/extract_method.dart b/pkg/analysis_server/lib/src/services/refactoring/extract_method.dart
|
| index 361d537c14e27bc73630659971c4b66f02ba8b7d..5126105cadde10631b06d882d69c1f75d9ae2080 100644
|
| --- a/pkg/analysis_server/lib/src/services/refactoring/extract_method.dart
|
| +++ b/pkg/analysis_server/lib/src/services/refactoring/extract_method.dart
|
| @@ -71,6 +71,7 @@ class ExtractMethodRefactoringImpl extends RefactoringImpl
|
| String returnType;
|
| String name;
|
| bool extractAll = true;
|
| + bool canCreateGetter = false;
|
| bool createGetter = false;
|
| final List<String> names = <String>[];
|
| final List<int> offsets = <int>[];
|
| @@ -100,18 +101,29 @@ class ExtractMethodRefactoringImpl extends RefactoringImpl
|
| utils = new CorrectionUtils(unit);
|
| }
|
|
|
| - bool get canCreateGetter {
|
| + /**
|
| + * Initializes [canCreateGetter] flag.
|
| + */
|
| + bool _computeCanCreateGetter() {
|
| + // is a function expression
|
| + if (_selectionFunctionExpression != null) {
|
| + return false;
|
| + }
|
| + // has parameters
|
| if (!parameters.isEmpty) {
|
| return false;
|
| }
|
| + // is assignment
|
| if (_selectionExpression != null) {
|
| if (_selectionExpression is AssignmentExpression) {
|
| return false;
|
| }
|
| }
|
| + // doesn't return a value
|
| if (_selectionStatements != null) {
|
| return returnType != 'void';
|
| }
|
| + // OK
|
| return true;
|
| }
|
|
|
| @@ -188,10 +200,12 @@ class ExtractMethodRefactoringImpl extends RefactoringImpl
|
| // prepare parts
|
| result.addStatus(_initializeParameters());
|
| _initializeReturnType();
|
| - _initializeGetter();
|
| // occurrences
|
| _initializeOccurrences();
|
| _prepareOffsetsLengths();
|
| + // getter
|
| + canCreateGetter = _computeCanCreateGetter();
|
| + _initializeCreateGetter();
|
| // names
|
| _prepareExcludedNames();
|
| _prepareNames();
|
| @@ -511,7 +525,7 @@ class ExtractMethodRefactoringImpl extends RefactoringImpl
|
| /**
|
| * Initializes [createGetter] flag.
|
| */
|
| - void _initializeGetter() {
|
| + void _initializeCreateGetter() {
|
| createGetter = false;
|
| // maybe we cannot at all
|
| if (!canCreateGetter) {
|
|
|