|
5 | 5 | import 'dart:convert'; |
6 | 6 |
|
7 | 7 | import 'package:analyzer/dart/element/element.dart'; |
8 | | -// ignore: implementation_imports |
9 | | -import 'package:analyzer/src/dart/element/member.dart'; |
| 8 | +import 'package:analyzer/dart/element/type.dart'; |
10 | 9 | import 'package:dartdoc/src/element_type.dart'; |
11 | 10 | import 'package:dartdoc/src/model/attribute.dart'; |
12 | 11 | import 'package:dartdoc/src/model/class.dart'; |
@@ -54,24 +53,25 @@ final class Annotation extends Attribute { |
54 | 53 | /// The linked type argument text, with `<` and `>`, if there are any type |
55 | 54 | /// arguments. |
56 | 55 | String get _linkedTypeArguments { |
57 | | - var element = _annotation.element; |
58 | | - if (element is! SubstitutedConstructorElementImpl) { |
| 56 | + if (_annotation.element is PropertyAccessorElement) { |
| 57 | + return ''; |
| 58 | + } |
| 59 | + |
| 60 | + var type = _modelType.type; |
| 61 | + if (type is! InterfaceType) { |
| 62 | + return ''; |
| 63 | + } |
| 64 | + |
| 65 | + var typeArguments = type.typeArguments; |
| 66 | + if (typeArguments.isEmpty) { |
59 | 67 | return ''; |
60 | 68 | } |
61 | 69 |
|
62 | 70 | var buffer = StringBuffer(); |
63 | 71 | buffer.write('<'); |
64 | | - var container = element.baseElement.enclosingElement; |
65 | | - for (var p in container.typeParameters) { |
66 | | - var type = element.substitution.map[p]; |
67 | | - assert(type != null); |
68 | | - if (type == null) { |
69 | | - // Abandon this type arguments string, as something is wrong with the |
70 | | - // user's code. |
71 | | - return ''; |
72 | | - } |
73 | | - buffer.write(_packageGraph.getTypeFor(type, _library).linkedName); |
74 | | - if (p != container.typeParameters.last) { |
| 72 | + for (var t in typeArguments) { |
| 73 | + buffer.write(_packageGraph.getTypeFor(t, _library).linkedName); |
| 74 | + if (t != typeArguments.last) { |
75 | 75 | buffer.write(', '); |
76 | 76 | } |
77 | 77 | } |
|
0 commit comments