public static String displayUrlRelativeToProject(@NotNull VirtualFile file, @NotNull String url, @NotNull Project project, boolean includeFilePath, boolean keepModuleAlwaysOnTheLeft) { final VirtualFile baseDir = project.getBaseDir(); if (baseDir != null && includeFilePath) { //noinspection ConstantConditions final String projectHomeUrl = baseDir.getPresentableUrl(); if (url.startsWith(projectHomeUrl)) { url = "..." + url.substring(projectHomeUrl.length()); } } if (SystemInfo.isMac && file.getFileSystem() instanceof LocalFileProvider) { final VirtualFile fileForJar = ((LocalFileProvider)file.getFileSystem()).getLocalVirtualFileFor(file); if (fileForJar != null) { final OrderEntry libraryEntry = LibraryUtil.findLibraryEntry(file, project); if (libraryEntry != null) { if (libraryEntry instanceof JdkOrderEntry) { url = url + " - [" + ((JdkOrderEntry)libraryEntry).getJdkName() + "]"; } else { url = url + " - [" + libraryEntry.getPresentableName() + "]"; } } else { url = url + " - [" + fileForJar.getName() + "]"; } } } final Module module = ModuleUtilCore.findModuleForFile(file, project); if (module == null) return url; return !keepModuleAlwaysOnTheLeft && SystemInfo.isMac ? url + " - [" + module.getName() + "]" : "[" + module.getName() + "] - " + url; }
@NotNull public static VirtualFile getLocalFile(@NotNull VirtualFile file) { if (!file.isValid()) { return file; } if (file.getFileSystem() instanceof LocalFileProvider) { final VirtualFile localFile = ((LocalFileProvider)file.getFileSystem()).getLocalVirtualFileFor(file); if (localFile != null) { return localFile; } } return file; }
@Nonnull public static VirtualFile getLocalFile(@Nonnull VirtualFile file) { if (!file.isValid()) { return file; } if (file.getFileSystem() instanceof LocalFileProvider) { final VirtualFile localFile = ((LocalFileProvider)file.getFileSystem()).getLocalVirtualFileFor(file); if (localFile != null) { return localFile; } } return file; }
public static String displayUrlRelativeToProject(@Nonnull VirtualFile file, @Nonnull String url, @Nonnull Project project, boolean includeFilePath, boolean keepModuleAlwaysOnTheLeft) { final VirtualFile baseDir = project.getBaseDir(); if (baseDir != null && includeFilePath) { //noinspection ConstantConditions final String projectHomeUrl = baseDir.getPresentableUrl(); if (url.startsWith(projectHomeUrl)) { url = "..." + url.substring(projectHomeUrl.length()); } } if (SystemInfo.isMac && file.getFileSystem() instanceof LocalFileProvider) { final VirtualFile fileForJar = ((LocalFileProvider)file.getFileSystem()).getLocalVirtualFileFor(file); if (fileForJar != null) { final OrderEntry libraryEntry = LibraryUtil.findLibraryEntry(file, project); if (libraryEntry != null) { if (libraryEntry instanceof ModuleExtensionWithSdkOrderEntry) { url = url + " - [" + ((ModuleExtensionWithSdkOrderEntry)libraryEntry).getSdkName() + "]"; } else { url = url + " - [" + libraryEntry.getPresentableName() + "]"; } } else { url = url + " - [" + fileForJar.getName() + "]"; } } } final Module module = ModuleUtilCore.findModuleForFile(file, project); if (module == null) return url; return !keepModuleAlwaysOnTheLeft && SystemInfo.isMac ? url + " - [" + module.getName() + "]" : "[" + module.getName() + "] - " + url; }
private static VirtualFile getLocalFor(VirtualFile virtualFile) { VirtualFileSystem fileSystem = virtualFile == null ? null : virtualFile.getFileSystem(); return fileSystem instanceof LocalFileProvider ? ((LocalFileProvider)fileSystem).getLocalVirtualFileFor(virtualFile) : null; }
public abstract List<LocalFileProvider> getLocalFileProviders();