Search in sources :

Example 6 with VirtualFilePointerContainer

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

the class JpsLibraryDelegate method getInvalidRootUrls.

@Override
public List<String> getInvalidRootUrls(OrderRootType type) {
    final VirtualFilePointerContainer container = myRoots.get(type);
    if (container == null)
        return Collections.emptyList();
    final List<VirtualFilePointer> pointers = container.getList();
    List<String> invalidPaths = null;
    for (VirtualFilePointer pointer : pointers) {
        if (!pointer.isValid()) {
            if (invalidPaths == null) {
                invalidPaths = new SmartList<>();
            }
            invalidPaths.add(pointer.getUrl());
        }
    }
    return invalidPaths == null ? Collections.<String>emptyList() : invalidPaths;
}
Also used : VirtualFilePointer(com.intellij.openapi.vfs.pointers.VirtualFilePointer) VirtualFilePointerContainer(com.intellij.openapi.vfs.pointers.VirtualFilePointerContainer)

Example 7 with VirtualFilePointerContainer

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

the class JpsLibraryDelegate method isValid.

@Override
public boolean isValid(@NotNull String url, @NotNull OrderRootType rootType) {
    final VirtualFilePointerContainer container = myRoots.get(rootType);
    if (container == null)
        return false;
    final VirtualFilePointer fp = container.findByUrl(url);
    return fp != null && fp.isValid();
}
Also used : VirtualFilePointer(com.intellij.openapi.vfs.pointers.VirtualFilePointer) VirtualFilePointerContainer(com.intellij.openapi.vfs.pointers.VirtualFilePointerContainer)

Example 8 with VirtualFilePointerContainer

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

the class JpsLibraryDelegate method getFiles.

@NotNull
@Override
public VirtualFile[] getFiles(@NotNull OrderRootType rootType) {
    final VirtualFilePointerContainer container = myRoots.get(rootType);
    if (container == null)
        return VirtualFile.EMPTY_ARRAY;
    final List<VirtualFile> expanded = new ArrayList<>();
    for (JpsLibraryRoot root : myJpsLibrary.getRoots(getJpsRootType(rootType))) {
        final VirtualFilePointer pointer = container.findByUrl(root.getUrl());
        if (pointer == null)
            continue;
        VirtualFile file = pointer.getFile();
        if (file == null)
            continue;
        if (file.isDirectory() && root.getInclusionOptions() != JpsLibraryRoot.InclusionOptions.ROOT_ITSELF) {
            LibraryImpl.collectJarFiles(file, expanded, root.getInclusionOptions() == JpsLibraryRoot.InclusionOptions.ARCHIVES_UNDER_ROOT_RECURSIVELY);
            continue;
        }
        expanded.add(file);
    }
    return VfsUtilCore.toVirtualFileArray(expanded);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) JpsLibraryRoot(org.jetbrains.jps.model.library.JpsLibraryRoot) VirtualFilePointer(com.intellij.openapi.vfs.pointers.VirtualFilePointer) VirtualFilePointerContainer(com.intellij.openapi.vfs.pointers.VirtualFilePointerContainer) NotNull(org.jetbrains.annotations.NotNull)

Example 9 with VirtualFilePointerContainer

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

the class OrderRootsCache method setCachedRoots.

public VirtualFilePointerContainer setCachedRoots(OrderRootType rootType, int flags, Collection<String> urls) {
    final VirtualFilePointerContainer container = VirtualFilePointerManager.getInstance().createContainer(myParentDisposable);
    for (String url : urls) {
        container.add(url);
    }
    myRoots.put(new CacheKey(rootType, flags), container);
    return container;
}
Also used : VirtualFilePointerContainer(com.intellij.openapi.vfs.pointers.VirtualFilePointerContainer)

Example 10 with VirtualFilePointerContainer

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

the class LibraryImpl method disposeMyPointers.

private void disposeMyPointers() {
    for (VirtualFilePointerContainer container : new THashSet<>(myRoots.values())) {
        container.killAll();
    }
    if (myExcludedRoots != null) {
        myExcludedRoots.killAll();
    }
    Disposer.dispose(myPointersDisposable);
    Disposer.register(this, myPointersDisposable);
}
Also used : THashSet(gnu.trove.THashSet) 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