return null;
}
// obtaining export name of the package from a providing manifest
String exportedPackage = null;
BundleManager bundleManager = BundleManager.getInstance(targetClass.getProject());
ModuleFileIndex index = ModuleRootManager.getInstance(requestorModule).getFileIndex();
List<OrderEntry> entries = index.getOrderEntriesForFile(targetFile.getVirtualFile());
OrderEntry entry = !entries.isEmpty() ? entries.get(0) : null;
if (entry instanceof ModuleOrderEntry) {
Module module = ((ModuleOrderEntry)entry).getModule();
if (module != null) {
BundleManifest manifest = bundleManager.getManifestByObject(module);
exportedPackage = manifest != null ? manifest.getExportedPackage(packageName) : null;
}
}
else if (entry instanceof LibraryOrderEntry) {
Library library = ((LibraryOrderEntry)entry).getLibrary();
if (library != null) {
BundleManifest manifest = bundleManager.getManifestByObject(library);
exportedPackage = manifest != null ? manifest.getExportedPackage(packageName) : null;
}
}
else if (entry instanceof JdkOrderEntry) {
exportedPackage = packageName;
}
if (exportedPackage == null) {
return NOT_EXPORTED;
}
if (!facet.getConfiguration().isManifestManuallyEdited()) {
return null;
}
BundleManifest manifest = bundleManager.getManifestByObject(requestorModule);
if (manifest != null) {
// Imported packages
if (manifest.isPackageImported(packageName)) {
return null;
}
// Required bundles
for (String bundleSpec : manifest.getRequiredBundles()) {
BundleManifest bundle = bundleManager.getManifestByBundleSpec(bundleSpec);
if (bundle != null && bundle.getExportedPackage(packageName) != null) {
return null;
}
}