2 * Copyright 2000-2009 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
.openapi
.vcs
.changes
;
18 import com
.intellij
.openapi
.vcs
.FilePath
;
19 import com
.intellij
.openapi
.vfs
.VirtualFile
;
20 import org
.jetbrains
.annotations
.NotNull
;
21 import org
.jetbrains
.annotations
.Nullable
;
23 import java
.util
.Collection
;
24 import java
.util
.HashSet
;
28 * to do not allow user to perform unknown activity under lock, pass mock manager
29 * use it later to call real manager under lock
31 class VcsDirtyScopeManagerProxy
extends VcsDirtyScopeManager
{
32 private boolean myEverythingDirty
;
33 // no grouping etc., let real manager do stuff
34 private final Set
<VirtualFile
> myVFiles
;
35 private final Set
<VirtualFile
> myVDirs
;
36 private final Set
<FilePath
> myFiles
;
37 private final Set
<FilePath
> myDirs
;
39 VcsDirtyScopeManagerProxy() {
40 myEverythingDirty
= false;
42 myVFiles
= new HashSet
<VirtualFile
>();
43 myVDirs
= new HashSet
<VirtualFile
>();
44 myFiles
= new HashSet
<FilePath
>();
45 myDirs
= new HashSet
<FilePath
>();
48 public void markEverythingDirty() {
49 myEverythingDirty
= true;
57 public void fileDirty(final VirtualFile file
) {
61 public void fileDirty(final FilePath file
) {
65 public void dirDirtyRecursively(final VirtualFile dir
, final boolean scheduleUpdate
) {
69 public void dirDirtyRecursively(final VirtualFile dir
) {
73 public void dirDirtyRecursively(final FilePath path
) {
77 public VcsInvalidated
retrieveScopes() {
78 throw new UnsupportedOperationException();
83 public Collection
<FilePath
> whatFilesDirty(@NotNull Collection
<FilePath
> files
) {
84 throw new UnsupportedOperationException();
87 public boolean filePathsDirty(@Nullable final Collection
<FilePath
> filesDirty
, @Nullable final Collection
<FilePath
> dirsRecursivelyDirty
) {
88 if (filesDirty
!= null) {
89 myFiles
.addAll(filesDirty
);
91 if (dirsRecursivelyDirty
!= null) {
92 myDirs
.addAll(dirsRecursivelyDirty
);
97 public boolean filesDirty(@Nullable final Collection
<VirtualFile
> filesDirty
, @Nullable final Collection
<VirtualFile
> dirsRecursivelyDirty
) {
98 if (filesDirty
!= null) {
99 myVFiles
.addAll(filesDirty
);
101 if (dirsRecursivelyDirty
!= null) {
102 myVDirs
.addAll(dirsRecursivelyDirty
);
107 public void callRealManager(final VcsDirtyScopeManager manager
) {
108 if (myEverythingDirty
) {
109 manager
.markEverythingDirty();
113 for (FilePath file
: myFiles
) {
114 manager
.fileDirty(file
);
116 for (VirtualFile file
: myVFiles
) {
117 manager
.fileDirty(file
);
119 for (FilePath dir
: myDirs
) {
120 manager
.dirDirtyRecursively(dir
);
122 for (VirtualFile dir
: myVDirs
) {
123 manager
.dirDirtyRecursively(dir
);