| 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 ae697914485764c60eb9dae7eb814f5a08625423..50e03ab9d41f17722a1d33e70cc242efdd20ab87 100644
|
| --- a/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
|
| +++ b/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
|
| @@ -146,6 +146,15 @@ class FixProcessor {
|
| if (errorCode == HintCode.TYPE_CHECK_IS_NULL) {
|
| _addFix_isNull();
|
| }
|
| + if (errorCode == HintCode.UNDEFINED_GETTER) {
|
| + _addFix_undefinedClassAccessor_useSimilar();
|
| + _addFix_createField();
|
| + _addFix_createGetter();
|
| + }
|
| + if (errorCode == HintCode.UNDEFINED_SETTER) {
|
| + _addFix_undefinedClassAccessor_useSimilar();
|
| + _addFix_createField();
|
| + }
|
| if (errorCode == HintCode.UNNECESSARY_CAST) {
|
| _addFix_removeUnnecessaryCast();
|
| }
|
| @@ -253,6 +262,7 @@ class FixProcessor {
|
| _addFix_undefinedFunction_create();
|
| }
|
| if (errorCode == StaticTypeWarningCode.UNDEFINED_SETTER) {
|
| + _addFix_undefinedClassAccessor_useSimilar();
|
| _addFix_createField();
|
| }
|
| // done
|
| @@ -393,46 +403,6 @@ class FixProcessor {
|
| _addFix(FixKind.CREATE_CONSTRUCTOR_FOR_FINAL_FIELDS, []);
|
| }
|
|
|
| - /**
|
| - * Here we handle cases when a constructors does not initialize all of the
|
| - * final fields.
|
| - */
|
| - void _addFix_updateConstructor_forUninitializedFinalFields() {
|
| - if (node is! SimpleIdentifier || node.parent is! ConstructorDeclaration) {
|
| - return;
|
| - }
|
| - ConstructorDeclaration constructor = node.parent;
|
| - // add these fields
|
| - List<FieldElement> fields =
|
| - error.getProperty(ErrorProperty.NOT_INITIALIZED_FIELDS);
|
| - if (fields != null) {
|
| - // prepare new parameters code
|
| - fields.sort((a, b) => a.nameOffset - b.nameOffset);
|
| - String fieldParametersCode =
|
| - fields.map((field) => 'this.${field.name}').join(', ');
|
| - // prepare the last required parameter
|
| - FormalParameter lastRequiredParameter;
|
| - List<FormalParameter> parameters = constructor.parameters.parameters;
|
| - for (FormalParameter parameter in parameters) {
|
| - if (parameter.kind == ParameterKind.REQUIRED) {
|
| - lastRequiredParameter = parameter;
|
| - }
|
| - }
|
| - // append new field formal initializers
|
| - if (lastRequiredParameter != null) {
|
| - _addInsertEdit(lastRequiredParameter.end, ', $fieldParametersCode');
|
| - } else {
|
| - int offset = constructor.parameters.leftParenthesis.end;
|
| - if (parameters.isNotEmpty) {
|
| - fieldParametersCode += ', ';
|
| - }
|
| - _addInsertEdit(offset, fieldParametersCode);
|
| - }
|
| - // add proposal
|
| - _addFix(FixKind.ADD_FIELD_FORMAL_PARAMETERS, []);
|
| - }
|
| - }
|
| -
|
| void _addFix_createConstructor_insteadOfSyntheticDefault() {
|
| TypeName typeName = null;
|
| ConstructorName constructorName = null;
|
| @@ -1745,6 +1715,46 @@ class FixProcessor {
|
| }
|
| }
|
|
|
| + /**
|
| + * Here we handle cases when a constructors does not initialize all of the
|
| + * final fields.
|
| + */
|
| + void _addFix_updateConstructor_forUninitializedFinalFields() {
|
| + if (node is! SimpleIdentifier || node.parent is! ConstructorDeclaration) {
|
| + return;
|
| + }
|
| + ConstructorDeclaration constructor = node.parent;
|
| + // add these fields
|
| + List<FieldElement> fields =
|
| + error.getProperty(ErrorProperty.NOT_INITIALIZED_FIELDS);
|
| + if (fields != null) {
|
| + // prepare new parameters code
|
| + fields.sort((a, b) => a.nameOffset - b.nameOffset);
|
| + String fieldParametersCode =
|
| + fields.map((field) => 'this.${field.name}').join(', ');
|
| + // prepare the last required parameter
|
| + FormalParameter lastRequiredParameter;
|
| + List<FormalParameter> parameters = constructor.parameters.parameters;
|
| + for (FormalParameter parameter in parameters) {
|
| + if (parameter.kind == ParameterKind.REQUIRED) {
|
| + lastRequiredParameter = parameter;
|
| + }
|
| + }
|
| + // append new field formal initializers
|
| + if (lastRequiredParameter != null) {
|
| + _addInsertEdit(lastRequiredParameter.end, ', $fieldParametersCode');
|
| + } else {
|
| + int offset = constructor.parameters.leftParenthesis.end;
|
| + if (parameters.isNotEmpty) {
|
| + fieldParametersCode += ', ';
|
| + }
|
| + _addInsertEdit(offset, fieldParametersCode);
|
| + }
|
| + // add proposal
|
| + _addFix(FixKind.ADD_FIELD_FORMAL_PARAMETERS, []);
|
| + }
|
| + }
|
| +
|
| void _addFix_useEffectiveIntegerDivision() {
|
| for (AstNode n = node; n != null; n = n.parent) {
|
| if (n is MethodInvocation &&
|
|
|