Search in sources :

Example 6 with DirectoryEntry

use of com.intellij.history.core.tree.DirectoryEntry 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 7 with DirectoryEntry

use of com.intellij.history.core.tree.DirectoryEntry in project intellij-community by JetBrains.

the class IdeaGateway method doCreateChildrenForPathOnly.

private void doCreateChildrenForPathOnly(@NotNull DirectoryEntry parent, @NotNull String path, @NotNull Iterable<VirtualFile> children) {
    for (VirtualFile child : children) {
        // on Mac FS root name is "/"
        String name = StringUtil.trimStart(child.getName(), "/");
        if (!path.startsWith(name))
            continue;
        String rest = path.substring(name.length());
        if (!rest.isEmpty() && rest.charAt(0) != '/')
            continue;
        if (!rest.isEmpty() && rest.charAt(0) == '/') {
            rest = rest.substring(1);
        }
        Entry e = doCreateEntryForPathOnly(child, rest);
        if (e == null)
            continue;
        parent.addChild(e);
    }
}
Also used : NewVirtualFile(com.intellij.openapi.vfs.newvfs.NewVirtualFile) Entry(com.intellij.history.core.tree.Entry) RootEntry(com.intellij.history.core.tree.RootEntry) FileEntry(com.intellij.history.core.tree.FileEntry) DirectoryEntry(com.intellij.history.core.tree.DirectoryEntry) VirtualFileSystemEntry(com.intellij.openapi.vfs.newvfs.impl.VirtualFileSystemEntry)

Example 8 with DirectoryEntry

use of com.intellij.history.core.tree.DirectoryEntry in project intellij-community by JetBrains.

the class IdeaGateway method doCreateEntryForPathOnly.

@Nullable
private Entry doCreateEntryForPathOnly(@NotNull VirtualFile file, @NotNull String path) {
    if (!file.isDirectory()) {
        if (!isVersioned(file))
            return null;
        return doCreateFileEntry(file, getActualContentNoAcquire(file));
    }
    DirectoryEntry newDir = new DirectoryEntry(file.getName());
    doCreateChildrenForPathOnly(newDir, path, iterateDBChildren(file));
    if (!isVersioned(file) && newDir.getChildren().isEmpty())
        return null;
    return newDir;
}
Also used : DirectoryEntry(com.intellij.history.core.tree.DirectoryEntry) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

DirectoryEntry (com.intellij.history.core.tree.DirectoryEntry)8 Entry (com.intellij.history.core.tree.Entry)6 FileEntry (com.intellij.history.core.tree.FileEntry)5 RootEntry (com.intellij.history.core.tree.RootEntry)5 StoredContent (com.intellij.history.core.StoredContent)4 Test (org.junit.Test)4 VirtualFileSystemEntry (com.intellij.openapi.vfs.newvfs.impl.VirtualFileSystemEntry)2 Nullable (org.jetbrains.annotations.Nullable)2 Difference (com.intellij.history.core.revisions.Difference)1 Document (com.intellij.openapi.editor.Document)1 FileDocumentManager (com.intellij.openapi.fileEditor.FileDocumentManager)1 NewVirtualFile (com.intellij.openapi.vfs.newvfs.NewVirtualFile)1