mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[log] simplify: move EMPTY DataPack instance to the DataPack
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.intellij.vcs.log.data;
|
||||
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.ConstantFunction;
|
||||
import com.intellij.util.NotNullFunction;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.vcs.log.*;
|
||||
@@ -12,15 +13,26 @@ import com.intellij.vcs.log.util.StopWatch;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
public class DataPack {
|
||||
|
||||
public static final DataPack EMPTY = createEmptyInstance();
|
||||
|
||||
@NotNull private final RefsModel myRefsModel;
|
||||
@NotNull private final PermanentGraph<Integer> myPermanentGraph;
|
||||
@NotNull private final Map<VirtualFile, VcsLogProvider> myLogProviders;
|
||||
private boolean myFull;
|
||||
|
||||
DataPack(@NotNull RefsModel refsModel,
|
||||
@NotNull PermanentGraph<Integer> permanentGraph,
|
||||
@NotNull Map<VirtualFile, VcsLogProvider> providers,
|
||||
boolean full) {
|
||||
myRefsModel = refsModel;
|
||||
myPermanentGraph = permanentGraph;
|
||||
myLogProviders = providers;
|
||||
myFull = full;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
static DataPack build(@NotNull List<? extends GraphCommit<Integer>> commits,
|
||||
@NotNull Map<VirtualFile, Set<VcsRef>> refs,
|
||||
@@ -69,14 +81,10 @@ public class DataPack {
|
||||
return map;
|
||||
}
|
||||
|
||||
DataPack(@NotNull RefsModel refsModel,
|
||||
@NotNull PermanentGraph<Integer> permanentGraph,
|
||||
@NotNull Map<VirtualFile, VcsLogProvider> providers,
|
||||
boolean full) {
|
||||
myRefsModel = refsModel;
|
||||
myPermanentGraph = permanentGraph;
|
||||
myLogProviders = providers;
|
||||
myFull = full;
|
||||
@NotNull
|
||||
private static DataPack createEmptyInstance() {
|
||||
RefsModel emptyModel = new RefsModel(Collections.<VirtualFile, Set<VcsRef>>emptyMap(), new ConstantFunction<Hash, Integer>(0));
|
||||
return new DataPack(emptyModel, EmptyPermanentGraph.getInstance(), Collections.<VirtualFile, VcsLogProvider>emptyMap(), false);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.vcs.log.data;
|
||||
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.ConstantFunction;
|
||||
import com.intellij.vcs.log.Hash;
|
||||
import com.intellij.vcs.log.VcsLogProvider;
|
||||
import com.intellij.vcs.log.VcsRef;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
public class EmptyDataPack {
|
||||
|
||||
@NotNull
|
||||
public static DataPack getInstance() {
|
||||
RefsModel emptyModel = new RefsModel(Collections.<VirtualFile, Set<VcsRef>>emptyMap(), new ConstantFunction<Hash, Integer>(0));
|
||||
return new DataPack(emptyModel, EmptyPermanentGraph.getInstance(), Collections.<VirtualFile, VcsLogProvider>emptyMap(), false);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -55,7 +55,7 @@ public class VcsLogRefresherImpl implements VcsLogRefresher {
|
||||
|
||||
@NotNull private final SingleTaskController<RefreshRequest, DataPack> mySingleTaskController;
|
||||
|
||||
@NotNull private DataPack myDataPack = EmptyDataPack.getInstance();
|
||||
@NotNull private DataPack myDataPack = DataPack.EMPTY;
|
||||
|
||||
public VcsLogRefresherImpl(@NotNull final Project project,
|
||||
@NotNull VcsLogHashMap hashMap,
|
||||
@@ -106,7 +106,7 @@ public class VcsLogRefresherImpl implements VcsLogRefresher {
|
||||
}
|
||||
catch (VcsException e) {
|
||||
myExceptionHandler.consume(e);
|
||||
return EmptyDataPack.getInstance();
|
||||
return DataPack.EMPTY;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,7 +214,7 @@ public class VcsLogRefresherImpl implements VcsLogRefresher {
|
||||
Collection<VirtualFile> rootsToRefresh = ContainerUtil.newArrayList();
|
||||
for (RefreshRequest request : requests) {
|
||||
if (request == RefreshRequest.RELOAD_ALL) {
|
||||
myCurrentDataPack = EmptyDataPack.getInstance();
|
||||
myCurrentDataPack = DataPack.EMPTY;
|
||||
return myProviders.keySet();
|
||||
}
|
||||
rootsToRefresh.addAll(request.rootsToRefresh);
|
||||
@@ -251,7 +251,7 @@ public class VcsLogRefresherImpl implements VcsLogRefresher {
|
||||
}
|
||||
catch (Exception e) {
|
||||
myExceptionHandler.consume(e);
|
||||
return EmptyDataPack.getInstance();
|
||||
return DataPack.EMPTY;
|
||||
}
|
||||
finally {
|
||||
sw.report();
|
||||
|
||||
@@ -26,7 +26,7 @@ import java.util.Map;
|
||||
|
||||
public class VisiblePack implements VcsLogDataPack {
|
||||
|
||||
public static final VisiblePack EMPTY = new VisiblePack(EmptyDataPack.getInstance(), EmptyVisibleGraph.getInstance(), false);
|
||||
public static final VisiblePack EMPTY = new VisiblePack(DataPack.EMPTY, EmptyVisibleGraph.getInstance(), false);
|
||||
|
||||
@NotNull private final DataPack myDataPack;
|
||||
@NotNull private final VisibleGraph<Integer> myVisibleGraph;
|
||||
|
||||
Reference in New Issue
Block a user