|
@@ -48,23 +48,28 @@ class RouterGenerator extends GeneratorForAnnotation<RouterPage> {
|
|
|
// 添加到imports
|
|
// 添加到imports
|
|
|
for (LibraryElement element
|
|
for (LibraryElement element
|
|
|
in (await buildStep.inputLibrary).importedLibraries) {
|
|
in (await buildStep.inputLibrary).importedLibraries) {
|
|
|
- Uri importUri = element.getType(importType)?.source?.uri;
|
|
|
|
|
|
|
+ if (element.name == "dart.core") {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ ClassElement importUri = element.getType(importType);
|
|
|
|
|
|
|
|
if (importUri != null) {
|
|
if (importUri != null) {
|
|
|
- router.imports.add(importUri.toString());
|
|
|
|
|
|
|
+ router.imports.add(element.source?.uri.toString());
|
|
|
|
|
+ break;
|
|
|
} else {
|
|
} else {
|
|
|
// 查找exports
|
|
// 查找exports
|
|
|
Set<LibraryElement> exports = allExportedElements(element);
|
|
Set<LibraryElement> exports = allExportedElements(element);
|
|
|
bool exported = false;
|
|
bool exported = false;
|
|
|
for (LibraryElement exportElement in exports) {
|
|
for (LibraryElement exportElement in exports) {
|
|
|
- print("export element ${exportElement.source?.uri}");
|
|
|
|
|
if (exportElement.getType(importType) != null) {
|
|
if (exportElement.getType(importType) != null) {
|
|
|
exported = true;
|
|
exported = true;
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
if (exported) {
|
|
if (exported) {
|
|
|
router.imports.add(element.source?.uri?.toString());
|
|
router.imports.add(element.source?.uri?.toString());
|
|
|
|
|
+ break;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|