@@ -7936,17 +7936,12 @@ enum Modifier {
79367936}
79377937
79387938/// A concrete implementation of a [MultiplyDefinedElement] .
7939- class MultiplyDefinedElementImpl implements MultiplyDefinedElement , Element2 {
7939+ class MultiplyDefinedElementImpl implements MultiplyDefinedElement {
79407940 /// The unique integer identifier of this element.
79417941 @override
79427942 final int id = ElementImpl ._NEXT_ID ++ ;
79437943
7944- /// The analysis context in which the multiply defined elements are defined.
7945- @override
7946- final AnalysisContext context;
7947-
7948- @override
7949- final AnalysisSession session;
7944+ final CompilationUnitElementImpl libraryFragment;
79507945
79517946 /// The name of the conflicting elements.
79527947 @override
@@ -7958,16 +7953,18 @@ class MultiplyDefinedElementImpl implements MultiplyDefinedElement, Element2 {
79587953 /// Initialize a newly created element in the given [context] to represent
79597954 /// the given non-empty [conflictingElements] .
79607955 MultiplyDefinedElementImpl (
7961- this .context, this .session, this .name, this .conflictingElements);
7962-
7963- @override
7964- Element2 ? get baseElement => null ;
7956+ this .libraryFragment,
7957+ this .name,
7958+ this .conflictingElements,
7959+ ) ;
79657960
79667961 @override
79677962 List <Element > get children => const [];
79687963
79697964 @override
7970- List <Element2 > get children2 => const [];
7965+ AnalysisContext get context {
7966+ return libraryFragment.context;
7967+ }
79717968
79727969 @override
79737970 Element ? get declaration => null ;
@@ -7978,9 +7975,6 @@ class MultiplyDefinedElementImpl implements MultiplyDefinedElement, Element2 {
79787975 @override
79797976 String ? get documentationComment => null ;
79807977
7981- @override
7982- Element2 ? get enclosingElement2 => null ;
7983-
79847978 @override
79857979 Element ? get enclosingElement3 => null ;
79867980
@@ -8086,9 +8080,6 @@ class MultiplyDefinedElementImpl implements MultiplyDefinedElement, Element2 {
80868080 @override
80878081 LibraryElement ? get library => null ;
80888082
8089- @override
8090- LibraryElement2 ? get library2 => null ;
8091-
80928083 @override
80938084 Source ? get librarySource => null ;
80948085
@@ -8100,9 +8091,6 @@ class MultiplyDefinedElementImpl implements MultiplyDefinedElement, Element2 {
81008091 return const < ElementAnnotationImpl > [];
81018092 }
81028093
8103- @override
8104- String get name3 => name;
8105-
81068094 @override
81078095 int get nameLength => 0 ;
81088096
@@ -8113,7 +8101,9 @@ class MultiplyDefinedElementImpl implements MultiplyDefinedElement, Element2 {
81138101 Element get nonSynthetic => this ;
81148102
81158103 @override
8116- Element2 get nonSynthetic2 => this ;
8104+ AnalysisSession get session {
8105+ return libraryFragment.session;
8106+ }
81178107
81188108 @override
81198109 Version ? get sinceSdkVersion => null ;
@@ -8125,21 +8115,6 @@ class MultiplyDefinedElementImpl implements MultiplyDefinedElement, Element2 {
81258115 T ? accept <T >(ElementVisitor <T > visitor) =>
81268116 visitor.visitMultiplyDefinedElement (this );
81278117
8128- @override
8129- T ? accept2 <T >(ElementVisitor2 <T > visitor) {
8130- // TODO(scheglov): remove when separate elements and fragments
8131- throw UnimplementedError ();
8132- }
8133-
8134- @override
8135- String displayString2 ({
8136- bool multiline = false ,
8137- bool preferTypeAlias = false ,
8138- }) {
8139- // TODO(scheglov): implement displayString2
8140- throw UnimplementedError ();
8141- }
8142-
81438118 @override
81448119 String getDisplayString ({
81458120 @Deprecated ('Only non-nullable by default mode is supported' )
@@ -8170,26 +8145,13 @@ class MultiplyDefinedElementImpl implements MultiplyDefinedElement, Element2 {
81708145 return false ;
81718146 }
81728147
8173- @override
8174- bool isAccessibleIn2 (LibraryElement2 library) {
8175- // TODO(scheglov): implement isAccessibleIn2
8176- throw UnimplementedError ();
8177- }
8178-
81798148 @override
81808149 E ? thisOrAncestorMatching <E extends Element >(
81818150 bool Function (Element ) predicate,
81828151 ) {
81838152 return null ;
81848153 }
81858154
8186- @override
8187- Element2 ? thisOrAncestorMatching2 (
8188- bool Function (Element2 p1) predicate,
8189- ) {
8190- return null ;
8191- }
8192-
81938155 @override
81948156 E ? thisOrAncestorMatching3 <E extends Element >(
81958157 bool Function (Element ) predicate,
@@ -8200,11 +8162,6 @@ class MultiplyDefinedElementImpl implements MultiplyDefinedElement, Element2 {
82008162 @override
82018163 E ? thisOrAncestorOfType <E extends Element >() => null ;
82028164
8203- @override
8204- E ? thisOrAncestorOfType2 <E extends Element2 >() {
8205- return null ;
8206- }
8207-
82088165 @override
82098166 E ? thisOrAncestorOfType3 <E extends Element >() => null ;
82108167
@@ -8239,13 +8196,174 @@ class MultiplyDefinedElementImpl implements MultiplyDefinedElement, Element2 {
82398196 child.accept (visitor);
82408197 }
82418198 }
8199+ }
8200+
8201+ class MultiplyDefinedElementImpl2 implements MultiplyDefinedElement2 {
8202+ @override
8203+ final int id = ElementImpl ._NEXT_ID ++ ;
8204+
8205+ final CompilationUnitElementImpl libraryFragment;
8206+
8207+ @override
8208+ final String name3;
8209+
8210+ @override
8211+ final List <Element2 > conflictingElements2;
8212+
8213+ @override
8214+ late final firstFragment = MultiplyDefinedFragmentImpl (this );
8215+
8216+ MultiplyDefinedElementImpl2 (
8217+ this .libraryFragment,
8218+ this .name3,
8219+ this .conflictingElements2,
8220+ );
8221+
8222+ MultiplyDefinedElementImpl get asElement {
8223+ return MultiplyDefinedElementImpl (
8224+ libraryFragment,
8225+ name3,
8226+ conflictingElements2.map ((e) => e.asElement).nonNulls.toList (),
8227+ );
8228+ }
8229+
8230+ @override
8231+ MultiplyDefinedElementImpl2 get baseElement => this ;
8232+
8233+ @override
8234+ List <Element2 > get children2 => const [];
8235+
8236+ @override
8237+ String get displayName => name3;
8238+
8239+ @override
8240+ Null get enclosingElement2 => null ;
8241+
8242+ @override
8243+ bool get isPrivate => false ;
8244+
8245+ @override
8246+ bool get isPublic => true ;
8247+
8248+ @override
8249+ bool get isSynthetic => true ;
8250+
8251+ bool get isVisibleForTemplate => false ;
8252+
8253+ bool get isVisibleOutsideTemplate => false ;
8254+
8255+ @override
8256+ ElementKind get kind => ElementKind .ERROR ;
8257+
8258+ @override
8259+ LibraryElement2 get library2 => libraryFragment.element;
8260+
8261+ @override
8262+ ElementLocation ? get location => null ;
8263+
8264+ @override
8265+ Element2 get nonSynthetic2 => this ;
8266+
8267+ @override
8268+ AnalysisSession get session => libraryFragment.session;
8269+
8270+ @override
8271+ T ? accept2 <T >(ElementVisitor2 <T > visitor) {
8272+ return visitor.visitMultiplyDefinedElement (this );
8273+ }
8274+
8275+ @override
8276+ String displayString2 ({
8277+ bool multiline = false ,
8278+ bool preferTypeAlias = false ,
8279+ }) {
8280+ var elementsStr = conflictingElements2.map ((e) {
8281+ return e.displayString2 ();
8282+ }).join (', ' );
8283+ return '[$elementsStr ]' ;
8284+ }
8285+
8286+ @override
8287+ bool isAccessibleIn2 (LibraryElement2 library) {
8288+ for (var element in conflictingElements2) {
8289+ if (element.isAccessibleIn2 (library)) {
8290+ return true ;
8291+ }
8292+ }
8293+ return false ;
8294+ }
8295+
8296+ @override
8297+ Element2 ? thisOrAncestorMatching2 (
8298+ bool Function (Element2 p1) predicate,
8299+ ) {
8300+ return null ;
8301+ }
8302+
8303+ @override
8304+ E ? thisOrAncestorOfType2 <E extends Element2 >() {
8305+ return null ;
8306+ }
8307+
8308+ @override
8309+ String toString () {
8310+ StringBuffer buffer = StringBuffer ();
8311+ bool needsSeparator = false ;
8312+ void writeList (List <Element2 > elements) {
8313+ for (var element in elements) {
8314+ if (needsSeparator) {
8315+ buffer.write (", " );
8316+ } else {
8317+ needsSeparator = true ;
8318+ }
8319+ buffer.write (
8320+ element.displayString2 (),
8321+ );
8322+ }
8323+ }
8324+
8325+ buffer.write ("[" );
8326+ writeList (conflictingElements2);
8327+ buffer.write ("]" );
8328+ return buffer.toString ();
8329+ }
82428330
82438331 @override
82448332 void visitChildren2 <T >(ElementVisitor2 <T > visitor) {
8245- // TODO(scheglov): remove when separate elements and fragments
8333+ for (var child in children2) {
8334+ child.accept2 (visitor);
8335+ }
82468336 }
82478337}
82488338
8339+ class MultiplyDefinedFragmentImpl implements MultiplyDefinedFragment {
8340+ @override
8341+ final MultiplyDefinedElementImpl2 element;
8342+
8343+ MultiplyDefinedFragmentImpl (this .element);
8344+
8345+ @override
8346+ List <Fragment > get children3 => [];
8347+
8348+ @override
8349+ LibraryFragment get enclosingFragment => element.libraryFragment;
8350+
8351+ @override
8352+ LibraryFragment get libraryFragment => enclosingFragment;
8353+
8354+ @override
8355+ String ? get name2 => element.name3;
8356+
8357+ @override
8358+ Null get nameOffset2 => null ;
8359+
8360+ @override
8361+ Null get nextFragment => null ;
8362+
8363+ @override
8364+ Null get previousFragment => null ;
8365+ }
8366+
82498367/// The synthetic element representing the declaration of the type `Never` .
82508368class NeverElementImpl extends ElementImpl implements TypeDefiningElement {
82518369 /// The unique instance of this class.
0 commit comments