|
3 | 3 | // BSD-style license that can be found in the LICENSE file.
|
4 | 4 |
|
5 | 5 | import 'package:analyzer/dart/element/element2.dart';
|
6 |
| -// ignore: implementation_imports |
7 |
| -import 'package:analyzer/src/dart/element/element.dart'; |
8 | 6 | import 'package:dartdoc/src/model/model.dart';
|
9 | 7 | import 'package:dartdoc/src/warnings.dart';
|
10 | 8 |
|
@@ -86,22 +84,16 @@ final class _Canonicalization {
|
86 | 84 | }
|
87 | 85 | }
|
88 | 86 |
|
89 |
| - // Copied from package analyzer ElementLocationImpl.fromElement. |
90 | 87 | String _getElementLocation(Element2 element) {
|
91 | 88 | var components = <String>[];
|
92 | 89 | Element2? ancestor = element;
|
93 | 90 | while (ancestor != null) {
|
94 |
| - if (ancestor is! ElementImpl2) { |
95 |
| - if (ancestor is LibraryElement2) { |
96 |
| - components.insert(0, ancestor.identifier); |
97 |
| - } else { |
98 |
| - throw Exception('${ancestor.runtimeType} is not an ElementImpl2'); |
99 |
| - } |
100 |
| - ancestor = ancestor.enclosingElement2; |
101 |
| - } else { |
| 91 | + if (ancestor is LibraryElement2) { |
102 | 92 | components.insert(0, ancestor.identifier);
|
103 |
| - ancestor = ancestor.enclosingElement2; |
| 93 | + } else { |
| 94 | + components.insert(0, ancestor.name3!); |
104 | 95 | }
|
| 96 | + ancestor = ancestor.enclosingElement2; |
105 | 97 | }
|
106 | 98 | var buffer = StringBuffer();
|
107 | 99 | var length = components.length;
|
|
0 commit comments