Move FormalParameterReference hierarchy to framework.

Change-Id: If3dc2f14ca0d1dec41f8ed89dae5a37a8e4c6f2b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/308803
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
Konstantin Shcheglov 2023-06-12 20:32:45 +00:00 committed by Commit Queue
parent 131d999085
commit c6372d8f5c
11 changed files with 136 additions and 138 deletions

View file

@ -2,7 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:analysis_server/src/services/correction/fix/data_driven/parameter_reference.dart';
import 'package:analysis_server/src/services/refactoring/framework/formal_parameter.dart';
import 'package:analyzer/dart/ast/ast.dart';
/// A class that can be used to access a value from a target.
@ -29,7 +29,7 @@ abstract class AccessorResult {
/// An accessor that returns a specific argument from an argument list.
class ArgumentAccessor extends Accessor {
/// The parameter corresponding to the argument from the original invocation.
final ParameterReference parameter;
final FormalParameterReference parameter;
/// Initialize a newly created accessor to access the argument that
/// corresponds to the given [parameter].

View file

@ -4,9 +4,9 @@
import 'package:analysis_server/src/services/correction/fix/data_driven/accessor.dart';
import 'package:analysis_server/src/services/correction/fix/data_driven/expression.dart';
import 'package:analysis_server/src/services/correction/fix/data_driven/parameter_reference.dart';
import 'package:analysis_server/src/services/correction/fix/data_driven/transform_set_error_code.dart';
import 'package:analysis_server/src/services/correction/fix/data_driven/variable_scope.dart';
import 'package:analysis_server/src/services/refactoring/framework/formal_parameter.dart';
import 'package:analyzer/error/listener.dart';
/// A parser for the textual representation of a code fragment.
@ -176,12 +176,12 @@ class CodeFragmentParser {
// The error has already been reported.
return null;
}
ParameterReference reference;
FormalParameterReference reference;
if (token.kind == _TokenKind.identifier) {
reference = NamedParameterReference(token.lexeme);
reference = NamedFormalParameterReference(token.lexeme);
} else {
var argumentIndex = int.parse(token.lexeme);
reference = PositionalParameterReference(argumentIndex);
reference = PositionalFormalParameterReference(argumentIndex);
}
advance();
token = _expect(const [_TokenKind.closeSquareBracket]);

View file

@ -5,7 +5,7 @@
import 'package:analysis_server/src/services/correction/dart/data_driven.dart';
import 'package:analysis_server/src/services/correction/fix/data_driven/change.dart';
import 'package:analysis_server/src/services/correction/fix/data_driven/code_template.dart';
import 'package:analysis_server/src/services/correction/fix/data_driven/parameter_reference.dart';
import 'package:analysis_server/src/services/refactoring/framework/formal_parameter.dart';
import 'package:analysis_server/src/utilities/index_range.dart';
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/source/source_range.dart';
@ -45,7 +45,7 @@ class AddParameter extends ParameterModification {
/// The type change of a parameter.
class ChangeParameterType extends ParameterModification {
/// The location of the changed parameter.
final ParameterReference reference;
final FormalParameterReference reference;
/// The nullability of the parameter.
final String nullability;
@ -124,7 +124,7 @@ class ModifyParameters extends Change<_Data> {
if (argument == null) {
// If there is no argument corresponding to the parameter then we assume
// that the parameter was absent.
var index = reference is PositionalParameterReference
var index = reference is PositionalFormalParameterReference
? reference.index
: remainingArguments.last + 1;
remainingArguments.add(index);
@ -167,10 +167,10 @@ class ModifyParameters extends Change<_Data> {
var argumentValue = parameter.argumentValue;
if (argumentValue != null) {
switch (parameter.reference) {
case NamedParameterReference(:final name):
case NamedFormalParameterReference(:final name):
builder.write(name);
builder.write(': ');
case PositionalParameterReference():
case PositionalFormalParameterReference():
// Nothing.
}
argumentValue.writeOn(builder, templateContext);
@ -373,7 +373,7 @@ abstract class ParameterModification {}
/// The removal of an existing parameter.
class RemoveParameter extends ParameterModification {
/// The parameter that was removed.
final ParameterReference parameter;
final FormalParameterReference parameter;
/// Initialize a newly created parameter modification to represent the removal
/// of an existing [parameter].

View file

@ -1,63 +0,0 @@
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:analyzer/dart/ast/ast.dart';
/// A reference to a named formal parameter.
final class NamedParameterReference extends ParameterReference {
/// The name of the named formal parameter.
final String name;
/// Initialize a newly created reference to refer to the named formal
/// parameter with the given [name].
NamedParameterReference(this.name) : assert(name.isNotEmpty);
@override
Expression? argumentFrom(ArgumentList argumentList) {
for (var argument in argumentList.arguments) {
if (argument is NamedExpression && argument.name.label.name == name) {
return argument.expression;
}
}
return null;
}
@override
String toString() => name;
}
/// A reference to a formal parameter.
sealed class ParameterReference {
/// Return the expression used to compute the value of the referenced
/// formal parameter, or `null` if there is no argument corresponding to the
/// formal parameter. Note that for named formal parameters this will be an
/// expression whose parent is a named expression.
Expression? argumentFrom(ArgumentList argumentList);
}
/// A reference to a positional formal parameter.
final class PositionalParameterReference extends ParameterReference {
/// The index of the positional formal parameter.
final int index;
/// Initialize a newly created reference to refer to the positional formal
/// parameter with the given [index].
PositionalParameterReference(this.index) : assert(index >= 0);
@override
Expression? argumentFrom(ArgumentList argumentList) {
var arguments = argumentList.arguments;
if (index >= arguments.length) {
return null;
}
var argument = arguments[index];
if (argument is NamedExpression) {
return null;
}
return argument;
}
@override
String toString() => '$index';
}

View file

@ -11,7 +11,6 @@ import 'package:analysis_server/src/services/correction/fix/data_driven/element_
import 'package:analysis_server/src/services/correction/fix/data_driven/element_kind.dart';
import 'package:analysis_server/src/services/correction/fix/data_driven/expression.dart';
import 'package:analysis_server/src/services/correction/fix/data_driven/modify_parameters.dart';
import 'package:analysis_server/src/services/correction/fix/data_driven/parameter_reference.dart';
import 'package:analysis_server/src/services/correction/fix/data_driven/rename.dart';
import 'package:analysis_server/src/services/correction/fix/data_driven/rename_parameter.dart';
import 'package:analysis_server/src/services/correction/fix/data_driven/replaced_by.dart';
@ -20,6 +19,7 @@ import 'package:analysis_server/src/services/correction/fix/data_driven/transfor
import 'package:analysis_server/src/services/correction/fix/data_driven/transform_set_error_code.dart';
import 'package:analysis_server/src/services/correction/fix/data_driven/value_generator.dart';
import 'package:analysis_server/src/services/correction/fix/data_driven/variable_scope.dart';
import 'package:analysis_server/src/services/refactoring/framework/formal_parameter.dart';
import 'package:analyzer/error/listener.dart';
import 'package:analyzer/src/util/yaml.dart';
import 'package:analyzer/src/utilities/extensions/string.dart';
@ -538,7 +538,7 @@ class TransformSetParser {
ErrorContext(key: _indexKey, parentNode: node),
);
if (index != null) {
return PositionalParameterReference(index);
return PositionalFormalParameterReference(index);
}
},
const {_nameKey}: (key, value) {
@ -547,7 +547,7 @@ class TransformSetParser {
ErrorContext(key: _nameKey, parentNode: node),
);
if (name != null) {
return NamedParameterReference(name);
return NamedFormalParameterReference(name);
}
},
},
@ -934,7 +934,7 @@ class TransformSetParser {
// The error has already been reported.
return null;
}
return PositionalParameterReference(index);
return PositionalFormalParameterReference(index);
},
{_nameKey}: (key, value) {
var name = _translateString(
@ -945,7 +945,7 @@ class TransformSetParser {
// The error has already been reported.
return null;
}
return NamedParameterReference(name);
return NamedFormalParameterReference(name);
},
},
errorNode: node,

View file

@ -2,10 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:analysis_server/src/services/correction/fix/data_driven/parameter_reference.dart';
import 'package:analysis_server/src/services/correction/util.dart';
import 'package:analysis_server/src/services/refactoring/framework/formal_parameter.dart'
show FormalParameterKind;
import 'package:analysis_server/src/services/refactoring/framework/formal_parameter.dart';
import 'package:analysis_server/src/services/refactoring/framework/refactoring_context.dart';
import 'package:analysis_server/src/services/refactoring/framework/write_invocation_arguments.dart'
as framework;
@ -714,14 +712,14 @@ class _SignatureUpdater {
}
}
ParameterReference _asFrameworkFormalParameterReference(
FormalParameterReference _asFrameworkFormalParameterReference(
FormalParameterState existing,
) {
final positionalIndex = existing.positionalIndex;
if (positionalIndex != null) {
return PositionalParameterReference(positionalIndex);
return PositionalFormalParameterReference(positionalIndex);
} else {
return NamedParameterReference(existing.name);
return NamedFormalParameterReference(existing.name);
}
}
}

View file

@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:analyzer/dart/ast/ast.dart';
/// The kind of a formal parameter.
enum FormalParameterKind {
requiredPositional,
@ -21,3 +23,62 @@ enum FormalParameterKind {
return this == requiredPositional || this == optionalPositional;
}
}
/// A reference to a formal parameter.
sealed class FormalParameterReference {
/// Return the expression used to compute the value of the referenced
/// formal parameter, or `null` if there is no argument corresponding to the
/// formal parameter. Note that for named formal parameters this will be an
/// expression whose parent is a named expression.
Expression? argumentFrom(ArgumentList argumentList);
}
/// A reference to a named formal parameter.
final class NamedFormalParameterReference extends FormalParameterReference {
/// The name of the named formal parameter.
final String name;
/// Initialize a newly created reference to refer to the named formal
/// parameter with the given [name].
NamedFormalParameterReference(this.name) : assert(name.isNotEmpty);
@override
Expression? argumentFrom(ArgumentList argumentList) {
for (var argument in argumentList.arguments) {
if (argument is NamedExpression && argument.name.label.name == name) {
return argument.expression;
}
}
return null;
}
@override
String toString() => name;
}
/// A reference to a positional formal parameter.
final class PositionalFormalParameterReference
extends FormalParameterReference {
/// The index of the positional formal parameter.
final int index;
/// Initialize a newly created reference to refer to the positional formal
/// parameter with the given [index].
PositionalFormalParameterReference(this.index) : assert(index >= 0);
@override
Expression? argumentFrom(ArgumentList argumentList) {
var arguments = argumentList.arguments;
if (index >= arguments.length) {
return null;
}
var argument = arguments[index];
if (argument is NamedExpression) {
return null;
}
return argument;
}
@override
String toString() => '$index';
}

View file

@ -2,8 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:analysis_server/src/services/correction/fix/data_driven/parameter_reference.dart';
import 'package:analysis_server/src/services/correction/util.dart';
import 'package:analysis_server/src/services/refactoring/framework/formal_parameter.dart';
import 'package:analyzer/dart/analysis/results.dart';
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/ast/token.dart';
@ -29,7 +29,7 @@ Future<ChangeStatus> writeArguments({
switch (update) {
case FormalParameterUpdateExisting(:final reference):
switch (reference) {
case NamedParameterReference():
case NamedFormalParameterReference():
final argument = namedArguments[reference.name];
if (argument == null) {
return ChangeStatusFailure();
@ -48,7 +48,7 @@ Future<ChangeStatus> writeArguments({
),
);
}
case PositionalParameterReference():
case PositionalFormalParameterReference():
final argument = positionArguments.elementAtOrNull(reference.index);
if (argument == null) {
return ChangeStatusFailure();
@ -140,7 +140,7 @@ sealed class FormalParameterUpdate {}
/// Existing formal parameter update.
sealed class FormalParameterUpdateExisting extends FormalParameterUpdate {
/// The original formal parameter reference.
final ParameterReference reference;
final FormalParameterReference reference;
FormalParameterUpdateExisting({
required this.reference,

View file

@ -4,9 +4,9 @@
import 'package:analysis_server/src/services/correction/fix/data_driven/accessor.dart';
import 'package:analysis_server/src/services/correction/fix/data_driven/code_template.dart';
import 'package:analysis_server/src/services/correction/fix/data_driven/parameter_reference.dart';
import 'package:analysis_server/src/services/correction/fix/data_driven/value_generator.dart';
import 'package:analysis_server/src/services/correction/util.dart';
import 'package:analysis_server/src/services/refactoring/framework/formal_parameter.dart';
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer_plugin/utilities/change_builder/change_builder_core.dart';
import 'package:test/test.dart';
@ -91,6 +91,6 @@ void g(int x, int y) {}
TemplateText _text(String text) => TemplateText(text);
TemplateVariable _variable(int index) => TemplateVariable(
CodeFragment([ArgumentAccessor(PositionalParameterReference(index))]));
TemplateVariable _variable(int index) => TemplateVariable(CodeFragment(
[ArgumentAccessor(PositionalFormalParameterReference(index))]));
}

View file

@ -6,9 +6,9 @@ import 'package:analysis_server/src/services/correction/fix/data_driven/changes_
import 'package:analysis_server/src/services/correction/fix/data_driven/element_descriptor.dart';
import 'package:analysis_server/src/services/correction/fix/data_driven/element_kind.dart';
import 'package:analysis_server/src/services/correction/fix/data_driven/modify_parameters.dart';
import 'package:analysis_server/src/services/correction/fix/data_driven/parameter_reference.dart';
import 'package:analysis_server/src/services/correction/fix/data_driven/rename.dart';
import 'package:analysis_server/src/services/correction/fix/data_driven/transform.dart';
import 'package:analysis_server/src/services/refactoring/framework/formal_parameter.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
import 'data_driven_test_support.dart';
@ -334,7 +334,7 @@ class C {
'm',
'C'
], [
RemoveParameter(PositionalParameterReference(0)),
RemoveParameter(PositionalFormalParameterReference(0)),
AddParameter(2, 'c', true, true, codeTemplate('2'))
], newName: 'm2'));
await resolveTestCode('''
@ -365,7 +365,7 @@ class C {
'm',
'C'
], [
RemoveParameter(PositionalParameterReference(1)),
RemoveParameter(PositionalFormalParameterReference(1)),
AddParameter(0, 'a', true, true, codeTemplate('0'))
], newName: 'm2'));
await resolveTestCode('''
@ -397,8 +397,8 @@ class C {
'C'
], [
AddParameter(1, 'c', true, false, codeTemplate('3')),
RemoveParameter(NamedParameterReference('b')),
RemoveParameter(NamedParameterReference('d')),
RemoveParameter(NamedFormalParameterReference('b')),
RemoveParameter(NamedFormalParameterReference('d')),
], newName: 'm2'));
await resolveTestCode('''
import '$importUri';
@ -428,8 +428,8 @@ class C {
'm1',
'C'
], [
RemoveParameter(PositionalParameterReference(0)),
RemoveParameter(PositionalParameterReference(1)),
RemoveParameter(PositionalFormalParameterReference(0)),
RemoveParameter(PositionalFormalParameterReference(1)),
AddParameter(0, 'c', true, true, codeTemplate('2')),
], newName: 'm2'));
await resolveTestCode('''
@ -460,8 +460,8 @@ class C {
'm1',
'C'
], [
RemoveParameter(PositionalParameterReference(1)),
RemoveParameter(PositionalParameterReference(2)),
RemoveParameter(PositionalFormalParameterReference(1)),
RemoveParameter(PositionalFormalParameterReference(2)),
AddParameter(1, 'd', true, true, codeTemplate('3')),
], newName: 'm2'));
await resolveTestCode('''
@ -493,8 +493,8 @@ class C {
'C'
], [
AddParameter(0, 'a', true, true, codeTemplate('0')),
RemoveParameter(PositionalParameterReference(1)),
RemoveParameter(PositionalParameterReference(3)),
RemoveParameter(PositionalFormalParameterReference(1)),
RemoveParameter(PositionalFormalParameterReference(3)),
AddParameter(2, 'd', true, true, codeTemplate('3')),
], newName: 'm2'));
await resolveTestCode('''
@ -526,7 +526,7 @@ class C {
'C'
], [
AddParameter(0, 'b', true, false, codeTemplate('0')),
RemoveParameter(NamedParameterReference('a')),
RemoveParameter(NamedFormalParameterReference('a')),
], newName: 'm2'));
await resolveTestCode('''
import '$importUri';
@ -557,7 +557,7 @@ class C {
'C'
], [
AddParameter(0, 'b', true, false, codeTemplate('0')),
RemoveParameter(NamedParameterReference('a')),
RemoveParameter(NamedFormalParameterReference('a')),
], newName: 'm2'));
await resolveTestCode('''
import '$importUri';
@ -594,7 +594,7 @@ class C {
'm',
'C'
], [
RemoveParameter(NamedParameterReference('a')),
RemoveParameter(NamedFormalParameterReference('a')),
AddParameter(1, 'b', true, false, codeTemplate('1')),
AddParameter(2, 'd', true, false, codeTemplate('2')),
AddParameter(3, 'e', true, false, codeTemplate('3')),
@ -624,7 +624,7 @@ class C {
}
''');
setPackageData(_modify(
['m', 'C'], [RemoveParameter(NamedParameterReference('a'))],
['m', 'C'], [RemoveParameter(NamedFormalParameterReference('a'))],
newName: 'm2'));
await resolveTestCode('''
import '$importUri';
@ -651,7 +651,7 @@ class C {
}
''');
setPackageData(_modify(
['m', 'C'], [RemoveParameter(PositionalParameterReference(0))],
['m', 'C'], [RemoveParameter(PositionalFormalParameterReference(0))],
newName: 'm2'));
await resolveTestCode('''
import '$importUri';
@ -678,7 +678,7 @@ class C {
}
''');
setPackageData(_modify(
['m', 'C'], [RemoveParameter(PositionalParameterReference(0))],
['m', 'C'], [RemoveParameter(PositionalFormalParameterReference(0))],
newName: 'm2'));
await resolveTestCode('''
import '$importUri';
@ -705,7 +705,7 @@ class C {
}
''');
setPackageData(_modify(
['m', 'C'], [RemoveParameter(NamedParameterReference('b'))],
['m', 'C'], [RemoveParameter(NamedFormalParameterReference('b'))],
newName: 'm2'));
await resolveTestCode('''
import '$importUri';
@ -732,7 +732,7 @@ class C {
}
''');
setPackageData(_modify(
['m', 'C'], [RemoveParameter(PositionalParameterReference(1))],
['m', 'C'], [RemoveParameter(PositionalFormalParameterReference(1))],
newName: 'm2'));
await resolveTestCode('''
import '$importUri';
@ -759,7 +759,7 @@ class C {
}
''');
setPackageData(_modify(
['m', 'C'], [RemoveParameter(PositionalParameterReference(1))],
['m', 'C'], [RemoveParameter(PositionalFormalParameterReference(1))],
newName: 'm2'));
await resolveTestCode('''
import '$importUri';
@ -784,8 +784,8 @@ class C {
void m({int a, @deprecated int b, int c}) {}
}
''');
setPackageData(
_modify(['m', 'C'], [RemoveParameter(NamedParameterReference('b'))]));
setPackageData(_modify(
['m', 'C'], [RemoveParameter(NamedFormalParameterReference('b'))]));
await resolveTestCode('''
import '$importUri';
@ -814,9 +814,9 @@ class C {
'm',
'C'
], [
RemoveParameter(PositionalParameterReference(0)),
RemoveParameter(PositionalParameterReference(2)),
RemoveParameter(PositionalParameterReference(3)),
RemoveParameter(PositionalFormalParameterReference(0)),
RemoveParameter(PositionalFormalParameterReference(2)),
RemoveParameter(PositionalFormalParameterReference(3)),
], newName: 'm2'));
await resolveTestCode('''
import '$importUri';
@ -843,7 +843,7 @@ class C {
}
''');
setPackageData(_modify(
['m', 'C'], [RemoveParameter(NamedParameterReference('a'))],
['m', 'C'], [RemoveParameter(NamedFormalParameterReference('a'))],
newName: 'm2'));
await resolveTestCode('''
import '$importUri';
@ -870,7 +870,7 @@ class C {
}
''');
setPackageData(_modify(
['m', 'C'], [RemoveParameter(NamedParameterReference('a'))],
['m', 'C'], [RemoveParameter(NamedFormalParameterReference('a'))],
newName: 'm2'));
await resolveTestCode('''
import '$importUri';
@ -897,7 +897,7 @@ class C {
}
''');
setPackageData(_modify(
['m', 'C'], [RemoveParameter(PositionalParameterReference(0))],
['m', 'C'], [RemoveParameter(PositionalFormalParameterReference(0))],
newName: 'm2'));
await resolveTestCode('''
import '$importUri';
@ -925,7 +925,7 @@ class C {
}
''');
setPackageData(_modify(
['m', 'C'], [RemoveParameter(PositionalParameterReference(0))],
['m', 'C'], [RemoveParameter(PositionalFormalParameterReference(0))],
newName: 'm2'));
await resolveTestCode('''
import '$importUri';
@ -952,7 +952,7 @@ class C {
}
''');
setPackageData(_modify(
['m', 'C'], [RemoveParameter(PositionalParameterReference(0))],
['m', 'C'], [RemoveParameter(PositionalFormalParameterReference(0))],
newName: 'm2'));
await resolveTestCode('''
import '$importUri';
@ -1018,7 +1018,7 @@ void f(int a, int b) {}
void g(int b) {}
''');
setPackageData(_modify(
['f'], [RemoveParameter(PositionalParameterReference(0))],
['f'], [RemoveParameter(PositionalFormalParameterReference(0))],
newName: 'g'));
await resolveTestCode('''
import '$importUri';

View file

@ -11,12 +11,12 @@ import 'package:analysis_server/src/services/correction/fix/data_driven/element_
import 'package:analysis_server/src/services/correction/fix/data_driven/element_matcher.dart';
import 'package:analysis_server/src/services/correction/fix/data_driven/expression.dart';
import 'package:analysis_server/src/services/correction/fix/data_driven/modify_parameters.dart';
import 'package:analysis_server/src/services/correction/fix/data_driven/parameter_reference.dart';
import 'package:analysis_server/src/services/correction/fix/data_driven/rename.dart';
import 'package:analysis_server/src/services/correction/fix/data_driven/replaced_by.dart';
import 'package:analysis_server/src/services/correction/fix/data_driven/transform.dart';
import 'package:analysis_server/src/services/correction/fix/data_driven/transform_set_error_code.dart';
import 'package:analysis_server/src/services/correction/fix/data_driven/value_generator.dart';
import 'package:analysis_server/src/services/refactoring/framework/formal_parameter.dart';
import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
@ -70,7 +70,7 @@ transforms:
var components = modification.argumentValue!.components;
expect(components, hasLength(1));
var value = _accessor(components[0]) as ArgumentAccessor;
var parameter = value.parameter as PositionalParameterReference;
var parameter = value.parameter as PositionalFormalParameterReference;
expect(parameter.index, 1);
}
@ -145,7 +145,7 @@ transforms:
var components = modification.argumentValue!.components;
expect(components, hasLength(1));
var value = _accessor(components[0]) as ArgumentAccessor;
var parameter = value.parameter as PositionalParameterReference;
var parameter = value.parameter as PositionalFormalParameterReference;
expect(parameter.index, 1);
}
@ -187,7 +187,7 @@ transforms:
var components = modification.argumentValue!.components;
expect(components, hasLength(1));
var value = _accessor(components[0]) as ArgumentAccessor;
var parameter = value.parameter as PositionalParameterReference;
var parameter = value.parameter as PositionalFormalParameterReference;
expect(parameter.index, 1);
}
@ -232,11 +232,11 @@ transforms:
var components = modification.argumentValue!.components;
expect(components, hasLength(4));
var extractorA = _accessor(components[0]) as ArgumentAccessor;
var parameterA = extractorA.parameter as PositionalParameterReference;
var parameterA = extractorA.parameter as PositionalFormalParameterReference;
expect(parameterA.index, 1);
expect((components[1] as TemplateText).text, '(');
var extractorB = _accessor(components[2]) as ArgumentAccessor;
var parameterB = extractorB.parameter as PositionalParameterReference;
var parameterB = extractorB.parameter as PositionalFormalParameterReference;
expect(parameterB.index, 2);
expect((components[3] as TemplateText).text, ')');
}
@ -314,7 +314,7 @@ transforms:
var components = change.argumentValue.components;
expect(components, hasLength(1));
var value = _accessor(components[0]) as ArgumentAccessor;
var parameter = value.parameter as NamedParameterReference;
var parameter = value.parameter as NamedFormalParameterReference;
expect(parameter.name, 'p');
}
@ -358,7 +358,7 @@ transforms:
var argumentComponents = change.argumentValue.components;
expect(argumentComponents, hasLength(1));
var value = _accessor(argumentComponents[0]) as ArgumentAccessor;
var parameter = value.parameter as PositionalParameterReference;
var parameter = value.parameter as PositionalFormalParameterReference;
expect(parameter.index, 2);
}
@ -402,7 +402,7 @@ transforms:
var argumentComponents = change.argumentValue.components;
expect(argumentComponents, hasLength(1));
var value = _accessor(argumentComponents[0]) as ArgumentAccessor;
var parameter = value.parameter as PositionalParameterReference;
var parameter = value.parameter as PositionalFormalParameterReference;
expect(parameter.index, 2);
}
@ -452,7 +452,7 @@ transforms:
var modifications = change.modifications;
expect(modifications, hasLength(1));
var modification = modifications[0] as ChangeParameterType;
var reference = modification.reference as NamedParameterReference;
var reference = modification.reference as NamedFormalParameterReference;
expect(reference.name, 'p');
var components = modification.argumentValue!.components;
expect(components, hasLength(1));
@ -526,7 +526,8 @@ transforms:
var modifications = change.modifications;
expect(modifications, hasLength(1));
var modification = modifications[0] as ChangeParameterType;
var reference = modification.reference as PositionalParameterReference;
var reference =
modification.reference as PositionalFormalParameterReference;
expect(reference.index, 0);
var components = modification.argumentValue!.components;
expect(components, hasLength(1));
@ -721,7 +722,7 @@ transforms:
var modifications = change.modifications;
expect(modifications, hasLength(1));
var modification = modifications[0] as RemoveParameter;
var parameter = modification.parameter as NamedParameterReference;
var parameter = modification.parameter as NamedFormalParameterReference;
expect(parameter.name, 'p');
}
@ -748,7 +749,8 @@ transforms:
var modifications = change.modifications;
expect(modifications, hasLength(1));
var modification = modifications[0] as RemoveParameter;
var parameter = modification.parameter as PositionalParameterReference;
var parameter =
modification.parameter as PositionalFormalParameterReference;
expect(parameter.index, 0);
}
@ -913,7 +915,7 @@ transforms:
var components = argumentValue.components;
expect(components, hasLength(1));
var value = _accessor(components[0]) as ArgumentAccessor;
var parameter = value.parameter as PositionalParameterReference;
var parameter = value.parameter as PositionalFormalParameterReference;
expect(parameter.index, 1);
}