Skip to content

Commit badcc56

Browse files
committed
WIP
1 parent 13edc30 commit badcc56

File tree

3 files changed

+35
-9
lines changed

3 files changed

+35
-9
lines changed

lib/src/model.dart

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,6 +1112,7 @@ class Library extends ModelElement {
11121112
.where((element) => element is ClassElement && !element.isEnum));
11131113

11141114
_classes = types.where(isPublic).map((e) {
1115+
if (e.name == 'ExportedClass') _getOriginalPublicContainingLibrary(e);
11151116
if (e.library != this._library &&
11161117
_exportedNamespace.definedNames.values.contains(e) &&
11171118
package._libraryElements.contains(e.library)) {
@@ -1124,6 +1125,26 @@ class Library extends ModelElement {
11241125
return _classes;
11251126
}
11261127

1128+
void _getOriginalPublicContainingLibrary(Element e) {
1129+
// _library.exportedLibraries.forEach((lib) {
1130+
// if (lib.publicNamespace.definedNames.isNotEmpty &&
1131+
// lib.publicNamespace.definedNames.values.contains(e)) {
1132+
// print("YYYY ${lib.name} has ${e.name}");
1133+
// }
1134+
// var ns = new NamespaceBuilder().createExportNamespaceForLibrary(lib);
1135+
// var ns2 = new NamespaceBuilder().createPublicNamespaceForLibrary(lib);
1136+
// print("XXX ${lib.name} public namespace: [" +
1137+
// lib.publicNamespace.definedNames.keys.join(', ') +
1138+
// "] and export ns [${ns.definedNames.keys.join(', ')}] " +
1139+
// " and total public namespace is [${ns2.definedNames.keys.join(', ')}]");
1140+
// });
1141+
_library.exports.forEach((export) {
1142+
print(
1143+
"XXX ${_library.name} has export ${export.exportedLibrary.name} ${package._libraryElements.contains(export.exportedLibrary)} with NS "
1144+
'${new NamespaceBuilder().createExportNamespaceForDirective(export).definedNames.keys.join(', ')}');
1145+
});
1146+
}
1147+
11271148
LibraryElement get _library => (element as LibraryElement);
11281149

11291150
Class getClassByName(String name) {
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// a private library, for exporting by to_be_exported
2+
library for_exporting;
3+
4+
String exportedField;
5+
6+
void exportedFunction() {}
7+
8+
typedef void ExportedTypeDef();
9+
10+
class ExportedClass {}
11+
12+
enum ExportedEnum { ONE, TWO, THREE }

test_package/lib/to_be_exported.dart

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
11
library to_be_exported;
22

3-
String exportedField;
4-
5-
void exportedFunction() {}
6-
7-
typedef void ExportedTypeDef();
8-
9-
class ExportedClass {}
10-
11-
enum ExportedEnum { ONE, TWO, THREE }
3+
// testing a library that is made up of "private" libraries
4+
export 'src/for_exporting.dart';

0 commit comments

Comments
 (0)