2
2
// for details. All rights reserved. Use of this source code is governed by a
3
3
// BSD-style license that can be found in the LICENSE file.
4
4
5
- // ignore_for_file: analyzer_use_new_elements
6
-
7
5
import 'dart:convert' ;
8
6
9
7
import 'package:analyzer/dart/ast/ast.dart'
10
8
show Expression, InstanceCreationExpression;
9
+ import 'package:analyzer/dart/element/element2.dart' show Annotatable;
11
10
import 'package:analyzer/source/line_info.dart' ;
12
11
// ignore: implementation_imports
13
12
import 'package:analyzer/src/dart/element/element.dart'
14
13
show ConstVariableElement;
15
14
import 'package:dartdoc/src/element_type.dart' ;
15
+ import 'package:dartdoc/src/model/accessor.dart' ;
16
16
import 'package:dartdoc/src/model/annotation.dart' ;
17
17
import 'package:dartdoc/src/model/attribute.dart' ;
18
+ import 'package:dartdoc/src/model/class.dart' ;
18
19
import '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' ;
20
25
import 'package:dartdoc/src/utils.dart' ;
21
26
import 'package:meta/meta.dart' ;
22
27
@@ -73,16 +78,16 @@ mixin GetterSetterCombo on ModelElement {
73
78
bool get hasConstantValueForDisplay => false ;
74
79
75
80
late final Expression ? _constantInitializer =
76
- (element as ConstVariableElement ).constantInitializer;
81
+ (element2.firstFragment as ConstVariableElement ).constantInitializer;
77
82
78
83
String linkifyConstantValue (String original) {
79
84
if (_constantInitializer is ! InstanceCreationExpression ) return original;
80
85
81
86
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;
84
89
85
- var target = getModelForElement (staticElement ) as Constructor ;
90
+ var target = getModelForElement2 (element ) as Constructor ;
86
91
var enclosingElement = target.enclosingElement;
87
92
if (enclosingElement is ! Class ) return original;
88
93
@@ -108,10 +113,10 @@ mixin GetterSetterCombo on ModelElement {
108
113
// explicit setters/getters will be handled by those objects, but
109
114
// if a warning comes up for an enclosing synthetic field we have to
110
115
// put it somewhere. So pick an accessor.
111
- if (element .isSynthetic) {
116
+ if (element2 .isSynthetic) {
112
117
if (hasExplicitGetter) return getter! .characterLocation;
113
118
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 ' );
115
120
}
116
121
return super .characterLocation;
117
122
}
@@ -137,9 +142,9 @@ mixin GetterSetterCombo on ModelElement {
137
142
138
143
initializerString = 'const $initializerString ' ;
139
144
140
- var isImplicitConstructorCall = _constantInitializer
141
- .constructorName.staticElement ? .isDefaultConstructor ??
142
- false ;
145
+ var isImplicitConstructorCall =
146
+ _constantInitializer .constructorName.element ? .isDefaultConstructor ??
147
+ false ;
143
148
if (isImplicitConstructorCall) {
144
149
// For an enum value with an implicit constructor call (like
145
150
// `enum E { one, two; }`), `constantInitializer.toString()` does not
@@ -206,13 +211,13 @@ mixin GetterSetterCombo on ModelElement {
206
211
@override
207
212
late final String documentationComment =
208
213
_getterSetterDocumentationComment.isEmpty
209
- ? element .documentationComment ?? ''
214
+ ? (element2 as Annotatable ) .documentationComment ?? ''
210
215
: _getterSetterDocumentationComment;
211
216
212
217
@override
213
218
bool get hasDocumentationComment =>
214
219
_getterSetterDocumentationComment.isNotEmpty ||
215
- element .documentationComment != null ;
220
+ (element2 as Annotatable ) .documentationComment != null ;
216
221
217
222
/// Derives a documentation comment for the combo by copying documentation
218
223
/// from the [getter] and/or [setter] .
0 commit comments