| Index: pkg/analysis_server/lib/src/services/correction/fix_internal.dart
|
| diff --git a/pkg/analysis_server/lib/src/services/correction/fix_internal.dart b/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
|
| index 3accd66aef277792cc2b45ff0a7fb41c4c3def71..e25e759af336bc0d06d96fb26618bb6ba8fe76ff 100644
|
| --- a/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
|
| +++ b/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
|
| @@ -1167,7 +1167,7 @@ class FixProcessor {
|
| ClassDeclaration targetClassNode = targetTypeNode;
|
| // prepare location
|
| ClassMemberLocation targetLocation =
|
| - utils.prepareNewFieldLocation(targetClassNode);
|
| + _getUtilsFor(targetClassNode).prepareNewFieldLocation(targetClassNode);
|
| // build field source
|
| Source targetSource = targetClassElement.source;
|
| String targetFile = targetSource.fullName;
|
| @@ -1324,7 +1324,7 @@ class FixProcessor {
|
| ClassDeclaration targetClassNode = targetTypeNode;
|
| // prepare location
|
| ClassMemberLocation targetLocation =
|
| - utils.prepareNewGetterLocation(targetClassNode);
|
| + _getUtilsFor(targetClassNode).prepareNewGetterLocation(targetClassNode);
|
| // build method source
|
| Source targetSource = targetClassElement.source;
|
| String targetFile = targetSource.fullName;
|
| @@ -2866,6 +2866,26 @@ class FixProcessor {
|
| }
|
|
|
| /**
|
| + * Return the correction utilities that should be used when creating an edit
|
| + * in the compilation unit containing the given [node].
|
| + */
|
| + CorrectionUtils _getUtilsFor(AstNode node) {
|
| + CompilationUnit targetUnit =
|
| + node.getAncestor((node) => node is CompilationUnit);
|
| + CompilationUnitElement targetUnitElement = targetUnit?.element;
|
| + CorrectionUtils realUtils = utils;
|
| + if (targetUnitElement != utils.unit.element) {
|
| + realUtils = new CorrectionUtils(targetUnit);
|
| + ClassDeclaration targetClass =
|
| + node.getAncestor((node) => node is ClassDeclaration);
|
| + if (targetClass != null) {
|
| + realUtils.targetClassElement = targetClass.element;
|
| + }
|
| + }
|
| + return realUtils;
|
| + }
|
| +
|
| + /**
|
| * Returns an expected [DartType] of [expression], may be `null` if cannot be
|
| * inferred.
|
| */
|
|
|