@@ -23,7 +23,7 @@ import 'package:test/test.dart';
2323mixin ElementsTypesMixin {
2424 InterfaceTypeImpl get boolNone {
2525 var element = typeProvider.boolElement2;
26- return interfaceTypeNone2 (element);
26+ return interfaceTypeNone (element);
2727 }
2828
2929 InterfaceTypeImpl get boolQuestion {
@@ -33,7 +33,7 @@ mixin ElementsTypesMixin {
3333
3434 InterfaceTypeImpl get doubleNone {
3535 var element = typeProvider.doubleElement2;
36- return interfaceTypeNone2 (element);
36+ return interfaceTypeNone (element);
3737 }
3838
3939 InterfaceTypeImpl get doubleQuestion {
@@ -45,7 +45,7 @@ mixin ElementsTypesMixin {
4545
4646 InterfaceTypeImpl get functionNone {
4747 var element = typeProvider.functionElement2;
48- return interfaceTypeNone2 (element);
48+ return interfaceTypeNone (element);
4949 }
5050
5151 InterfaceTypeImpl get functionQuestion {
@@ -55,7 +55,7 @@ mixin ElementsTypesMixin {
5555
5656 InterfaceTypeImpl get intNone {
5757 var element = typeProvider.intElement2;
58- return interfaceTypeNone2 (element);
58+ return interfaceTypeNone (element);
5959 }
6060
6161 InterfaceTypeImpl get intQuestion {
@@ -71,12 +71,12 @@ mixin ElementsTypesMixin {
7171
7272 InterfaceTypeImpl get nullNone {
7373 var element = typeProvider.nullElement2;
74- return interfaceTypeNone2 (element);
74+ return interfaceTypeNone (element);
7575 }
7676
7777 InterfaceTypeImpl get numNone {
7878 var element = typeProvider.numElement2;
79- return interfaceTypeNone2 (element);
79+ return interfaceTypeNone (element);
8080 }
8181
8282 InterfaceTypeImpl get numQuestion {
@@ -86,7 +86,7 @@ mixin ElementsTypesMixin {
8686
8787 InterfaceTypeImpl get objectNone {
8888 var element = typeProvider.objectElement2;
89- return interfaceTypeNone2 (element);
89+ return interfaceTypeNone (element);
9090 }
9191
9292 InterfaceTypeImpl get objectQuestion {
@@ -96,12 +96,12 @@ mixin ElementsTypesMixin {
9696
9797 InterfaceTypeImpl get recordNone {
9898 var element = typeProvider.recordElement2;
99- return interfaceTypeNone2 (element);
99+ return interfaceTypeNone (element);
100100 }
101101
102102 InterfaceTypeImpl get stringNone {
103103 var element = typeProvider.stringElement2;
104- return interfaceTypeNone2 (element);
104+ return interfaceTypeNone (element);
105105 }
106106
107107 InterfaceTypeImpl get stringQuestion {
@@ -200,10 +200,21 @@ mixin ElementsTypesMixin {
200200 required String name,
201201 required List <ConstFieldElementImpl > constants,
202202 }) {
203- var element = EnumElementImpl (name, 0 );
204- EnumElementImpl2 (Reference .root (), element);
205- element.enclosingElement3 = testLibrary.definingCompilationUnit;
206- element.fields = constants;
203+ var fragment = EnumElementImpl (name, 0 );
204+ EnumElementImpl2 (Reference .root (), fragment);
205+ fragment.enclosingElement3 = testLibrary.definingCompilationUnit;
206+ fragment.fields = constants;
207+ return fragment;
208+ }
209+
210+ EnumElementImpl2 enum_2 ({
211+ required String name,
212+ required List <ConstFieldElementImpl > constants,
213+ }) {
214+ var fragment = EnumElementImpl (name, 0 );
215+ var element = EnumElementImpl2 (Reference .root (), fragment);
216+ fragment.enclosingElement3 = testLibrary.definingCompilationUnit;
217+ fragment.fields = constants;
207218 return element;
208219 }
209220
@@ -256,6 +267,32 @@ mixin ElementsTypesMixin {
256267 return fragment;
257268 }
258269
270+ ExtensionTypeElementImpl2 extensionType2 (
271+ String name, {
272+ String representationName = 'it' ,
273+ required TypeImpl representationType,
274+ List <TypeParameterElementImpl2 > typeParameters = const [],
275+ List <InterfaceType > interfaces = const [],
276+ }) {
277+ var fragment = ExtensionTypeElementImpl (name, - 1 );
278+ fragment.enclosingElement3 = testLibrary.definingCompilationUnit;
279+ fragment.typeParameters = typeParameters.map ((e) => e.asElement).toList ();
280+ fragment.interfaces = interfaces;
281+
282+ var field = FieldElementImpl (representationName, - 1 );
283+ field.type = representationType;
284+ fragment.fields = [field];
285+
286+ var element = ExtensionTypeElementImpl2 (Reference .root (), fragment);
287+ element
288+ ..representation = field
289+ ..typeErasure = representationType
290+ ..interfaces = fragment.interfaces
291+ ..fields = fragment.fields;
292+
293+ return element;
294+ }
295+
259296 FunctionTypeImpl functionType ({
260297 required List <TypeParameterElementImpl2 > typeParameters,
261298 required List <FormalParameterElementImpl > formalParameters,
@@ -336,16 +373,6 @@ mixin ElementsTypesMixin {
336373 }
337374
338375 InterfaceTypeImpl interfaceTypeNone (
339- InterfaceElementImpl element, {
340- List <DartType > typeArguments = const [],
341- }) {
342- return element.instantiate (
343- typeArguments: typeArguments,
344- nullabilitySuffix: NullabilitySuffix .none,
345- );
346- }
347-
348- InterfaceTypeImpl interfaceTypeNone2 (
349376 InterfaceElementImpl2 element, {
350377 List <DartType > typeArguments = const [],
351378 }) {
@@ -485,6 +512,29 @@ mixin ElementsTypesMixin {
485512 return fragment;
486513 }
487514
515+ MixinElementImpl2 mixin_2 ({
516+ required String name,
517+ bool isAugmentation = false ,
518+ List <TypeParameterElementImpl2 > typeParameters = const [],
519+ List <InterfaceType >? constraints,
520+ List <InterfaceType > interfaces = const [],
521+ }) {
522+ var fragment = MixinElementImpl (name, 0 );
523+ fragment.isAugmentation = isAugmentation;
524+ fragment.enclosingElement3 = testLibrary.definingCompilationUnit;
525+ fragment.typeParameters = typeParameters.map ((e) => e.asElement).toList ();
526+ fragment.superclassConstraints = constraints ?? [typeProvider.objectType];
527+ fragment.interfaces = interfaces;
528+ fragment.constructors = const < ConstructorElementImpl > [];
529+
530+ var element = MixinElementImpl2 (Reference .root (), fragment);
531+ element.superclassConstraints = fragment.superclassConstraints;
532+ element.interfaces = fragment.interfaces;
533+ element.methods = fragment.methods;
534+
535+ return element;
536+ }
537+
488538 FormalParameterElementImpl namedParameter ({
489539 required String name,
490540 required TypeImpl type,
@@ -714,6 +764,31 @@ class _MockSource implements Source {
714764 noSuchMethod (Invocation invocation) => super .noSuchMethod (invocation);
715765}
716766
767+ extension ClassElementImpl2Extension on ClassElementImpl2 {
768+ void addAugmentations (List <ClassElementImpl > augmentations) {
769+ var augmentationTarget = fragments.last;
770+ for (var augmentation in augmentations) {
771+ expect (augmentation.isAugmentation, isTrue);
772+ augmentationTarget.augmentation = augmentation;
773+ augmentation.augmentationTargetAny = augmentationTarget;
774+ augmentationTarget = augmentation;
775+
776+ expect (augmentation.typeParameters, isEmpty,
777+ reason: 'Not supported in tests' );
778+
779+ interfaces = [
780+ ...interfaces,
781+ ...augmentation.interfaces,
782+ ];
783+
784+ mixins = [
785+ ...mixins,
786+ ...augmentation.mixins,
787+ ];
788+ }
789+ }
790+ }
791+
717792extension ClassElementImplExtension on ClassElementImpl {
718793 void addAugmentations (List <ClassElementImpl > augmentations) {
719794 var augmentationTarget = this ;
@@ -744,6 +819,31 @@ extension ClassElementImplExtension on ClassElementImpl {
744819 }
745820}
746821
822+ extension MixinElementImpl2Extension on MixinElementImpl2 {
823+ void addAugmentations (List <MixinElementImpl > augmentations) {
824+ var augmentationTarget = fragments.last;
825+ for (var augmentation in augmentations) {
826+ expect (augmentation.isAugmentation, isTrue);
827+ augmentationTarget.augmentation = augmentation;
828+ augmentation.augmentationTargetAny = augmentationTarget;
829+ augmentationTarget = augmentation;
830+
831+ expect (augmentation.typeParameters, isEmpty,
832+ reason: 'Not supported in tests' );
833+
834+ superclassConstraints = [
835+ ...superclassConstraints,
836+ ...augmentation.superclassConstraints,
837+ ];
838+
839+ interfaces = [
840+ ...interfaces,
841+ ...augmentation.interfaces,
842+ ];
843+ }
844+ }
845+ }
846+
747847extension MixinElementImplExtension on MixinElementImpl {
748848 void addAugmentations (List <MixinElementImpl > augmentations) {
749849 var augmentationTarget = this ;
0 commit comments