Skip to content

Commit

Permalink
Elements. Rename to ClassElementImpl2, etc.
Browse files Browse the repository at this point in the history
Change-Id: I94119f60b5bf01e52cf348a7c67f2b4a5ba62900
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393583
Reviewed-by: Brian Wilkerson <[email protected]>
Commit-Queue: Konstantin Shcheglov <[email protected]>
  • Loading branch information
scheglov authored and Commit Queue committed Nov 5, 2024
1 parent 9d340db commit 53bf3ff
Show file tree
Hide file tree
Showing 11 changed files with 716 additions and 718 deletions.
1,261 changes: 630 additions & 631 deletions pkg/analyzer/lib/src/dart/element/element.dart

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pkg/analyzer/lib/src/generated/testing/element_factory.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class ElementFactory {
fragment.typeParameters = typeParameters(parameterNames);
}

var element = AugmentedClassElementImpl(Reference.root(), fragment);
var element = ClassElementImpl2(Reference.root(), fragment);
element.mixins = fragment.mixins;
element.interfaces = fragment.interfaces;

Expand Down Expand Up @@ -80,7 +80,7 @@ class ElementFactory {
fragment.interfaces = interfaces;
fragment.constructors = const <ConstructorElementImpl>[];

var element = AugmentedClassElementImpl(Reference.root(), fragment);
var element = ClassElementImpl2(Reference.root(), fragment);
element.mixins = fragment.mixins;
element.interfaces = fragment.interfaces;

Expand Down
22 changes: 11 additions & 11 deletions pkg/analyzer/lib/src/summary2/augmentation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import 'package:analyzer/src/dart/element/type_algebra.dart';
import 'package:analyzer/src/utilities/extensions/element.dart';
import 'package:analyzer/src/utilities/extensions/string.dart';

class ClassElementBuilder extends InstanceElementBuilder<
AugmentedClassElementImpl, ClassElementImpl> {
class ClassElementBuilder
extends InstanceElementBuilder<ClassElementImpl2, ClassElementImpl> {
ClassElementBuilder({
required super.element,
required super.firstFragment,
Expand All @@ -37,7 +37,7 @@ class ClassElementBuilder extends InstanceElementBuilder<
}

class EnumElementBuilder
extends InstanceElementBuilder<AugmentedEnumElementImpl, EnumElementImpl> {
extends InstanceElementBuilder<EnumElementImpl2, EnumElementImpl> {
EnumElementBuilder({
required super.element,
required super.firstFragment,
Expand All @@ -62,7 +62,7 @@ class EnumElementBuilder
}

class ExtensionElementBuilder extends InstanceElementBuilder<
AugmentedExtensionElementImpl, ExtensionElementImpl> {
ExtensionElementImpl2, ExtensionElementImpl> {
ExtensionElementBuilder({
required super.element,
required super.firstFragment,
Expand All @@ -86,7 +86,7 @@ class ExtensionElementBuilder extends InstanceElementBuilder<
}

class ExtensionTypeElementBuilder extends InstanceElementBuilder<
AugmentedExtensionTypeElementImpl, ExtensionTypeElementImpl> {
ExtensionTypeElementImpl2, ExtensionTypeElementImpl> {
ExtensionTypeElementBuilder({
required super.element,
required super.firstFragment,
Expand Down Expand Up @@ -154,7 +154,7 @@ class GetterElementBuilder extends FragmentedElementBuilder<GetterElementImpl,
}
}

abstract class InstanceElementBuilder<E extends AugmentedInstanceElementImpl,
abstract class InstanceElementBuilder<E extends InstanceElementImpl2,
F extends InstanceElementImpl> extends FragmentedElementBuilder<E, F> {
final Map<String, FieldElementImpl> fields = {};
final Map<String, ConstructorElementImpl> constructors = {};
Expand Down Expand Up @@ -252,15 +252,15 @@ abstract class InstanceElementBuilder<E extends AugmentedInstanceElementImpl,
augmented.accessors.addAll(firstFragment.accessors);
augmented.methods.addAll(firstFragment.methods);

if (augmented is AugmentedInterfaceElementImpl) {
if (augmented is InterfaceElementImpl2) {
if (firstFragment is InterfaceElementImpl) {
augmented.mixins.addAll(firstFragment.mixins);
augmented.interfaces.addAll(firstFragment.interfaces);
augmented.constructors.addAll(firstFragment.constructors);
}
}

if (augmented is AugmentedMixinElementImpl) {
if (augmented is MixinElementImpl2) {
if (firstFragment is MixinElementImpl) {
augmented.superclassConstraints.addAll(
firstFragment.superclassConstraints,
Expand Down Expand Up @@ -304,7 +304,7 @@ abstract class InstanceElementBuilder<E extends AugmentedInstanceElementImpl,

if (augmentation is InterfaceElementImpl &&
firstFragment is InterfaceElementImpl &&
element is AugmentedInterfaceElementImpl) {
element is InterfaceElementImpl2) {
element.constructors = [
...element.constructors.notAugmented,
...augmentation.constructors.notAugmented.map((element) {
Expand Down Expand Up @@ -353,8 +353,8 @@ abstract class InstanceElementBuilder<E extends AugmentedInstanceElementImpl,
}
}

class MixinElementBuilder extends InstanceElementBuilder<
AugmentedMixinElementImpl, MixinElementImpl> {
class MixinElementBuilder
extends InstanceElementBuilder<MixinElementImpl2, MixinElementImpl> {
MixinElementBuilder({
required super.element,
required super.firstFragment,
Expand Down
20 changes: 10 additions & 10 deletions pkg/analyzer/lib/src/summary2/bundle_reader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -728,10 +728,10 @@ class LibraryReader {
var element = ClassElementImpl(name, -1);
element.name2 = fragmentName;

if (reference2.element2 case AugmentedClassElementImpl element2?) {
if (reference2.element2 case ClassElementImpl2 element2?) {
element.augmentedInternal = element2;
} else {
AugmentedClassElementImpl(reference2, element);
ClassElementImpl2(reference2, element);
}

var linkedData = ClassElementLinkedData(
Expand Down Expand Up @@ -884,10 +884,10 @@ class LibraryReader {
var element = EnumElementImpl(name, -1);
element.name2 = fragmentName;

if (reference2.element2 case AugmentedEnumElementImpl element2?) {
if (reference2.element2 case EnumElementImpl2 element2?) {
element.augmentedInternal = element2;
} else {
AugmentedEnumElementImpl(reference2, element);
EnumElementImpl2(reference2, element);
}

var linkedData = EnumElementLinkedData(
Expand Down Expand Up @@ -983,10 +983,10 @@ class LibraryReader {
var element = ExtensionElementImpl(name, -1);
element.name2 = fragmentName;

if (reference2.element2 case AugmentedExtensionElementImpl element2?) {
if (reference2.element2 case ExtensionElementImpl2 element2?) {
element.augmentedInternal = element2;
} else {
AugmentedExtensionElementImpl(reference2, element);
ExtensionElementImpl2(reference2, element);
}

element.setLinkedData(
Expand Down Expand Up @@ -1040,10 +1040,10 @@ class LibraryReader {
var element = ExtensionTypeElementImpl(name, -1);
element.name2 = fragmentName;

if (reference2.element2 case AugmentedExtensionTypeElementImpl element2?) {
if (reference2.element2 case ExtensionTypeElementImpl2 element2?) {
element.augmentedInternal = element2;
} else {
AugmentedExtensionTypeElementImpl(reference2, element);
ExtensionTypeElementImpl2(reference2, element);
}

element.setLinkedData(
Expand Down Expand Up @@ -1349,10 +1349,10 @@ class LibraryReader {
var element = MixinElementImpl(name, -1);
element.name2 = fragmentName;

if (reference2.element2 case AugmentedMixinElementImpl element2?) {
if (reference2.element2 case MixinElementImpl2 element2?) {
element.augmentedInternal = element2;
} else {
AugmentedMixinElementImpl(reference2, element);
MixinElementImpl2(reference2, element);
}

var linkedData = MixinElementLinkedData(
Expand Down
15 changes: 7 additions & 8 deletions pkg/analyzer/lib/src/summary2/element_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class ElementBuilder extends ThrowingAstVisitor<void> {
var libraryRef = _libraryBuilder.reference;
var containerRef = libraryRef.getChild('@class');
var elementReference = containerRef.addChild(refName);
var element = AugmentedClassElementImpl(elementReference, fragment);
var element = ClassElementImpl2(elementReference, fragment);

elementBuilder = ClassElementBuilder(
element: element,
Expand Down Expand Up @@ -185,7 +185,7 @@ class ElementBuilder extends ThrowingAstVisitor<void> {
var refName = fragment.name2 ?? '${_nextUnnamedId++}';
var elementReference =
_libraryBuilder.reference.getChild('@class').addChild(refName);
AugmentedClassElementImpl(elementReference, fragment);
ClassElementImpl2(elementReference, fragment);

node.declaredElement = fragment;
_linker.elementNodes[fragment] = node;
Expand Down Expand Up @@ -288,7 +288,7 @@ class ElementBuilder extends ThrowingAstVisitor<void> {
var libraryRef = _libraryBuilder.reference;
var containerRef = libraryRef.getChild('@enum');
var elementReference = containerRef.addChild(refName);
var element = AugmentedEnumElementImpl(elementReference, fragment);
var element = EnumElementImpl2(elementReference, fragment);

elementBuilder = EnumElementBuilder(
firstFragment: fragment,
Expand Down Expand Up @@ -529,7 +529,7 @@ class ElementBuilder extends ThrowingAstVisitor<void> {
} else {
var elementReference =
_libraryBuilder.reference.getChild('@extension').addChild(refName);
var element = AugmentedExtensionElementImpl(elementReference, fragment);
var element = ExtensionElementImpl2(elementReference, fragment);

elementBuilder = ExtensionElementBuilder(
firstFragment: fragment,
Expand All @@ -540,7 +540,7 @@ class ElementBuilder extends ThrowingAstVisitor<void> {
} else {
var elementReference =
_libraryBuilder.reference.getChild('@extension').addChild(refName);
var element = AugmentedExtensionElementImpl(elementReference, fragment);
var element = ExtensionElementImpl2(elementReference, fragment);
elementBuilder = ExtensionElementBuilder(
firstFragment: fragment,
element: element,
Expand Down Expand Up @@ -599,8 +599,7 @@ class ElementBuilder extends ThrowingAstVisitor<void> {
var libraryRef = _libraryBuilder.reference;
var containerRef = libraryRef.getChild('@extensionType');
var elementReference = containerRef.addChild(refName);
var element =
AugmentedExtensionTypeElementImpl(elementReference, fragment);
var element = ExtensionTypeElementImpl2(elementReference, fragment);

elementBuilder = ExtensionTypeElementBuilder(
firstFragment: fragment,
Expand Down Expand Up @@ -1226,7 +1225,7 @@ class ElementBuilder extends ThrowingAstVisitor<void> {
var libraryRef = _libraryBuilder.reference;
var containerRef = libraryRef.getChild('@mixin');
var elementReference = containerRef.addChild(refName);
var element = AugmentedMixinElementImpl(elementReference, fragment);
var element = MixinElementImpl2(elementReference, fragment);

elementBuilder = MixinElementBuilder(
firstFragment: fragment,
Expand Down
4 changes: 2 additions & 2 deletions pkg/analyzer/lib/src/summary2/library_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ class LibraryBuilder with MacroApplicationsContainer {

classElement.constructors = [constructor].toFixedList();

if (classElement.augmented case AugmentedClassElementImpl augmented) {
if (classElement.augmented case ClassElementImpl2 augmented) {
augmented.constructors = classElement.constructors;
}
}
Expand Down Expand Up @@ -259,7 +259,7 @@ class LibraryBuilder with MacroApplicationsContainer {
constructor,
].toFixedList();

if (enumElement.augmented case AugmentedEnumElementImpl augmented) {
if (enumElement.augmented case EnumElementImpl2 augmented) {
augmented.constructors = enumElement.constructors;
}
}
Expand Down
72 changes: 36 additions & 36 deletions pkg/analyzer/lib/src/summary2/types_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -372,77 +372,77 @@ class TypesBuilder {
}

void _updatedAugmented(
InstanceElementImpl element, {
InstanceElementImpl fragment, {
WithClause? withClause,
}) {
// Always schedule mixin inference for the declaration.
if (element.augmentationTarget == null) {
if (element is InterfaceElementImpl) {
_toInferMixins[element] = _ToInferMixins(element, withClause);
if (fragment.augmentationTarget == null) {
if (fragment is InterfaceElementImpl) {
_toInferMixins[fragment] = _ToInferMixins(fragment, withClause);
}
}

// Here we merge declaration and augmentations.
// If there are no augmentations, nothing to do.
var augmented = element.augmented;
if (augmented is! AugmentedInstanceElementImpl) {
var element = fragment.element;
if (element is! InstanceElementImpl2) {
return;
}

var declaration = augmented.firstFragment;
var declarationTypeParameters = declaration.typeParameters;
var firstFragment = element.firstFragment;
var firstTypeParameters = firstFragment.typeParameters;

var augmentationTypeParameters = element.typeParameters;
if (augmentationTypeParameters.length != declarationTypeParameters.length) {
var fragmentTypeParameters = fragment.typeParameters;
if (fragmentTypeParameters.length != firstTypeParameters.length) {
return;
}

var toDeclaration = Substitution.fromPairs(
augmentationTypeParameters,
declarationTypeParameters.instantiateNone(),
var toFirst = Substitution.fromPairs(
fragmentTypeParameters,
firstTypeParameters.instantiateNone(),
);

var fromDeclaration = Substitution.fromPairs(
declarationTypeParameters,
augmentationTypeParameters.instantiateNone(),
var fromFirst = Substitution.fromPairs(
firstTypeParameters,
fragmentTypeParameters.instantiateNone(),
);

// Schedule mixing inference for augmentations.
if (element.augmentationTarget != null) {
if (element is InterfaceElementImpl && withClause != null) {
var toInferMixins = _toInferMixins[declaration];
if (fragment.augmentationTarget != null) {
if (fragment is InterfaceElementImpl && withClause != null) {
var toInferMixins = _toInferMixins[firstFragment];
if (toInferMixins != null) {
toInferMixins.augmentations.add(
_ToInferMixinsAugmentation(
element: element,
element: fragment,
withClause: withClause,
toDeclaration: toDeclaration,
fromDeclaration: fromDeclaration,
toDeclaration: toFirst,
fromDeclaration: fromFirst,
),
);
}
}
}

if (element is InterfaceElementImpl &&
declaration is InterfaceElementImpl &&
augmented is AugmentedInterfaceElementImpl) {
if (declaration.supertype == null) {
var elementSuperType = element.supertype;
if (elementSuperType != null) {
var superType = toDeclaration.mapInterfaceType(elementSuperType);
declaration.supertype = superType;
if (fragment is InterfaceElementImpl &&
firstFragment is InterfaceElementImpl &&
element is InterfaceElementImpl2) {
if (firstFragment.supertype == null) {
var fragmentSuperType = fragment.supertype;
if (fragmentSuperType != null) {
var superType = toFirst.mapInterfaceType(fragmentSuperType);
firstFragment.supertype = superType;
}
}

augmented.interfaces.addAll(
toDeclaration.mapInterfaceTypes(element.interfaces),
element.interfaces.addAll(
toFirst.mapInterfaceTypes(fragment.interfaces),
);
}

if (element is MixinElementImpl && augmented is AugmentedMixinElementImpl) {
augmented.superclassConstraints.addAll(
toDeclaration.mapInterfaceTypes(element.superclassConstraints),
if (fragment is MixinElementImpl && element is MixinElementImpl2) {
element.superclassConstraints.addAll(
toFirst.mapInterfaceTypes(fragment.superclassConstraints),
);
}
}
Expand Down Expand Up @@ -692,7 +692,7 @@ class _MixinsInference {
} finally {
element.mixinInferenceCallback = null;
switch (element.augmented) {
case AugmentedInterfaceElementImpl augmented:
case InterfaceElementImpl2 augmented:
augmented.mixins.addAll(declarationMixins);
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/analyzer/lib/src/test_utilities/mock_sdk_elements.dart
Original file line number Diff line number Diff line change
Expand Up @@ -919,7 +919,7 @@ class _MockSdkElementsBuilder {
}

void _buildClassElement(ClassElementImpl fragment) {
var element = AugmentedClassElementImpl(Reference.root(), fragment);
var element = ClassElementImpl2(Reference.root(), fragment);
element.mixins = fragment.mixins;
element.interfaces = fragment.interfaces;
element.fields = fragment.fields;
Expand Down
Loading

0 comments on commit 53bf3ff

Please sign in to comment.