File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -68,16 +68,27 @@ extension TypeAnnotationNameHelper on TypeAnnotation {
6868/// Extension built on [NameHelper] to allow for easy access to the `name`
6969/// field of [Identifier] s.
7070extension TypeNameHelper on NamedType {
71+ // Backwards compatibility for various analyzer versions that remove name/name2.
72+ dynamic get name => name2;
73+ dynamic get name2 => name;
74+ dynamic get _name => name;
75+ String get nameLexeme {
76+ final name = this ._name;
77+ if (name is Identifier ) return name.name;
78+ if (name is Token ) return name.lexeme;
79+ if (name is String ) return name;
80+ throw UnimplementedError ('Unexpected type for name: ${name .runtimeType }' );
81+ }
82+
7183 /// The type name without any namespace prefixes.
72- String get nameWithoutPrefix => name2.lexeme ;
84+ String get nameWithoutPrefix => nameLexeme ;
7385
7486 /// The type name including the namespace prefix.
7587 String get nameWithPrefix {
7688 final prefix = importPrefix? .name.lexeme;
77- final name = name2.lexeme;
7889 return [
7990 if (prefix != null ) prefix,
80- name ,
91+ nameLexeme ,
8192 ].join ('.' );
8293 }
8394}
You can’t perform that action at this time.
0 commit comments