| Index: pkg/analysis_server/lib/src/services/refactoring/convert_method_to_getter.dart
|
| diff --git a/pkg/analysis_server/lib/src/services/refactoring/convert_method_to_getter.dart b/pkg/analysis_server/lib/src/services/refactoring/convert_method_to_getter.dart
|
| index 71cedecb5e10bc12fa569505cf91425614f79f07..5ba028e40852f99ccc3e65ad619a4dc0f517deb2 100644
|
| --- a/pkg/analysis_server/lib/src/services/refactoring/convert_method_to_getter.dart
|
| +++ b/pkg/analysis_server/lib/src/services/refactoring/convert_method_to_getter.dart
|
| @@ -97,12 +97,14 @@ class ConvertMethodToGetterRefactoringImpl extends RefactoringImpl
|
| // prepare parameters
|
| FormalParameterList parameters;
|
| {
|
| - AstNode node = await astProvider.getParsedNodeForElement(element);
|
| - if (node is MethodDeclaration) {
|
| - parameters = node.parameters;
|
| - }
|
| - if (node is FunctionDeclaration) {
|
| - parameters = node.functionExpression.parameters;
|
| + AstNode name = await astProvider.getParsedNameForElement(element);
|
| + AstNode declaration = name?.parent;
|
| + if (declaration is MethodDeclaration) {
|
| + parameters = declaration.parameters;
|
| + } else if (declaration is FunctionDeclaration) {
|
| + parameters = declaration.functionExpression.parameters;
|
| + } else {
|
| + return;
|
| }
|
| }
|
| // insert "get "
|
| @@ -127,7 +129,7 @@ class ConvertMethodToGetterRefactoringImpl extends RefactoringImpl
|
| MethodInvocation invocation;
|
| {
|
| CompilationUnit refUnit =
|
| - await astProvider.getResolvedUnitForElement(refElement);
|
| + await astProvider.getParsedUnitForElement(refElement);
|
| AstNode refNode =
|
| new NodeLocator(refRange.offset).searchWithin(refUnit);
|
| invocation = refNode.getAncestor((node) => node is MethodInvocation);
|
|
|