1 /*******************************************************************************
2 * Copyright (C) 2015, Obeo.
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *******************************************************************************/
9 package org
.eclipse
.egit
.core
.internal
.merge
;
13 import org
.eclipse
.core
.resources
.IResource
;
14 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
15 import org
.eclipse
.team
.core
.TeamException
;
16 import org
.eclipse
.team
.core
.variants
.IResourceVariant
;
17 import org
.eclipse
.team
.core
.variants
.IResourceVariantTree
;
20 * An immutable resource variant tree backed by a
21 * {@link GitResourceVariantCache}. This will never contact the server.
23 * This will not react to refreshing calls and shouldn't be used for
24 * synchronization purposes.
28 * Illegal implementation of IResourceVariantTree : we could also extend the
29 * AbstractResourceVariantTree... but since we don't react to refreshing calls
30 * anyway, we do not need the extra logic it provides.
32 class GitCachedResourceVariantTree
implements IResourceVariantTree
{
33 private final GitResourceVariantCache cache
;
35 public GitCachedResourceVariantTree(GitResourceVariantCache cache
) {
40 public IResource
[] roots() {
41 final Set
<IResource
> roots
= cache
.getRoots();
42 return roots
.toArray(new IResource
[roots
.size()]);
46 public IResource
[] members(IResource resource
) throws TeamException
{
47 return cache
.members(resource
);
51 public IResourceVariant
getResourceVariant(IResource resource
)
52 throws TeamException
{
53 return cache
.getVariant(resource
);
57 public boolean hasResourceVariant(IResource resource
) throws TeamException
{
58 return cache
.getVariant(resource
) != null;
62 public IResource
[] refresh(IResource
[] resources
, int depth
,
63 IProgressMonitor monitor
) throws TeamException
{
64 // This does not react to refresh calls
65 return new IResource
[0];
69 public void flushVariants(IResource resource
, int depth
)
70 throws TeamException
{
71 // Empty implementation