Search in sources :

Example 1 with VirtualFileSystemEntry

use of com.intellij.openapi.vfs.newvfs.impl.VirtualFileSystemEntry in project intellij-community by JetBrains.

the class LocalFileSystemTest method testBadFileName.

public void testBadFileName() throws Exception {
    if (!SystemInfo.isUnix) {
        System.err.println(getName() + " skipped: " + SystemInfo.OS_NAME);
        return;
    }
    final File dir = FileUtil.createTempDirectory("test.", ".dir");
    final File file = FileUtil.createTempFile(dir, "test\\", "\\txt", true);
    final VirtualFile vDir = myFS.refreshAndFindFileByIoFile(dir);
    assertNotNull(vDir);
    assertEquals(0, vDir.getChildren().length);
    ((VirtualFileSystemEntry) vDir).markDirtyRecursively();
    vDir.refresh(false, true);
    final VirtualFile vFile = myFS.refreshAndFindFileByIoFile(file);
    assertNull(vFile);
}
Also used : VirtualFileSystemEntry(com.intellij.openapi.vfs.newvfs.impl.VirtualFileSystemEntry) File(java.io.File)

Example 2 with VirtualFileSystemEntry

use of com.intellij.openapi.vfs.newvfs.impl.VirtualFileSystemEntry in project intellij-community by JetBrains.

the class IdeaGateway method doCreateEntry.

@Nullable
private Entry doCreateEntry(@NotNull VirtualFile file, boolean forDeletion) {
    if (!file.isDirectory()) {
        if (!isVersioned(file))
            return null;
        Pair<StoredContent, Long> contentAndStamps;
        if (forDeletion) {
            FileDocumentManager m = FileDocumentManager.getInstance();
            // should not try to load document
            Document d = m.isFileModified(file) ? m.getCachedDocument(file) : null;
            contentAndStamps = acquireAndClearCurrentContent(file, d);
        } else {
            contentAndStamps = getActualContentNoAcquire(file);
        }
        return doCreateFileEntry(file, contentAndStamps);
    }
    DirectoryEntry newDir = null;
    if (file instanceof VirtualFileSystemEntry) {
        int nameId = ((VirtualFileSystemEntry) file).getNameId();
        if (nameId > 0) {
            newDir = new DirectoryEntry(nameId);
        }
    }
    if (newDir == null) {
        newDir = new DirectoryEntry(file.getName());
    }
    doCreateChildren(newDir, iterateDBChildren(file), forDeletion);
    if (!isVersioned(file) && newDir.getChildren().isEmpty())
        return null;
    return newDir;
}
Also used : VirtualFileSystemEntry(com.intellij.openapi.vfs.newvfs.impl.VirtualFileSystemEntry) FileDocumentManager(com.intellij.openapi.fileEditor.FileDocumentManager) StoredContent(com.intellij.history.core.StoredContent) Document(com.intellij.openapi.editor.Document) DirectoryEntry(com.intellij.history.core.tree.DirectoryEntry) Nullable(org.jetbrains.annotations.Nullable)

Example 3 with VirtualFileSystemEntry

use of com.intellij.openapi.vfs.newvfs.impl.VirtualFileSystemEntry in project idea-php-typo3-plugin by cedricziel.

the class ExtensionDefinitionFactory method fromDirectory.

public static TYPO3ExtensionDefinition fromDirectory(VirtualDirectoryImpl virtualDirectory) {
    TYPO3ExtensionDefinition extensionDefinition = null;
    // try finding composer manifest
    VirtualFileSystemEntry composerManifest = virtualDirectory.findChild("composer.json");
    if (composerManifest != null) {
        try {
            extensionDefinition = fromComposerManifest(composerManifest);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    return extensionDefinition != null ? extensionDefinition : null;
}
Also used : VirtualFileSystemEntry(com.intellij.openapi.vfs.newvfs.impl.VirtualFileSystemEntry) IOException(java.io.IOException) TYPO3ExtensionDefinition(com.cedricziel.idea.typo3.domain.TYPO3ExtensionDefinition)

Example 4 with VirtualFileSystemEntry

use of com.intellij.openapi.vfs.newvfs.impl.VirtualFileSystemEntry in project intellij-community by JetBrains.

the class ComputeVirtualFileNameStatAction method compute.

private void compute(VirtualFile root) {
    String name = root.getName();
    if (!nameCount.increment(name))
        nameCount.put(name, 1);
    for (int i = 1; i <= name.length(); i++) {
        //String prefix = name.substring(0, i);
        //if (!prefixes.increment(prefix)) prefixes.put(prefix, 1);
        String suffix = name.substring(name.length() - i);
        if (!suffixes.increment(suffix))
            suffixes.put(suffix, 1);
    }
    Collection<VirtualFile> cachedChildren = ((VirtualFileSystemEntry) root).getCachedChildren();
    //VirtualFile[] cachedChildren = ((VirtualFileSystemEntry)root).getChildren();
    for (VirtualFile cachedChild : cachedChildren) {
        compute(cachedChild);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) VirtualFileSystemEntry(com.intellij.openapi.vfs.newvfs.impl.VirtualFileSystemEntry)

Example 5 with VirtualFileSystemEntry

use of com.intellij.openapi.vfs.newvfs.impl.VirtualFileSystemEntry in project intellij-community by JetBrains.

the class InlineLibraryMethodTest method testInlineAllInProjectFromLibrary.

public void testInlineAllInProjectFromLibrary() throws Exception {
    configureByText(JavaFileType.INSTANCE, "package mycompany;\n" + "public class File {\n" + " public static File createTempFile(String pr, String postfix){return createTempFile(pr, postfix, null);}\n" + " public static File createTempFile(String pr, String postfix, String base){return new File();}\n" + "}");
    @NonNls String fileName = "/refactoring/inlineMethod/" + getTestName(false) + ".java";
    configureByFile(fileName);
    PsiClass fileClass = getJavaFacade().findClass("mycompany.File");
    assertNotNull(fileClass);
    final PsiFile file = fileClass.getContainingFile();
    WriteCommandAction.runWriteCommandAction(null, () -> {
        try {
            ((VirtualFileSystemEntry) file.getVirtualFile()).setWritable(false);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    });
    PsiElement element = null;
    PsiMethod[] createTempFiles = fileClass.findMethodsByName("createTempFile", false);
    for (PsiMethod createTempFile : createTempFiles) {
        if (createTempFile.getParameterList().getParametersCount() == 2) {
            element = createTempFile;
            break;
        }
    }
    assertNotNull(element);
    PsiMethod method = (PsiMethod) element;
    final boolean condition = InlineMethodProcessor.checkBadReturns(method) && !InlineUtil.allUsagesAreTailCalls(method);
    assertFalse("Bad returns found", condition);
    final InlineMethodProcessor processor = new InlineMethodProcessor(getProject(), method, null, myEditor, false);
    processor.run();
    checkResultByFile(fileName + ".after");
}
Also used : NonNls(org.jetbrains.annotations.NonNls) VirtualFileSystemEntry(com.intellij.openapi.vfs.newvfs.impl.VirtualFileSystemEntry) PsiMethod(com.intellij.psi.PsiMethod) PsiClass(com.intellij.psi.PsiClass) PsiFile(com.intellij.psi.PsiFile) IOException(java.io.IOException) PsiElement(com.intellij.psi.PsiElement)

Aggregations

VirtualFileSystemEntry (com.intellij.openapi.vfs.newvfs.impl.VirtualFileSystemEntry)5 IOException (java.io.IOException)2 TYPO3ExtensionDefinition (com.cedricziel.idea.typo3.domain.TYPO3ExtensionDefinition)1 StoredContent (com.intellij.history.core.StoredContent)1 DirectoryEntry (com.intellij.history.core.tree.DirectoryEntry)1 Document (com.intellij.openapi.editor.Document)1 FileDocumentManager (com.intellij.openapi.fileEditor.FileDocumentManager)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 PsiClass (com.intellij.psi.PsiClass)1 PsiElement (com.intellij.psi.PsiElement)1 PsiFile (com.intellij.psi.PsiFile)1 PsiMethod (com.intellij.psi.PsiMethod)1 File (java.io.File)1 NonNls (org.jetbrains.annotations.NonNls)1 Nullable (org.jetbrains.annotations.Nullable)1