Skip to content

Commit a54fab3

Browse files
authored
Don't use 'Source.encoding'. (dart-lang#2020)
1 parent c1b9830 commit a54fab3

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

lib/src/model.dart

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2777,23 +2777,19 @@ class Library extends ModelElement with Categorization, TopLevelContainer {
27772777
static String getLibraryName(LibraryElement element) {
27782778
var source = element.source;
27792779

2780-
String name = element.name;
2781-
if (name == null || name.isEmpty) {
2782-
// handle the case of an anonymous library
2783-
name = path.basename(source.fullName);
2784-
2785-
if (name.endsWith('.dart')) {
2786-
name = name.substring(0, name.length - '.dart'.length);
2787-
}
2780+
if (source.uri.isScheme('dart')) {
2781+
return '${source.uri}';
27882782
}
27892783

2790-
// So, if the library is a system library, it's name is not
2791-
// dart:___, it's dart.___. Apparently the way to get to the dart:___
2792-
// name is to get source.encoding.
2793-
// This may be wrong or misleading, but developers expect the name
2794-
// of dart:____
2795-
name = source.isInSystemLibrary ? source.encoding : name;
2784+
var name = element.name;
2785+
if (name != null && name.isNotEmpty) {
2786+
return name;
2787+
}
27962788

2789+
name = path.basename(source.fullName);
2790+
if (name.endsWith('.dart')) {
2791+
name = name.substring(0, name.length - '.dart'.length);
2792+
}
27972793
return name;
27982794
}
27992795

0 commit comments

Comments
 (0)