| Index: pkg/analysis_server/lib/src/services/refactoring/inline_local.dart
|
| diff --git a/pkg/analysis_server/lib/src/services/refactoring/inline_local.dart b/pkg/analysis_server/lib/src/services/refactoring/inline_local.dart
|
| index fdee7212086a1f5d03bf5c75a44d7442b1a68f34..2c4e11525fad771a3ea62a9c8d88765fda0ff705 100644
|
| --- a/pkg/analysis_server/lib/src/services/refactoring/inline_local.dart
|
| +++ b/pkg/analysis_server/lib/src/services/refactoring/inline_local.dart
|
| @@ -79,18 +79,11 @@ class InlineLocalRefactoringImpl extends RefactoringImpl implements
|
| }
|
| }
|
| }
|
| - if (_variableNode == null) {
|
| - result = new RefactoringStatus.fatal(
|
| - 'Local variable declaration or reference must be selected to activate this refactoring.');
|
| - return new Future.value(result);
|
| - }
|
| - // should be normal variable declaration statement
|
| - if (_variableNode.parent is! VariableDeclarationList ||
|
| - _variableNode.parent.parent is! VariableDeclarationStatement ||
|
| - _variableNode.parent.parent.parent is! Block) {
|
| + // validate node declaration
|
| + if (!_isVariableDeclaredInStatement()) {
|
| result = new RefactoringStatus.fatal(
|
| - 'Local variable declared in '
|
| - 'statement should be selected to activate this refactoring.');
|
| + 'Local variable declaration or reference must be selected '
|
| + 'to activate this refactoring.');
|
| return new Future.value(result);
|
| }
|
| // should have initializer at declaration
|
| @@ -188,6 +181,21 @@ class InlineLocalRefactoringImpl extends RefactoringImpl implements
|
| @override
|
| bool requiresPreview() => false;
|
|
|
| + bool _isVariableDeclaredInStatement() {
|
| + if (_variableNode == null) {
|
| + return false;
|
| + }
|
| + AstNode parent = _variableNode.parent;
|
| + if (parent is VariableDeclarationList) {
|
| + parent = parent.parent;
|
| + if (parent is VariableDeclarationStatement) {
|
| + parent = parent.parent;
|
| + return parent is Block || parent is SwitchCase;
|
| + }
|
| + }
|
| + return false;
|
| + }
|
| +
|
| static bool _shouldBeExpressionInterpolation(InterpolationExpression target,
|
| Expression expression) {
|
| TokenType targetType = target.beginToken.type;
|
|
|