22// for details. All rights reserved. Use of this source code is governed by a
33// BSD-style license that can be found in the LICENSE file.
44
5- // ignore_for_file: analyzer_use_new_elements
6-
75import 'dart:convert' ;
86
97import 'package:analyzer/dart/ast/ast.dart'
108 show Expression, InstanceCreationExpression;
9+ import 'package:analyzer/dart/element/element2.dart' show Annotatable;
1110import 'package:analyzer/source/line_info.dart' ;
1211// ignore: implementation_imports
1312import 'package:analyzer/src/dart/element/element.dart'
1413 show ConstVariableElement;
1514import 'package:dartdoc/src/element_type.dart' ;
15+ import 'package:dartdoc/src/model/accessor.dart' ;
1616import 'package:dartdoc/src/model/annotation.dart' ;
1717import 'package:dartdoc/src/model/attribute.dart' ;
18+ import 'package:dartdoc/src/model/class.dart' ;
1819import 'package:dartdoc/src/model/comment_referable.dart' ;
19- import 'package:dartdoc/src/model/model.dart' ;
20+ import 'package:dartdoc/src/model/constructor.dart' ;
21+ import 'package:dartdoc/src/model/documentation_comment.dart' ;
22+ import 'package:dartdoc/src/model/enum.dart' ;
23+ import 'package:dartdoc/src/model/model_element.dart' ;
24+ import 'package:dartdoc/src/model/parameter.dart' ;
2025import 'package:dartdoc/src/utils.dart' ;
2126import 'package:meta/meta.dart' ;
2227
@@ -73,16 +78,16 @@ mixin GetterSetterCombo on ModelElement {
7378 bool get hasConstantValueForDisplay => false ;
7479
7580 late final Expression ? _constantInitializer =
76- (element as ConstVariableElement ).constantInitializer;
81+ (element2.firstFragment as ConstVariableElement ).constantInitializer;
7782
7883 String linkifyConstantValue (String original) {
7984 if (_constantInitializer is ! InstanceCreationExpression ) return original;
8085
8186 var constructorName = _constantInitializer.constructorName.toString ();
82- var staticElement = _constantInitializer.constructorName.staticElement ;
83- if (staticElement == null ) return original;
87+ var element = _constantInitializer.constructorName.element ;
88+ if (element == null ) return original;
8489
85- var target = getModelForElement (staticElement ) as Constructor ;
90+ var target = getModelForElement2 (element ) as Constructor ;
8691 var enclosingElement = target.enclosingElement;
8792 if (enclosingElement is ! Class ) return original;
8893
@@ -108,10 +113,10 @@ mixin GetterSetterCombo on ModelElement {
108113 // explicit setters/getters will be handled by those objects, but
109114 // if a warning comes up for an enclosing synthetic field we have to
110115 // put it somewhere. So pick an accessor.
111- if (element .isSynthetic) {
116+ if (element2 .isSynthetic) {
112117 if (hasExplicitGetter) return getter! .characterLocation;
113118 if (hasExplicitSetter) return setter! .characterLocation;
114- assert (false , 'Field and accessors can not all be synthetic: $element ' );
119+ assert (false , 'Field and accessors can not all be synthetic: $element2 ' );
115120 }
116121 return super .characterLocation;
117122 }
@@ -137,9 +142,9 @@ mixin GetterSetterCombo on ModelElement {
137142
138143 initializerString = 'const $initializerString ' ;
139144
140- var isImplicitConstructorCall = _constantInitializer
141- .constructorName.staticElement ? .isDefaultConstructor ??
142- false ;
145+ var isImplicitConstructorCall =
146+ _constantInitializer .constructorName.element ? .isDefaultConstructor ??
147+ false ;
143148 if (isImplicitConstructorCall) {
144149 // For an enum value with an implicit constructor call (like
145150 // `enum E { one, two; }`), `constantInitializer.toString()` does not
@@ -206,13 +211,13 @@ mixin GetterSetterCombo on ModelElement {
206211 @override
207212 late final String documentationComment =
208213 _getterSetterDocumentationComment.isEmpty
209- ? element .documentationComment ?? ''
214+ ? (element2 as Annotatable ) .documentationComment ?? ''
210215 : _getterSetterDocumentationComment;
211216
212217 @override
213218 bool get hasDocumentationComment =>
214219 _getterSetterDocumentationComment.isNotEmpty ||
215- element .documentationComment != null ;
220+ (element2 as Annotatable ) .documentationComment != null ;
216221
217222 /// Derives a documentation comment for the combo by copying documentation
218223 /// from the [getter] and/or [setter] .
0 commit comments