Search in sources :

Example 1 with VirtualFilePointerContainer

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

the class FileAssociationsManagerImpl method getAssociationsFor.

public PsiFile[] getAssociationsFor(PsiFile file, FileType... fileTypes) {
    final VirtualFile virtualFile = file.getVirtualFile();
    if (virtualFile == null)
        return PsiFile.EMPTY_ARRAY;
    for (VirtualFilePointer pointer : myAssociations.keySet()) {
        if (pointer.isValid() && pointer.getUrl().equals(virtualFile.getUrl())) {
            final VirtualFilePointerContainer container = myAssociations.get(pointer);
            if (container != null) {
                final VirtualFile[] files = container.getFiles();
                final Set<PsiFile> list = new HashSet<>();
                final PsiManager psiManager = PsiManager.getInstance(myProject);
                for (VirtualFile assoc : files) {
                    final PsiFile psiFile = psiManager.findFile(assoc);
                    if (psiFile != null && (fileTypes.length == 0 || matchesFileType(psiFile, fileTypes))) {
                        list.add(psiFile);
                    }
                }
                return PsiUtilCore.toPsiFileArray(list);
            } else {
                return PsiFile.EMPTY_ARRAY;
            }
        }
    }
    return PsiFile.EMPTY_ARRAY;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) PsiManager(com.intellij.psi.PsiManager) PsiFile(com.intellij.psi.PsiFile) VirtualFilePointer(com.intellij.openapi.vfs.pointers.VirtualFilePointer) VirtualFilePointerContainer(com.intellij.openapi.vfs.pointers.VirtualFilePointerContainer)

Example 2 with VirtualFilePointerContainer

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

the class FileAssociationsManagerImpl method readExternal.

@SuppressWarnings({ "unchecked" })
public void readExternal(Element element) throws InvalidDataException {
    final List<Element> children = element.getChildren("file");
    for (Element child : children) {
        final String url = child.getAttributeValue("url");
        if (url != null) {
            final VirtualFilePointer pointer = myFilePointerManager.create(url, myProject, null);
            final VirtualFilePointerContainer container = myFilePointerManager.createContainer(myProject);
            container.readExternal(child, "association");
            myAssociations.put(pointer, container);
        }
    }
}
Also used : Element(org.jdom.Element) VirtualFilePointer(com.intellij.openapi.vfs.pointers.VirtualFilePointer) VirtualFilePointerContainer(com.intellij.openapi.vfs.pointers.VirtualFilePointerContainer)

Example 3 with VirtualFilePointerContainer

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

the class DetectionExcludesConfigurationImpl method addExcludedFramework.

@Override
public void addExcludedFramework(@NotNull FrameworkType type) {
    convert();
    myExcludedFrameworks.add(type.getId());
    final VirtualFilePointerContainer container = myExcludedFiles.remove(type.getId());
    if (container != null) {
        container.clear();
    }
}
Also used : VirtualFilePointerContainer(com.intellij.openapi.vfs.pointers.VirtualFilePointerContainer)

Example 4 with VirtualFilePointerContainer

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

the class DetectionExcludesConfigurationImpl method getActualState.

@NotNull
public ExcludesConfigurationState getActualState() {
    ensureOldSettingsLoaded();
    final ExcludesConfigurationState state = new ExcludesConfigurationState();
    state.setDetectionEnabled(myDetectionEnabled);
    state.getFrameworkTypes().addAll(myExcludedFrameworks);
    Collections.sort(state.getFrameworkTypes(), String.CASE_INSENSITIVE_ORDER);
    for (String typeId : myExcludedFiles.keySet()) {
        final VirtualFilePointerContainer container = myExcludedFiles.get(typeId);
        for (String url : container.getUrls()) {
            state.getFiles().add(new ExcludedFileState(url, typeId));
        }
    }
    Collections.sort(state.getFiles(), (o1, o2) -> StringUtil.comparePairs(o1.getFrameworkType(), o1.getUrl(), o2.getFrameworkType(), o2.getUrl(), true));
    return state;
}
Also used : VirtualFilePointerContainer(com.intellij.openapi.vfs.pointers.VirtualFilePointerContainer) NotNull(org.jetbrains.annotations.NotNull)

Example 5 with VirtualFilePointerContainer

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

the class JavaModuleExternalPathsImpl method isChanged.

@Override
public boolean isChanged() {
    if (myOrderRootPointerContainers.size() != mySource.myOrderRootPointerContainers.size())
        return true;
    for (final OrderRootType type : myOrderRootPointerContainers.keySet()) {
        final VirtualFilePointerContainer container = myOrderRootPointerContainers.get(type);
        final VirtualFilePointerContainer otherContainer = mySource.myOrderRootPointerContainers.get(type);
        if (container == null || otherContainer == null) {
            if (container != otherContainer)
                return true;
        } else {
            final String[] urls = container.getUrls();
            final String[] otherUrls = otherContainer.getUrls();
            if (urls.length != otherUrls.length)
                return true;
            for (int i = 0; i < urls.length; i++) {
                if (!Comparing.strEqual(urls[i], otherUrls[i]))
                    return true;
            }
        }
    }
    return false;
}
Also used : 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