| 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 a887ed69f0db5253e3c0d24a592a15292fc359bd..134dabc0406070ad4c1ae5e06820c4a28cfcdf89 100644
|
| --- a/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
|
| +++ b/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
|
| @@ -382,8 +382,8 @@ class FixProcessor {
|
| ClassElement targetElement = targetType.element as ClassElement;
|
| String targetFile = targetElement.source.fullName;
|
| ClassDeclaration targetClass = targetElement.node;
|
| - _ConstructorLocation targetLocation =
|
| - _prepareNewConstructorLocation(targetClass);
|
| + ConstructorLocation targetLocation =
|
| + utils.findNewConstructorLocation(targetClass);
|
| // build method source
|
| SourceBuilder sb = new SourceBuilder(targetFile, targetLocation.offset);
|
| {
|
| @@ -436,8 +436,8 @@ class FixProcessor {
|
| ClassElement targetElement = targetType.element as ClassElement;
|
| String targetFile = targetElement.source.fullName;
|
| ClassDeclaration targetClass = targetElement.node;
|
| - _ConstructorLocation targetLocation =
|
| - _prepareNewConstructorLocation(targetClass);
|
| + ConstructorLocation targetLocation =
|
| + utils.findNewConstructorLocation(targetClass);
|
| // build method source
|
| SourceBuilder sb = new SourceBuilder(targetFile, targetLocation.offset);
|
| {
|
| @@ -572,8 +572,8 @@ class FixProcessor {
|
| argumentsBuffer.append(parameterName);
|
| }
|
| // add proposal
|
| - _ConstructorLocation targetLocation =
|
| - _prepareNewConstructorLocation(targetClassNode);
|
| + ConstructorLocation targetLocation =
|
| + utils.findNewConstructorLocation(targetClassNode);
|
| SourceBuilder sb = new SourceBuilder(file, targetLocation.offset);
|
| {
|
| String indent = utils.getIndent(1);
|
| @@ -2128,29 +2128,6 @@ class FixProcessor {
|
| return node is SimpleIdentifier && node.name == 'await';
|
| }
|
|
|
| - _ConstructorLocation _prepareNewConstructorLocation(
|
| - ClassDeclaration classDeclaration) {
|
| - List<ClassMember> members = classDeclaration.members;
|
| - // find the last field/constructor
|
| - ClassMember lastFieldOrConstructor = null;
|
| - for (ClassMember member in members) {
|
| - if (member is FieldDeclaration || member is ConstructorDeclaration) {
|
| - lastFieldOrConstructor = member;
|
| - } else {
|
| - break;
|
| - }
|
| - }
|
| - // after the last field/constructor
|
| - if (lastFieldOrConstructor != null) {
|
| - return new _ConstructorLocation(
|
| - eol + eol, lastFieldOrConstructor.end, '');
|
| - }
|
| - // at the beginning of the class
|
| - String suffix = members.isEmpty ? '' : eol;
|
| - return new _ConstructorLocation(
|
| - eol, classDeclaration.leftBracket.end, suffix);
|
| - }
|
| -
|
| _FieldLocation _prepareNewFieldLocation(ClassDeclaration classDeclaration) {
|
| String indent = utils.getIndent(1);
|
| // find the last field
|
| @@ -2305,17 +2282,6 @@ class _ClosestElementFinder {
|
| }
|
|
|
| /**
|
| - * Describes the location for a newly created [ConstructorDeclaration].
|
| - */
|
| -class _ConstructorLocation {
|
| - final String prefix;
|
| - final int offset;
|
| - final String suffix;
|
| -
|
| - _ConstructorLocation(this.prefix, this.offset, this.suffix);
|
| -}
|
| -
|
| -/**
|
| * Describes the location for a newly created [FieldDeclaration].
|
| */
|
| class _FieldLocation {
|
|
|