2 * Copyright 2000-2011 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.testFramework.vcs;
18 import com.intellij.openapi.project.Project;
19 import com.intellij.openapi.vcs.AbstractVcs;
20 import com.intellij.openapi.vcs.FilePath;
21 import com.intellij.openapi.vcs.ProjectLevelVcsManager;
22 import com.intellij.openapi.vcs.changes.VcsModifiableDirtyScope;
23 import com.intellij.openapi.vfs.VirtualFile;
24 import com.intellij.util.Processor;
25 import org.jetbrains.annotations.NotNull;
26 import org.jetbrains.annotations.Nullable;
28 import java.util.Collection;
29 import java.util.HashSet;
33 * Mock implementation of {@link com.intellij.openapi.vcs.changes.VcsDirtyScope}.
34 * Stores files and dirs separately without any check.
35 * Not all operations may be supported.
37 * @author Kirill Likhodedov
39 public class MockDirtyScope extends VcsModifiableDirtyScope {
41 private final Project myProject;
42 private final AbstractVcs myVcs;
43 private final ProjectLevelVcsManager myVcsManager;
45 private final Set<FilePath> myDirtyFiles = new HashSet<FilePath>();
46 private final Set<FilePath> myDirtyDirs = new HashSet<FilePath>();
47 private final Set<VirtualFile> myContentRoots = new HashSet<VirtualFile>();
49 public MockDirtyScope(@NotNull Project project, @NotNull AbstractVcs vcs) {
52 myVcsManager = ProjectLevelVcsManager.getInstance(myProject);
56 public void addDirtyFile(@Nullable FilePath newcomer) {
57 myDirtyFiles.add(newcomer);
58 myContentRoots.add(myVcsManager.getVcsRootFor(newcomer.getVirtualFile()));
62 public void addDirtyDirRecursively(@Nullable FilePath newcomer) {
63 myDirtyDirs.add(newcomer);
64 myContentRoots.add(myVcsManager.getVcsRootFor(newcomer.getVirtualFile()));
69 public Collection<VirtualFile> getAffectedContentRoots() {
70 return myContentRoots;
75 public Project getProject() {
81 public AbstractVcs getVcs() {
87 public Set<FilePath> getDirtyFiles() {
93 public Set<FilePath> getDirtyFilesNoExpand() {
99 public Set<FilePath> getRecursivelyDirtyDirectories() {
104 public boolean isRecursivelyDirty(VirtualFile vf) {
105 throw new UnsupportedOperationException();
109 public void iterate(Processor<FilePath> iterator) {
110 throw new UnsupportedOperationException();
114 public boolean isEmpty() {
115 return myDirtyFiles.isEmpty();
119 public boolean belongsTo(FilePath path) {
120 throw new UnsupportedOperationException();