Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kurtakov2017-07-25 16:06:05 +0000
committerAlexander Kurtakov2017-07-25 16:06:05 +0000
commita5e1a790fce0ff0a0f9f166694b1e56324b185f4 (patch)
tree48b728800254c949c579df27f3f090bb1c24e8ad /bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants
parent3734ce46345e063654bf3bdc0ff6a3096bc0d501 (diff)
downloadeclipse.platform.team-I20170728-2000.tar.gz
eclipse.platform.team-I20170728-2000.tar.xz
eclipse.platform.team-I20170728-2000.zip
Take 2: * Generify. * Replace non-javadoc with @Override * Convert to lambdas Change-Id: Ia44170d3e752ad6513f007964463692e1cc6288e Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
Diffstat (limited to 'bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants')
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/AbstractResourceVariantTree.java37
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/PersistantResourceVariantByteStore.java31
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ResourceVariantTree.java30
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ResourceVariantTreeSubscriber.java33
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ThreeWayResourceComparator.java14
5 files changed, 54 insertions, 91 deletions
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/AbstractResourceVariantTree.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/AbstractResourceVariantTree.java
index c78c3e953..3888a19b0 100644
--- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/AbstractResourceVariantTree.java
+++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/AbstractResourceVariantTree.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -46,8 +46,9 @@ public abstract class AbstractResourceVariantTree implements IResourceVariantTre
* @return the array of resources whose corresponding variants have changed
* @throws TeamException
*/
+ @Override
public IResource[] refresh(IResource[] resources, int depth, IProgressMonitor monitor) throws TeamException {
- List changedResources = new ArrayList();
+ List<IResource> changedResources = new ArrayList<>();
monitor.beginTask(null, 100 * resources.length);
for (int i = 0; i < resources.length; i++) {
IResource resource = resources[i];
@@ -55,7 +56,7 @@ public abstract class AbstractResourceVariantTree implements IResourceVariantTre
changedResources.addAll(Arrays.asList(changed));
}
monitor.done();
- return (IResource[]) changedResources.toArray(new IResource[changedResources.size()]);
+ return changedResources.toArray(new IResource[changedResources.size()]);
}
/**
@@ -109,9 +110,9 @@ public abstract class AbstractResourceVariantTree implements IResourceVariantTre
* @throws TeamException
*/
protected IResource[] collectChanges(IResource local, IResourceVariant remote, int depth, IProgressMonitor monitor) throws TeamException {
- List changedResources = new ArrayList();
+ List<IResource> changedResources = new ArrayList<>();
collectChanges(local, remote, changedResources, depth, monitor);
- return (IResource[]) changedResources.toArray(new IResource[changedResources.size()]);
+ return changedResources.toArray(new IResource[changedResources.size()]);
}
/**
@@ -164,30 +165,30 @@ public abstract class AbstractResourceVariantTree implements IResourceVariantTre
*/
protected abstract boolean setVariant(IResource local, IResourceVariant remote) throws TeamException;
- private void collectChanges(IResource local, IResourceVariant remote, Collection changedResources, int depth, IProgressMonitor monitor) throws TeamException {
+ private void collectChanges(IResource local, IResourceVariant remote, Collection<IResource> changedResources, int depth, IProgressMonitor monitor) throws TeamException {
boolean changed = setVariant(local, remote);
if (changed) {
changedResources.add(local);
}
if (depth == IResource.DEPTH_ZERO) return;
- Map children = mergedMembers(local, remote, monitor);
- for (Iterator it = children.keySet().iterator(); it.hasNext();) {
- IResource localChild = (IResource) it.next();
- IResourceVariant remoteChild = (IResourceVariant)children.get(localChild);
+ Map<IResource, IResourceVariant> children = mergedMembers(local, remote, monitor);
+ for (Iterator<IResource> it = children.keySet().iterator(); it.hasNext();) {
+ IResource localChild = it.next();
+ IResourceVariant remoteChild = children.get(localChild);
collectChanges(localChild, remoteChild, changedResources,
depth == IResource.DEPTH_INFINITE ? IResource.DEPTH_INFINITE : IResource.DEPTH_ZERO,
monitor);
}
- IResource[] cleared = collectedMembers(local, (IResource[]) children.keySet().toArray(new IResource[children.keySet().size()]));
+ IResource[] cleared = collectedMembers(local, children.keySet().toArray(new IResource[children.keySet().size()]));
changedResources.addAll(Arrays.asList(cleared));
monitor.worked(1);
}
- private Map mergedMembers(IResource local, IResourceVariant remote, IProgressMonitor progress) throws TeamException {
+ private Map<IResource, IResourceVariant> mergedMembers(IResource local, IResourceVariant remote, IProgressMonitor progress) throws TeamException {
// {IResource -> IResourceVariant}
- Map mergedResources = new HashMap();
+ Map<IResource, IResourceVariant> mergedResources = new HashMap<>();
IResourceVariant[] remoteChildren;
if (remote == null) {
@@ -200,12 +201,12 @@ public abstract class AbstractResourceVariantTree implements IResourceVariantTre
IResource[] localChildren = members(local);
if (remoteChildren.length > 0 || localChildren.length > 0) {
- Set allSet = new HashSet(20);
- Map localSet = null;
- Map remoteSet = null;
+ Set<String> allSet = new HashSet<>(20);
+ Map<String, IResource> localSet = null;
+ Map<String, IResourceVariant> remoteSet = null;
if (localChildren.length > 0) {
- localSet = new HashMap(10);
+ localSet = new HashMap<>(10);
for (int i = 0; i < localChildren.length; i++) {
IResource localChild = localChildren[i];
String name = localChild.getName();
@@ -215,7 +216,7 @@ public abstract class AbstractResourceVariantTree implements IResourceVariantTre
}
if (remoteChildren.length > 0) {
- remoteSet = new HashMap(10);
+ remoteSet = new HashMap<>(10);
for (int i = 0; i < remoteChildren.length; i++) {
IResourceVariant remoteChild = remoteChildren[i];
String name = remoteChild.getName();
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/PersistantResourceVariantByteStore.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/PersistantResourceVariantByteStore.java
index 9f38007aa..90ac851b9 100644
--- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/PersistantResourceVariantByteStore.java
+++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/PersistantResourceVariantByteStore.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -43,9 +43,7 @@ public class PersistantResourceVariantByteStore extends ResourceVariantByteStore
getSynchronizer().add(syncName);
}
- /* (non-Javadoc)
- * @see org.eclipse.team.core.variants.ResourceVariantByteStore#dispose()
- */
+ @Override
public void dispose() {
getSynchronizer().remove(getSyncName());
}
@@ -58,9 +56,7 @@ public class PersistantResourceVariantByteStore extends ResourceVariantByteStore
return syncName;
}
- /* (non-Javadoc)
- * @see org.eclipse.team.core.variants.ResourceVariantByteStore#getBytes(org.eclipse.core.resources.IResource)
- */
+ @Override
public byte[] getBytes(IResource resource) throws TeamException {
byte[] syncBytes = internalGetSyncBytes(resource);
if (syncBytes != null && equals(syncBytes, NO_REMOTE)) {
@@ -70,9 +66,7 @@ public class PersistantResourceVariantByteStore extends ResourceVariantByteStore
return syncBytes;
}
- /* (non-Javadoc)
- * @see org.eclipse.team.core.variants.ResourceVariantByteStore#setBytes(org.eclipse.core.resources.IResource, byte[])
- */
+ @Override
public boolean setBytes(IResource resource, byte[] bytes) throws TeamException {
Assert.isNotNull(bytes);
byte[] oldBytes = internalGetSyncBytes(resource);
@@ -85,9 +79,7 @@ public class PersistantResourceVariantByteStore extends ResourceVariantByteStore
}
}
- /* (non-Javadoc)
- * @see org.eclipse.team.core.variants.ResourceVariantByteStore#flushBytes(org.eclipse.core.resources.IResource, int)
- */
+ @Override
public boolean flushBytes(IResource resource, int depth) throws TeamException {
if (resource.exists() || resource.isPhantom()) {
try {
@@ -122,13 +114,12 @@ public class PersistantResourceVariantByteStore extends ResourceVariantByteStore
* <code>getBytes(resource)</code> will return <code>null</code>.
* @return <code>true</code> if this changes the remote sync bytes
*/
+ @Override
public boolean deleteBytes(IResource resource) throws TeamException {
return setBytes(resource, NO_REMOTE);
}
- /* (non-Javadoc)
- * @see org.eclipse.team.core.variants.ResourceVariantByteStore#members(org.eclipse.core.resources.IResource)
- */
+ @Override
public IResource[] members(IResource resource) throws TeamException {
if(resource.getType() == IResource.FILE) {
return new IResource[0];
@@ -136,14 +127,14 @@ public class PersistantResourceVariantByteStore extends ResourceVariantByteStore
try {
// Filter and return only resources that have sync bytes in the cache.
IResource[] members = ((IContainer)resource).members(true /* include phantoms */);
- List filteredMembers = new ArrayList(members.length);
+ List<IResource> filteredMembers = new ArrayList<>(members.length);
for (int i = 0; i < members.length; i++) {
IResource member = members[i];
if(getBytes(member) != null) {
filteredMembers.add(member);
}
}
- return (IResource[]) filteredMembers.toArray(new IResource[filteredMembers.size()]);
+ return filteredMembers.toArray(new IResource[filteredMembers.size()]);
} catch (CoreException e) {
throw TeamException.asTeamException(e);
}
@@ -161,9 +152,7 @@ public class PersistantResourceVariantByteStore extends ResourceVariantByteStore
}
}
- /* (non-Javadoc)
- * @see org.eclipse.team.core.variants.ResourceVariantByteStore#run(org.eclipse.core.resources.IWorkspaceRunnable, org.eclipse.core.runtime.IProgressMonitor)
- */
+ @Override
public void run(IResource root, IWorkspaceRunnable runnable, IProgressMonitor monitor)
throws TeamException {
try {
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ResourceVariantTree.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ResourceVariantTree.java
index 12cf6faeb..e3b5c9f85 100644
--- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ResourceVariantTree.java
+++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ResourceVariantTree.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -11,8 +11,6 @@
package org.eclipse.team.core.variants;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspaceRunnable;
-import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.team.core.TeamException;
@@ -38,30 +36,22 @@ public abstract class ResourceVariantTree extends AbstractResourceVariantTree {
this.store = store;
}
- /* (non-Javadoc)
- * @see org.eclipse.team.core.variants.IResourceVariantTree#members(org.eclipse.core.resources.IResource)
- */
+ @Override
public IResource[] members(IResource resource) throws TeamException {
return getByteStore().members(resource);
}
- /* (non-Javadoc)
- * @see org.eclipse.team.core.variants.IResourceVariantTree#hasResourceVariant(org.eclipse.core.resources.IResource)
- */
+ @Override
public boolean hasResourceVariant(IResource resource) throws TeamException {
return getByteStore().getBytes(resource) != null;
}
- /* (non-Javadoc)
- * @see org.eclipse.team.core.variants.IResourceVariantTree#flushVariants(org.eclipse.core.resources.IResource, int)
- */
+ @Override
public void flushVariants(IResource resource, int depth) throws TeamException {
getByteStore().flushBytes(resource, depth);
}
- /* (non-Javadoc)
- * @see org.eclipse.team.core.variants.AbstractResourceVariantTree#setVariant(org.eclipse.core.resources.IResource, org.eclipse.team.core.variants.IResourceVariant)
- */
+ @Override
protected boolean setVariant(IResource local, IResourceVariant remote) throws TeamException {
ResourceVariantByteStore cache = getByteStore();
byte[] newRemoteBytes = getBytes(local, remote);
@@ -100,18 +90,12 @@ public abstract class ResourceVariantTree extends AbstractResourceVariantTree {
return remote.asBytes();
}
- /* (non-Javadoc)
- * @see org.eclipse.team.core.variants.AbstractResourceVariantTree#collectChanges(org.eclipse.core.resources.IResource, org.eclipse.team.core.variants.IResourceVariant, int, org.eclipse.core.runtime.IProgressMonitor)
- */
+ @Override
protected IResource[] collectChanges(final IResource local,
final IResourceVariant remote, final int depth, IProgressMonitor monitor)
throws TeamException {
final IResource[][] resources = new IResource[][] { null };
- getByteStore().run(local, new IWorkspaceRunnable() {
- public void run(IProgressMonitor monitor) throws CoreException {
- resources[0] = ResourceVariantTree.super.collectChanges(local, remote, depth, monitor);
- }
- }, monitor);
+ getByteStore().run(local, monitor1 -> resources[0] = ResourceVariantTree.super.collectChanges(local, remote, depth, monitor1), monitor);
return resources[0];
}
}
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ResourceVariantTreeSubscriber.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ResourceVariantTreeSubscriber.java
index 7c7c64e35..b58ccaeac 100644
--- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ResourceVariantTreeSubscriber.java
+++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ResourceVariantTreeSubscriber.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -31,9 +31,7 @@ import org.eclipse.team.internal.core.*;
*/
public abstract class ResourceVariantTreeSubscriber extends Subscriber {
- /* (non-Javadoc)
- * @see org.eclipse.team.core.subscribers.Subscriber#getSyncInfo(org.eclipse.core.resources.IResource)
- */
+ @Override
public SyncInfo getSyncInfo(IResource resource) throws TeamException {
if (!isSupervised(resource)) return null;
IResourceVariant remoteResource = getRemoteTree().getResourceVariant(resource);
@@ -61,15 +59,13 @@ public abstract class ResourceVariantTreeSubscriber extends Subscriber {
return info;
}
- /* (non-Javadoc)
- * @see org.eclipse.team.core.subscribers.Subscriber#members(org.eclipse.core.resources.IResource)
- */
+ @Override
public IResource[] members(IResource resource) throws TeamException {
if(resource.getType() == IResource.FILE) {
return new IResource[0];
}
try {
- Set allMembers = new HashSet();
+ Set<IResource> allMembers = new HashSet<>();
try {
allMembers.addAll(Arrays.asList(((IContainer)resource).members()));
} catch (CoreException e) {
@@ -93,19 +89,17 @@ public abstract class ResourceVariantTreeSubscriber extends Subscriber {
iterator.remove();
}
}
- return (IResource[]) allMembers.toArray(new IResource[allMembers.size()]);
+ return allMembers.toArray(new IResource[allMembers.size()]);
} catch (CoreException e) {
throw TeamException.asTeamException(e);
}
}
- /* (non-Javadoc)
- * @see org.eclipse.team.core.subscribers.Subscriber#refresh(org.eclipse.core.resources.IResource[], int, org.eclipse.core.runtime.IProgressMonitor)
- */
+ @Override
public void refresh(IResource[] resources, int depth, IProgressMonitor monitor) throws TeamException {
monitor = Policy.monitorFor(monitor);
- List errors = new ArrayList();
- List cancels = new ArrayList();
+ List<IStatus> errors = new ArrayList<>();
+ List<IStatus> cancels = new ArrayList<>();
try {
monitor.beginTask(null, 1000 * resources.length);
for (int i = 0; i < resources.length; i++) {
@@ -127,7 +121,7 @@ public abstract class ResourceVariantTreeSubscriber extends Subscriber {
if (!cancels.isEmpty()) {
errors.addAll(cancels);
throw new TeamException(new MultiStatus(TeamPlugin.ID, 0,
- (IStatus[]) errors.toArray(new IStatus[errors.size()]),
+ errors.toArray(new IStatus[errors.size()]),
NLS.bind(
Messages.ResourceVariantTreeSubscriber_3,
(new Object[] { getName(),
@@ -135,6 +129,7 @@ public abstract class ResourceVariantTreeSubscriber extends Subscriber {
Integer.toString(resources.length),
Integer.toString(cancels.size()) })),
null) {
+ @Override
public int getSeverity() {
// we want to display status as an error
return IStatus.ERROR;
@@ -142,12 +137,12 @@ public abstract class ResourceVariantTreeSubscriber extends Subscriber {
});
}
throw new TeamException(new MultiStatus(TeamPlugin.ID, 0,
- (IStatus[]) errors.toArray(new IStatus[errors.size()]),
+ errors.toArray(new IStatus[errors.size()]),
NLS.bind(Messages.ResourceVariantTreeSubscriber_1, (new Object[] {getName(), Integer.toString(numSuccess), Integer.toString(resources.length)})), null));
}
if (!cancels.isEmpty()) {
throw new OperationCanceledException(
- ((IStatus) cancels.get(0)).getMessage());
+ cancels.get(0).getMessage());
}
}
@@ -165,14 +160,14 @@ public abstract class ResourceVariantTreeSubscriber extends Subscriber {
monitor = Policy.monitorFor(monitor);
try {
monitor.beginTask(null, 100);
- Set allChanges = new HashSet();
+ Set<IResource> allChanges = new HashSet<>();
if (getResourceComparator().isThreeWay()) {
IResource[] baseChanges = getBaseTree().refresh(new IResource[] {resource}, depth, Policy.subMonitorFor(monitor, 25));
allChanges.addAll(Arrays.asList(baseChanges));
}
IResource[] remoteChanges = getRemoteTree().refresh(new IResource[] {resource}, depth, Policy.subMonitorFor(monitor, 75));
allChanges.addAll(Arrays.asList(remoteChanges));
- IResource[] changedResources = (IResource[]) allChanges.toArray(new IResource[allChanges.size()]);
+ IResource[] changedResources = allChanges.toArray(new IResource[allChanges.size()]);
fireTeamResourceChange(SubscriberChangeEvent.asSyncChangedDeltas(this, changedResources));
return Status.OK_STATUS;
} catch (TeamException e) {
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ThreeWayResourceComparator.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ThreeWayResourceComparator.java
index 0382fcfea..db7c714cf 100644
--- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ThreeWayResourceComparator.java
+++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ThreeWayResourceComparator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -36,9 +36,7 @@ public class ThreeWayResourceComparator implements IResourceVariantComparator {
this.synchronizer = synchronizer;
}
- /* (non-Javadoc)
- * @see org.eclipse.team.core.variants.IResourceVariantComparator#compare(org.eclipse.core.resources.IResource, org.eclipse.team.core.variants.IResourceVariant)
- */
+ @Override
public boolean compare(IResource local, IResourceVariant remote) {
// First, ensure the resources are the same gender
if ((local.getType() == IResource.FILE) == remote.isContainer()) {
@@ -59,18 +57,14 @@ public class ThreeWayResourceComparator implements IResourceVariantComparator {
}
}
- /* (non-Javadoc)
- * @see org.eclipse.team.core.variants.IResourceVariantComparator#compare(org.eclipse.team.core.variants.IResourceVariant, org.eclipse.team.core.variants.IResourceVariant)
- */
+ @Override
public boolean compare(IResourceVariant base, IResourceVariant remote) {
byte[] bytes1 = getBytes(base);
byte[] bytes2 = getBytes(remote);
return equals(bytes1, bytes2);
}
- /* (non-Javadoc)
- * @see org.eclipse.team.core.variants.IResourceVariantComparator#isThreeWay()
- */
+ @Override
public boolean isThreeWay() {
return true;
}

Back to the top