+++ /dev/null
-/*
- * Copyright 2000-2009 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.openapi.vcs;
-
-import com.intellij.openapi.project.Project;
-
-public abstract class ThreadLocalDefendedInvoker<T> {
- protected final static ThreadLocal<Boolean> myThreadLocal = new ThreadLocal<Boolean>() {
- @Override
- protected Boolean initialValue() {
- return Boolean.TRUE;
- }
- };
-
- protected abstract T execute(Project project);
-
- public static boolean isInside() {
- return ! Boolean.TRUE.equals(myThreadLocal.get());
- }
-
- public static boolean isOutside() {
- return ! isInside();
- }
-
- public T executeDefended(Project project) {
- try {
- myThreadLocal.set(Boolean.FALSE);
- return execute(project);
- } finally {
- myThreadLocal.set(Boolean.TRUE);
- }
- }
-}
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vcs.ProjectLevelVcsManager;
-import com.intellij.openapi.vcs.ThreadLocalDefendedInvoker;
import com.intellij.openapi.vcs.impl.ProjectLevelVcsManagerImpl;
import com.intellij.openapi.vcs.impl.VcsInitObject;
import com.intellij.openapi.vfs.LocalFileSystem;
// grouped; if there are several mappings one under another, will return the upmost
private final SvnMapping myMoreRealMapping;
private final List<RootUrlInfo> myErrorRoots;
- private final MyRootsHelper myHelper;
+ @NotNull private final MyRootsHelper myRootsHelper;
private final Project myProject;
private final NestedCopiesHolder myNestedCopiesHolder;
private boolean myInitialized;
private boolean myInitedReloaded;
- private static class MyRootsHelper extends ThreadLocalDefendedInvoker<VirtualFile[]> {
- private final ProjectLevelVcsManager myPlVcsManager;
+ private static class MyRootsHelper {
+ @NotNull private final static ThreadLocal<Boolean> ourInProgress = ThreadLocal.withInitial(() -> Boolean.FALSE);
+ @NotNull private final Project myProject;
+ @NotNull private final ProjectLevelVcsManager myVcsManager;
- private MyRootsHelper(final ProjectLevelVcsManager vcsManager) {
- myPlVcsManager = vcsManager;
+ private MyRootsHelper(@NotNull Project project, @NotNull ProjectLevelVcsManager vcsManager) {
+ myProject = project;
+ myVcsManager = vcsManager;
}
- protected VirtualFile[] execute(Project project) {
- return myPlVcsManager.getRootsUnderVcs(SvnVcs.getInstance(project));
+ @NotNull
+ public VirtualFile[] execute() {
+ try {
+ ourInProgress.set(Boolean.TRUE);
+ return myVcsManager.getRootsUnderVcs(SvnVcs.getInstance(myProject));
+ }
+ finally {
+ ourInProgress.set(Boolean.FALSE);
+ }
+ }
+
+ public static boolean isInProgress() {
+ return ourInProgress.get();
}
}
myMapping = new SvnMapping();
myMoreRealMapping = new SvnMapping();
myErrorRoots = ContainerUtil.newArrayList();
- myHelper = new MyRootsHelper(vcsManager);
+ myRootsHelper = new MyRootsHelper(project, vcsManager);
myChecker = new SvnCompatibilityChecker(project);
myNestedCopiesHolder = new NestedCopiesHolder();
}
@NotNull
public List<VirtualFile> convertRoots(@NotNull List<VirtualFile> result) {
- if (ThreadLocalDefendedInvoker.isInside()) return ContainerUtil.newArrayList(result);
+ if (MyRootsHelper.isInProgress()) return ContainerUtil.newArrayList(result);
synchronized (myMonitor) {
final List<VirtualFile> cachedRoots = myMoreRealMapping.getUnderVcsRoots();
}
else {
final SvnVcs vcs = SvnVcs.getInstance(myProject);
- final VirtualFile[] roots = myHelper.executeDefended(myProject);
+ final VirtualFile[] roots = myRootsHelper.execute();
final SvnRootsDetector rootsDetector = new SvnRootsDetector(vcs, this, myNestedCopiesHolder);
// do not send additional request for nested copies when in init state
rootsDetector.detectCopyRoots(roots, init(), afterRefreshCallback);
}
}
+ @NotNull
public VirtualFile[] getNotFilteredRoots() {
- return myHelper.executeDefended(myProject);
+ return myRootsHelper.execute();
}
public boolean isEmpty() {