Search in sources :

Example 26 with VirtualFilePointerContainer

use of com.intellij.openapi.vfs.pointers.VirtualFilePointerContainer in project intellij-community by JetBrains.

the class LibraryImpl method moveRootDown.

@Override
public void moveRootDown(@NotNull String url, @NotNull OrderRootType rootType) {
    checkDisposed();
    LOG.assertTrue(isWritable());
    final VirtualFilePointerContainer container = myRoots.get(rootType);
    container.moveDown(url);
}
Also used : VirtualFilePointerContainer(com.intellij.openapi.vfs.pointers.VirtualFilePointerContainer)

Example 27 with VirtualFilePointerContainer

use of com.intellij.openapi.vfs.pointers.VirtualFilePointerContainer in project intellij-community by JetBrains.

the class LibraryImpl method getUrls.

@Override
@NotNull
public String[] getUrls(@NotNull OrderRootType rootType) {
    checkDisposed();
    VirtualFilePointerContainer result = myRoots.get(rootType);
    return result == null ? ArrayUtilRt.EMPTY_STRING_ARRAY : result.getUrls();
}
Also used : VirtualFilePointerContainer(com.intellij.openapi.vfs.pointers.VirtualFilePointerContainer) NotNull(org.jetbrains.annotations.NotNull)

Example 28 with VirtualFilePointerContainer

use of com.intellij.openapi.vfs.pointers.VirtualFilePointerContainer in project intellij-community by JetBrains.

the class LibraryImpl method readRoots.

private void readRoots(Element element) throws InvalidDataException {
    for (OrderRootType rootType : getAllRootTypes()) {
        final Element rootChild = element.getChild(rootType.name());
        if (rootChild == null) {
            continue;
        }
        VirtualFilePointerContainer roots = myRoots.get(rootType);
        roots.readExternal(rootChild, ROOT_PATH_ELEMENT);
    }
    Element excludedRoot = element.getChild(EXCLUDED_ROOTS_TAG);
    if (excludedRoot != null) {
        getOrCreateExcludedRoots().readExternal(excludedRoot, ROOT_PATH_ELEMENT);
    }
}
Also used : OrderRootType(com.intellij.openapi.roots.OrderRootType) Element(org.jdom.Element) VirtualFilePointerContainer(com.intellij.openapi.vfs.pointers.VirtualFilePointerContainer)

Example 29 with VirtualFilePointerContainer

use of com.intellij.openapi.vfs.pointers.VirtualFilePointerContainer in project intellij-community by JetBrains.

the class LibraryImpl method removeRoot.

@Override
public boolean removeRoot(@NotNull String url, @NotNull OrderRootType rootType) {
    checkDisposed();
    LOG.assertTrue(isWritable());
    final VirtualFilePointerContainer container = myRoots.get(rootType);
    final VirtualFilePointer byUrl = container.findByUrl(url);
    if (byUrl != null) {
        container.remove(byUrl);
        if (myExcludedRoots != null) {
            for (String excludedRoot : myExcludedRoots.getUrls()) {
                if (!isUnderRoots(excludedRoot)) {
                    VirtualFilePointer pointer = myExcludedRoots.findByUrl(excludedRoot);
                    if (pointer != null) {
                        myExcludedRoots.remove(pointer);
                    }
                }
            }
        }
        myJarDirectories.remove(rootType, url);
        return true;
    }
    return false;
}
Also used : VirtualFilePointer(com.intellij.openapi.vfs.pointers.VirtualFilePointer) VirtualFilePointerContainer(com.intellij.openapi.vfs.pointers.VirtualFilePointerContainer)

Example 30 with VirtualFilePointerContainer

use of com.intellij.openapi.vfs.pointers.VirtualFilePointerContainer in project intellij-community by JetBrains.

the class FileAssociationsManagerImpl method addAssociation.

public void addAssociation(PsiFile file, VirtualFile assoc) {
    final VirtualFile virtualFile = file.getVirtualFile();
    if (virtualFile == null) {
        LOG.warn("No VirtualFile for " + file.getName());
        return;
    }
    for (VirtualFilePointer pointer : myAssociations.keySet()) {
        if (pointer.getUrl().equals(virtualFile.getUrl())) {
            VirtualFilePointerContainer container = myAssociations.get(pointer);
            if (container == null) {
                container = myFilePointerManager.createContainer(myProject);
                myAssociations.put(pointer, container);
            }
            if (container.findByUrl(assoc.getUrl()) == null) {
                container.add(assoc);
                touch();
            }
            return;
        }
    }
    final VirtualFilePointerContainer container = myFilePointerManager.createContainer(myProject);
    container.add(assoc);
    myAssociations.put(myFilePointerManager.create(virtualFile, myProject, null), container);
    touch();
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) VirtualFilePointer(com.intellij.openapi.vfs.pointers.VirtualFilePointer) VirtualFilePointerContainer(com.intellij.openapi.vfs.pointers.VirtualFilePointerContainer)

Aggregations

VirtualFilePointerContainer (com.intellij.openapi.vfs.pointers.VirtualFilePointerContainer)33 VirtualFilePointer (com.intellij.openapi.vfs.pointers.VirtualFilePointer)11 Element (org.jdom.Element)6 VirtualFile (com.intellij.openapi.vfs.VirtualFile)5 OrderRootType (com.intellij.openapi.roots.OrderRootType)4 NotNull (org.jetbrains.annotations.NotNull)4 HashMap (com.intellij.util.containers.HashMap)2 PsiFile (com.intellij.psi.PsiFile)1 PsiManager (com.intellij.psi.PsiManager)1 SmartList (com.intellij.util.SmartList)1 THashSet (gnu.trove.THashSet)1 JpsLibraryRoot (org.jetbrains.jps.model.library.JpsLibraryRoot)1