IDEA-51905 (CVS: Update Project and Repository/Incoming views don't work if the VCS...
[fedora-idea.git] / plugins / cvs / cvs-plugin / src / com / intellij / cvsSupport2 / cvsoperations / common / FindAllRootsHelper.java
blob66447fceeef3735b7348044cb4b11bdbaa4e273f
1 /*
2 * Copyright 2000-2010 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package com.intellij.cvsSupport2.cvsoperations.common;
18 import com.intellij.cvsSupport2.CvsUtil;
19 import com.intellij.openapi.vcs.FilePath;
20 import com.intellij.openapi.vcs.FilePathImpl;
21 import com.intellij.openapi.vfs.VfsUtil;
22 import com.intellij.openapi.vfs.VirtualFile;
23 import com.intellij.util.Processor;
25 import java.util.ArrayList;
26 import java.util.List;
28 public class FindAllRootsHelper {
29 private FindAllRootsHelper() {
32 public static FilePath[] findVersionedUnder(final FilePath[] roots) {
33 final List<FilePath> result = new ArrayList<FilePath>();
35 final Processor<VirtualFile> processor = new Processor<VirtualFile>() {
36 public boolean process(VirtualFile file) {
37 final boolean underCvs = CvsUtil.fileIsUnderCvs(file);
38 if (underCvs) {
39 result.add(new FilePathImpl(file));
41 return ! underCvs;
45 for (FilePath root : roots) {
46 final VirtualFile vf = root.getVirtualFile();
47 if (vf == null) continue;
48 VfsUtil.processFilesRecursively(vf, processor);
50 return result.toArray(new FilePath[result.size()]);