+ pub fn maybe_resolve_path(&self, p: &syn::Path, generics: Option<&GenericTypes>) -> Option<String> {
+ self.maybe_resolve_imported_path(p, generics).map(|mut path| {
+ loop {
+ // Now that we've resolved the path to the path as-imported, check whether the path
+ // is actually a pub(.*) use statement and map it to the real path.
+ let path_tmp = path.clone();
+ let crate_name = path_tmp.splitn(2, "::").next().unwrap();
+ let mut module_riter = path_tmp.rsplitn(2, "::");
+ let obj = module_riter.next().unwrap();
+ if let Some(module_path) = module_riter.next() {
+ if let Some(m) = self.library.modules.get(module_path) {
+ for item in m.items.iter() {
+ if let syn::Item::Use(syn::ItemUse { vis, tree, .. }) = item {
+ match vis {
+ syn::Visibility::Public(_)|
+ syn::Visibility::Crate(_)|
+ syn::Visibility::Restricted(_) => {
+ Self::walk_use_intern(crate_name, module_path,
+ &self.library.dependencies, tree, "",
+ syn::punctuated::Punctuated::new(), &mut |ident, (use_path, _)| {
+ if format!("{}", ident) == obj {
+ path = use_path;
+ }
+ });
+ },
+ syn::Visibility::Inherited => {},
+ }
+ }
+ }
+ }
+ }
+ break;
+ }
+ path
+ })
+ }
+