Search in sources :

Example 1 with IIgnoreFileFilter

use of org.netbeans.lib.cvsclient.util.IIgnoreFileFilter in project intellij-community by JetBrains.

the class ImportTree method getIgnoreFileFilter.

public IIgnoreFileFilter getIgnoreFileFilter() {
    final Collection<File> excludedFiles = new HashSet<>();
    for (final VirtualFile excludedFile : myExcludedFiles) {
        excludedFiles.add(CvsVfsUtil.getFileFor(excludedFile));
    }
    final Collection<File> includedFiles = new HashSet<>();
    for (VirtualFile includedFile : myIncludedFiles) {
        includedFiles.add(CvsVfsUtil.getFileFor(includedFile));
    }
    return new IIgnoreFileFilter() {

        private final Map<File, IgnoredFilesInfo> myParentToIgnoresMap = new HashMap<>();

        public boolean shouldBeIgnored(AbstractFileObject abstractFileObject, ICvsFileSystem cvsFileSystem) {
            final File file = cvsFileSystem.getLocalFileSystem().getFile(abstractFileObject);
            if (file.isDirectory() && file.getName().equals(CvsUtil.CVS))
                return true;
            if (FileTypeManager.getInstance().isFileIgnored(abstractFileObject.getName()))
                return true;
            final VirtualFile vFile = LocalFileSystem.getInstance().findFileByIoFile(file);
            if (myProject != null && !includedFiles.contains(file)) {
                if (vFile != null && isIgnoredByVcs(vFile)) {
                    return true;
                }
            }
            if (excludedFiles.contains(file))
                return true;
            final File parentFile = file.getParentFile();
            if (parentFile == null)
                return false;
            if (!myParentToIgnoresMap.containsKey(parentFile)) {
                myParentToIgnoresMap.put(parentFile, IgnoredFilesInfoImpl.createForFile(new File(parentFile, CvsUtil.CVS_IGNORE_FILE)));
            }
            return myParentToIgnoresMap.get(parentFile).shouldBeIgnored(vFile);
        }
    };
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ICvsFileSystem(org.netbeans.lib.cvsclient.file.ICvsFileSystem) IIgnoreFileFilter(org.netbeans.lib.cvsclient.util.IIgnoreFileFilter) AbstractFileObject(org.netbeans.lib.cvsclient.file.AbstractFileObject) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) HashMap(com.intellij.util.containers.HashMap) Map(java.util.Map) HashSet(com.intellij.util.containers.HashSet)

Aggregations

VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 HashMap (com.intellij.util.containers.HashMap)1 HashSet (com.intellij.util.containers.HashSet)1 File (java.io.File)1 Map (java.util.Map)1 AbstractFileObject (org.netbeans.lib.cvsclient.file.AbstractFileObject)1 ICvsFileSystem (org.netbeans.lib.cvsclient.file.ICvsFileSystem)1 IIgnoreFileFilter (org.netbeans.lib.cvsclient.util.IIgnoreFileFilter)1