use of com.intellij.openapi.vfs.newvfs.NewVirtualFile in project intellij-community by JetBrains.
the class VfsUtilPerformanceTest method testFindRootPerformance.
@Test
public void testFindRootPerformance() throws IOException {
File tempJar = IoTestUtil.createTestJar(myTempDir.newFile("test.jar"));
VirtualFile jar = LocalFileSystem.getInstance().findFileByIoFile(tempJar);
assertNotNull(jar);
JarFileSystem fs = JarFileSystem.getInstance();
String path = jar.getPath() + "!/";
NewVirtualFile root = ManagingFS.getInstance().findRoot(path, fs);
PlatformTestUtil.startPerformanceTest("find root is slow", 5000, () -> JobLauncher.getInstance().invokeConcurrentlyUnderProgress(Collections.nCopies(500, null), null, false, false, o -> {
for (int i = 0; i < 20000; i++) {
NewVirtualFile rootJar = ManagingFS.getInstance().findRoot(path, fs);
assertNotNull(rootJar);
assertSame(root, rootJar);
}
return true;
})).useLegacyScaling().assertTiming();
}
use of com.intellij.openapi.vfs.newvfs.NewVirtualFile in project intellij-community by JetBrains.
the class VfsUtilTest method testFindRootWithDenormalizedPath.
@Test
public void testFindRootWithDenormalizedPath() throws IOException {
File tempJar = IoTestUtil.createTestJar(myTempDir.newFile("test.jar"));
VirtualFile jar = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(tempJar);
assertNotNull(jar);
JarFileSystem fs = JarFileSystem.getInstance();
NewVirtualFile root1 = ManagingFS.getInstance().findRoot(jar.getPath() + "!/", fs);
NewVirtualFile root2 = ManagingFS.getInstance().findRoot(jar.getParent().getPath() + "//" + jar.getName() + "!/", fs);
assertNotNull(root1);
assertSame(root1, root2);
}
use of com.intellij.openapi.vfs.newvfs.NewVirtualFile in project intellij-community by JetBrains.
the class SynchronizeCurrentFileAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
final Project project = getEventProject(e);
final VirtualFile[] files = getFiles(e);
if (project == null || files == null || files.length == 0)
return;
ApplicationManager.getApplication().runWriteAction(() -> {
for (VirtualFile file : files) {
if (file instanceof NewVirtualFile) {
((NewVirtualFile) file).markDirtyRecursively();
}
}
});
RefreshQueue.getInstance().refresh(true, true, () -> postRefresh(project, files), files);
}
use of com.intellij.openapi.vfs.newvfs.NewVirtualFile in project intellij-community by JetBrains.
the class VcsVFSListener method addFileToDelete.
private void addFileToDelete(VirtualFile file) {
if (file.isDirectory() && file instanceof NewVirtualFile && !isDirectoryVersioningSupported()) {
for (VirtualFile child : ((NewVirtualFile) file).getCachedChildren()) {
addFileToDelete(child);
}
} else {
final VcsDeleteType type = needConfirmDeletion(file);
final FilePath filePath = VcsContextFactory.SERVICE.getInstance().createFilePathOnDeleted(new File(file.getPath()), file.isDirectory());
if (type == VcsDeleteType.CONFIRM) {
myDeletedFiles.add(filePath);
} else if (type == VcsDeleteType.SILENT) {
myDeletedWithoutConfirmFiles.add(filePath);
}
}
}
use of com.intellij.openapi.vfs.newvfs.NewVirtualFile in project intellij-community by JetBrains.
the class StubUpdatingIndex method canHaveStub.
public static boolean canHaveStub(@NotNull VirtualFile file) {
final FileType fileType = file.getFileType();
if (fileType instanceof LanguageFileType) {
final Language l = ((LanguageFileType) fileType).getLanguage();
final ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(l);
if (parserDefinition == null) {
return false;
}
final IFileElementType elementType = parserDefinition.getFileNodeType();
if (elementType instanceof IStubFileElementType) {
if (((IStubFileElementType) elementType).shouldBuildStubFor(file)) {
return true;
}
FileBasedIndex fileBasedIndex = FileBasedIndex.getInstance();
if (file instanceof NewVirtualFile && fileBasedIndex instanceof FileBasedIndexImpl && ((FileBasedIndexImpl) fileBasedIndex).getIndex(INDEX_ID).isIndexedStateForFile(((NewVirtualFile) file).getId(), file)) {
return true;
}
}
}
final BinaryFileStubBuilder builder = BinaryFileStubBuilders.INSTANCE.forFileType(fileType);
return builder != null && builder.acceptsFile(file);
}
Aggregations