Search in sources :

Example 11 with NewVirtualFile

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();
}
Also used : NewVirtualFile(com.intellij.openapi.vfs.newvfs.NewVirtualFile) UIUtil(com.intellij.util.ui.UIUtil) Arrays(java.util.Arrays) JobLauncher(com.intellij.concurrency.JobLauncher) EdtTestUtil(com.intellij.testFramework.EdtTestUtil) JobSchedulerImpl(com.intellij.concurrency.JobSchedulerImpl) SkipSlowTestLocally(com.intellij.testFramework.SkipSlowTestLocally) Disposer(com.intellij.openapi.util.Disposer) WriteCommandAction(com.intellij.openapi.command.WriteCommandAction) FileUtil(com.intellij.openapi.util.io.FileUtil) ThrowableRunnable(com.intellij.util.ThrowableRunnable) ProgressManager(com.intellij.openapi.progress.ProgressManager) PlatformTestUtil(com.intellij.testFramework.PlatformTestUtil) NewVirtualFile(com.intellij.openapi.vfs.newvfs.NewVirtualFile) StringUtil(com.intellij.openapi.util.text.StringUtil) Test(org.junit.Test) IOException(java.io.IOException) File(java.io.File) TimeUnit(java.util.concurrent.TimeUnit) CountDownLatch(java.util.concurrent.CountDownLatch) BareTestFixtureTestCase(com.intellij.testFramework.fixtures.BareTestFixtureTestCase) Rule(org.junit.Rule) ManagingFS(com.intellij.openapi.vfs.newvfs.ManagingFS) TempDirectory(com.intellij.testFramework.rules.TempDirectory) ExceptionUtil(com.intellij.util.ExceptionUtil) TimeoutUtil(com.intellij.util.TimeoutUtil) IoTestUtil(com.intellij.openapi.util.io.IoTestUtil) LightTempDirTestFixtureImpl(com.intellij.testFramework.fixtures.impl.LightTempDirTestFixtureImpl) Assert(org.junit.Assert) Ref(com.intellij.openapi.util.Ref) Collections(java.util.Collections) NewVirtualFile(com.intellij.openapi.vfs.newvfs.NewVirtualFile) NewVirtualFile(com.intellij.openapi.vfs.newvfs.NewVirtualFile) File(java.io.File) Test(org.junit.Test)

Example 12 with NewVirtualFile

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);
}
Also used : NewVirtualFile(com.intellij.openapi.vfs.newvfs.NewVirtualFile) NewVirtualFile(com.intellij.openapi.vfs.newvfs.NewVirtualFile) NewVirtualFile(com.intellij.openapi.vfs.newvfs.NewVirtualFile) File(java.io.File) Test(org.junit.Test)

Example 13 with NewVirtualFile

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);
}
Also used : NewVirtualFile(com.intellij.openapi.vfs.newvfs.NewVirtualFile) VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) NewVirtualFile(com.intellij.openapi.vfs.newvfs.NewVirtualFile)

Example 14 with NewVirtualFile

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);
        }
    }
}
Also used : NewVirtualFile(com.intellij.openapi.vfs.newvfs.NewVirtualFile) NewVirtualFile(com.intellij.openapi.vfs.newvfs.NewVirtualFile) NewVirtualFile(com.intellij.openapi.vfs.newvfs.NewVirtualFile) File(java.io.File)

Example 15 with NewVirtualFile

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);
}
Also used : IFileElementType(com.intellij.psi.tree.IFileElementType) LanguageFileType(com.intellij.openapi.fileTypes.LanguageFileType) ParserDefinition(com.intellij.lang.ParserDefinition) IStubFileElementType(com.intellij.psi.tree.IStubFileElementType) Language(com.intellij.lang.Language) FileType(com.intellij.openapi.fileTypes.FileType) LanguageFileType(com.intellij.openapi.fileTypes.LanguageFileType) NewVirtualFile(com.intellij.openapi.vfs.newvfs.NewVirtualFile)

Aggregations

NewVirtualFile (com.intellij.openapi.vfs.newvfs.NewVirtualFile)18 VirtualFile (com.intellij.openapi.vfs.VirtualFile)8 File (java.io.File)4 VirtualDirectoryImpl (com.intellij.openapi.vfs.newvfs.impl.VirtualDirectoryImpl)2 IOException (java.io.IOException)2 Test (org.junit.Test)2 JobLauncher (com.intellij.concurrency.JobLauncher)1 JobSchedulerImpl (com.intellij.concurrency.JobSchedulerImpl)1 Language (com.intellij.lang.Language)1 ParserDefinition (com.intellij.lang.ParserDefinition)1 Application (com.intellij.openapi.application.Application)1 WriteCommandAction (com.intellij.openapi.command.WriteCommandAction)1 Document (com.intellij.openapi.editor.Document)1 FileEditor (com.intellij.openapi.fileEditor.FileEditor)1 FileType (com.intellij.openapi.fileTypes.FileType)1 LanguageFileType (com.intellij.openapi.fileTypes.LanguageFileType)1 ProgressManager (com.intellij.openapi.progress.ProgressManager)1 Project (com.intellij.openapi.project.Project)1 Disposer (com.intellij.openapi.util.Disposer)1 Ref (com.intellij.openapi.util.Ref)1