Search in sources :

Example 11 with VirtualFilePointerContainer

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

the class LibraryImpl method addRoot.

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

Example 12 with VirtualFilePointerContainer

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

the class LibraryImpl method addJarDirectory.

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

Example 13 with VirtualFilePointerContainer

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

the class LibraryImpl method initRoots.

private Map<OrderRootType, VirtualFilePointerContainer> initRoots() {
    Disposer.register(this, myPointersDisposable);
    Map<OrderRootType, VirtualFilePointerContainer> result = new HashMap<>(4);
    for (OrderRootType rootType : getAllRootTypes()) {
        result.put(rootType, VirtualFilePointerManager.getInstance().createContainer(myPointersDisposable));
    }
    return result;
}
Also used : HashMap(com.intellij.util.containers.HashMap) OrderRootType(com.intellij.openapi.roots.OrderRootType) VirtualFilePointerContainer(com.intellij.openapi.vfs.pointers.VirtualFilePointerContainer)

Example 14 with VirtualFilePointerContainer

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

the class LibraryImpl method addJarDirectory.

@Override
public void addJarDirectory(@NotNull final VirtualFile file, final boolean recursive, @NotNull OrderRootType rootType) {
    checkDisposed();
    LOG.assertTrue(isWritable());
    final VirtualFilePointerContainer container = myRoots.get(rootType);
    container.add(file);
    myJarDirectories.add(rootType, file.getUrl(), recursive);
}
Also used : VirtualFilePointerContainer(com.intellij.openapi.vfs.pointers.VirtualFilePointerContainer)

Example 15 with VirtualFilePointerContainer

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

the class LibraryImpl method writeExternal.

@Override
public void writeExternal(Element rootElement) {
    checkDisposed();
    Element element = new Element(ELEMENT);
    if (myName != null) {
        element.setAttribute(LIBRARY_NAME_ATTR, myName);
    }
    if (myKind != null) {
        element.setAttribute(LIBRARY_TYPE_ATTR, myKind.getKindId());
        LOG.assertTrue(myProperties != null, "Properties is 'null' in library with kind " + myKind);
        final Object state = myProperties.getState();
        if (state != null) {
            final Element propertiesElement = XmlSerializer.serializeIfNotDefault(state, SERIALIZATION_FILTERS);
            if (!JDOMUtil.isEmpty(propertiesElement)) {
                element.addContent(propertiesElement.setName(PROPERTIES_ELEMENT));
            }
        }
    }
    ArrayList<OrderRootType> storableRootTypes = new ArrayList<>();
    storableRootTypes.addAll(Arrays.asList(OrderRootType.getAllTypes()));
    if (myKind != null) {
        storableRootTypes.addAll(Arrays.asList(myKind.getAdditionalRootTypes()));
    }
    for (OrderRootType rootType : sortRootTypes(storableRootTypes)) {
        final VirtualFilePointerContainer roots = myRoots.get(rootType);
        if (roots.size() == 0 && rootType.skipWriteIfEmpty()) {
            //compatibility iml/ipr
            continue;
        }
        final Element rootTypeElement = new Element(rootType.name());
        roots.writeExternal(rootTypeElement, ROOT_PATH_ELEMENT);
        element.addContent(rootTypeElement);
    }
    if (myExcludedRoots != null && myExcludedRoots.size() > 0) {
        Element excluded = new Element(EXCLUDED_ROOTS_TAG);
        myExcludedRoots.writeExternal(excluded, ROOT_PATH_ELEMENT);
        element.addContent(excluded);
    }
    myJarDirectories.writeExternal(element);
    rootElement.addContent(element);
}
Also used : OrderRootType(com.intellij.openapi.roots.OrderRootType) Element(org.jdom.Element) 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