@SuppressWarnings({"ConstantConditions"}) public ArchiveFileDiffElement(@NotNull VirtualFile file) { super( file.getFileSystem() instanceof ArchiveFileSystem ? file : ArchiveVfsUtil.getArchiveRootForLocalFile(file)); }
private static void retainOnlyJarsAndDirectories(List<VirtualFile> woSdk) { for (Iterator<VirtualFile> iterator = woSdk.iterator(); iterator.hasNext(); ) { VirtualFile file = iterator.next(); final VirtualFile local = ArchiveVfsUtil.getVirtualFileForJar(file); final boolean dir = file.isDirectory(); final String name = file.getName(); if (LOG.isDebugEnabled()) { LOG.debug( "Considering: " + file.getPath() + "; local=" + local + "; dir=" + dir + "; name=" + name); } if (dir || local != null) { continue; } if (name.endsWith(".jar")) { continue; } LOG.debug("Removing"); iterator.remove(); } }
@Nullable public static VirtualFile doResolveSuperPomFile(@NotNull File mavenHome) { File[] files = mavenHome.listFiles(); if (files == null) return null; for (File library : files) { for (Pair<Pattern, String> path : SUPER_POM_PATHS) { if (path.first.matcher(library.getName()).matches()) { VirtualFile libraryVirtualFile = LocalFileSystem.getInstance().findFileByIoFile(library); if (libraryVirtualFile == null) continue; VirtualFile root = ArchiveVfsUtil.getJarRootForLocalFile(libraryVirtualFile); if (root == null) continue; VirtualFile pomFile = root.findFileByRelativePath(path.second); if (pomFile != null) { return pomFile; } } } } return null; }
@Override protected VirtualFileDiffElement createElement(VirtualFile file) { final VirtualFile archiveRootForLocalFile = ArchiveVfsUtil.getArchiveRootForLocalFile(file); return archiveRootForLocalFile == null ? null : new ArchiveFileDiffElement(file); }
@NotNull protected String[] getSystemLibraryUrlsImpl( @NotNull Sdk sdk, String name, OrderRootType orderRootType) { if (orderRootType == BinariesOrderRootType.getInstance()) { File libraryByAssemblyName = getLibraryByAssemblyName(name, null); if (libraryByAssemblyName == null) { return ArrayUtil.EMPTY_STRING_ARRAY; } return new String[] { VirtualFileManager.constructUrl( DotNetModuleFileType.PROTOCOL, libraryByAssemblyName.getPath()) + ArchiveFileSystem.ARCHIVE_SEPARATOR }; } else if (orderRootType == DocumentationOrderRootType.getInstance()) { String[] systemLibraryUrls = getSystemLibraryUrls(name, BinariesOrderRootType.getInstance()); if (systemLibraryUrls.length != 1) { return ArrayUtil.EMPTY_STRING_ARRAY; } VirtualFile libraryFile = VirtualFileManager.getInstance().findFileByUrl(systemLibraryUrls[0]); if (libraryFile == null) { return ArrayUtil.EMPTY_STRING_ARRAY; } VirtualFile localFile = ArchiveVfsUtil.getVirtualFileForArchive(libraryFile); if (localFile == null) { return ArrayUtil.EMPTY_STRING_ARRAY; } VirtualFile docFile = localFile.getParent().findChild(localFile.getNameWithoutExtension() + ".xml"); if (docFile != null) { return new String[] {docFile.getUrl()}; } return ArrayUtil.EMPTY_STRING_ARRAY; } else if (orderRootType == ExternalAttributesRootOrderType.getInstance()) { try { final Ref<Couple<String>> ref = Ref.create(); File libraryFile = getLibraryByAssemblyName(name, ref); if (libraryFile == null) { return ArrayUtil.EMPTY_STRING_ARRAY; } assert ref.get() != null; PluginClassLoader classLoader = (PluginClassLoader) getClass().getClassLoader(); IdeaPluginDescriptor plugin = PluginManager.getPlugin(classLoader.getPluginId()); assert plugin != null; File dir = new File(plugin.getPath(), "externalAttributes"); val urls = new SmartList<String>(); val requiredFileName = name + ".xml"; FileUtil.visitFiles( dir, new Processor<File>() { @Override public boolean process(File file) { if (file.isDirectory()) { return true; } if (Comparing.equal(requiredFileName, file.getName(), false) && isValidExternalFile(ref.get().getSecond(), file)) { urls.add(VfsUtil.pathToUrl(file.getPath())); } return true; } }); return ArrayUtil.toStringArray(urls); } catch (Exception e) { LOGGER.error(e); } } return ArrayUtil.EMPTY_STRING_ARRAY; }