/** * Returns a descriptor for the given class within the given package fragment, or null if the fragment doesn't have * a location on the filesystem. */ private static BinaryModuleDescriptor createDescriptor(PackageFragmentRoot root, ModularClassFile classFile) { IPath location = JavaIndex.getLocationForElement(root); if (location == null) { return null; } String entryName = TypeConstants.MODULE_INFO_CLASS_NAME_STRING; IPath workspacePath = root.getPath(); String indexPath; if (root instanceof JarPackageFragmentRoot) { entryName = ((JarPackageFragmentRoot) root).getClassFilePath(entryName); indexPath = root.getHandleIdentifier() + IDependent.JAR_FILE_ENTRY_SEPARATOR + entryName; // see additional comments in BinaryTypeFactor.createDescriptor() } else { location = location.append(entryName); indexPath = workspacePath.append(entryName).toString(); workspacePath = classFile.resource().getFullPath(); } return new BinaryModuleDescriptor(location.toString().toCharArray(), null, // TODO: module name not know at this point workspacePath.toString().toCharArray(), indexPath.toCharArray()); }
/** * Returns a descriptor for the given class within the given package fragment, or null if the fragment doesn't have * a location on the filesystem. */ private static BinaryModuleDescriptor createDescriptor(PackageFragmentRoot root, ModularClassFile classFile) { IPath location = JavaIndex.getLocationForElement(root); if (location == null) { return null; } String entryName = TypeConstants.MODULE_INFO_CLASS_NAME_STRING; IPath workspacePath = root.getPath(); String indexPath; char[] moduleName = null; if (root instanceof JarPackageFragmentRoot) { entryName = ((JarPackageFragmentRoot) root).getClassFilePath(entryName); indexPath = root.getHandleIdentifier() + IDependent.JAR_FILE_ENTRY_SEPARATOR + entryName; // see additional comments in BinaryTypeFactor.createDescriptor() if (root instanceof JrtPackageFragmentRoot) { moduleName = root.getElementName().toCharArray(); } } else { location = location.append(entryName); indexPath = workspacePath.append(entryName).toString(); workspacePath = classFile.resource().getFullPath(); } return new BinaryModuleDescriptor(location.toString().toCharArray(), moduleName, // TODO: module name only known for JRT workspacePath.toString().toCharArray(), indexPath.toCharArray()); }