private static Map<IPath, List<IJavaElement>> removeDuplicatePaths(List<IJavaElement> allIndexables) { Map<IPath, List<IJavaElement>> paths = new HashMap<>(); HashSet<IPath> workspacePaths = new HashSet<IPath>(); for (IJavaElement next : allIndexables) { IPath nextPath = JavaIndex.getLocationForElement(next); IPath workspacePath = getWorkspacePathForRoot(next); List<IJavaElement> value = paths.get(nextPath); if (value == null) { value = new ArrayList<IJavaElement>(); paths.put(nextPath, value); } else { if (workspacePath != null) { if (workspacePaths.contains(workspacePath)) { continue; } if (!workspacePath.isEmpty()) { Package.logInfo("Found duplicate workspace path for " + workspacePath.toString()); //$NON-NLS-1$ } workspacePaths.add(workspacePath); } } value.add(next); } return paths; }
private static Map<IPath, List<IJavaElement>> removeDuplicatePaths(List<IJavaElement> allIndexables) { Map<IPath, List<IJavaElement>> paths = new HashMap<>(); HashSet<IPath> workspacePaths = new HashSet<IPath>(); for (IJavaElement next : allIndexables) { IPath nextPath = JavaIndex.getLocationForElement(next); IPath workspacePath = getWorkspacePathForRoot(next); List<IJavaElement> value = paths.get(nextPath); if (value == null) { value = new ArrayList<IJavaElement>(); paths.put(nextPath, value); } else { if (workspacePath != null) { if (workspacePaths.contains(workspacePath)) { continue; } if (!workspacePath.isEmpty()) { Package.logInfo("Found duplicate workspace path for " + workspacePath.toString()); //$NON-NLS-1$ } workspacePaths.add(workspacePath); } } value.add(next); } return paths; }
/** * 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()); }
IPath location = JavaIndex.getLocationForElement(root); if (location == null) { return null;
String name = classFile.getName(); PackageFragmentRoot root = (PackageFragmentRoot) pkg.getParent(); IPath location = JavaIndex.getLocationForElement(root); if (location == null) { return null;
IPath nextPath = JavaIndex.getLocationForElement(this.roots[i]); this.mapPathsToRoots.put(nextPath, i);
IPath nextPath = JavaIndex.getLocationForElement(this.roots[i]); this.mapPathsToRoots.put(nextPath, i);
continue; IPath filesystemPath = JavaIndex.getLocationForElement(nextRoot); if (scannedPaths.contains(filesystemPath)) { continue;
JavaIndex index = JavaIndex.getIndex(); try (IReader reader = index.getNd().acquireReadLock()) { IPath resourcePath = JavaIndex.getLocationForElement(this); if (!resourcePath.isEmpty()) { NdResourceFile resourceFile = index.getResourceFile(resourcePath.toString().toCharArray());
continue; IPath filesystemPath = JavaIndex.getLocationForElement(nextRoot); if (scannedPaths.contains(filesystemPath)) { continue;
IPath location = JavaIndex.getLocationForElement(next);
IPath location = JavaIndex.getLocationForElement(next);
IPath location = JavaIndex.getLocationForElement(jarRoot);
IPath location = JavaIndex.getLocationForElement(jarRoot);
JavaIndex index = JavaIndex.getIndex(); try (IReader reader = index.getNd().acquireReadLock()) { IPath resourcePath = JavaIndex.getLocationForElement(this); if (!resourcePath.isEmpty()) { NdResourceFile resourceFile = index.getResourceFile(resourcePath.toString().toCharArray());
IPackageFragmentRoot packageFragmentRoot = (IPackageFragmentRoot) element .getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT); IPath rootPathString = JavaIndex.getLocationForElement(packageFragmentRoot); if (!rootPathString.equals(thePath)) { resourceFile.setPackageFragmentRoot(rootPathString.toString().toCharArray());
IPackageFragmentRoot packageFragmentRoot = (IPackageFragmentRoot) element .getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT); IPath rootPathString = JavaIndex.getLocationForElement(packageFragmentRoot); if (!rootPathString.equals(thePath)) { resourceFile.setPackageFragmentRoot(rootPathString.toString().toCharArray());