summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorRemy Suen2010-05-12 22:37:10 (EDT)
committer Remy Suen2010-05-12 22:37:10 (EDT)
commit6b6c3ca05a66811b4910267549d1a5b90bd7620a (patch)
tree377c81a6f6261619a80e3365da73e2e4d5448ee5
parente1b0a72f34ed00da4f66397edd4f044cef477a27 (diff)
downloadegit-6b6c3ca05a66811b4910267549d1a5b90bd7620a.zip
egit-6b6c3ca05a66811b4910267549d1a5b90bd7620a.tar.gz
egit-6b6c3ca05a66811b4910267549d1a5b90bd7620a.tar.bz2
Relax constructor parameters of EGit operationsrefs/changes/93/693/1
Certain EGit operations takes a Collection<IResource> as a parameter in its constructor. The problem with this type is that one cannot pass in a Collection<IFile> or a Collection<IFolder>. Instead, you are forced to alter your existing collection into one for IResources. The fix is to alter these constructors so that they take a Collection<? extends IResource> instead. Change-Id: I93acf875107596b7eb08d76aaf69f13ed0cab524
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/op/AddToIndexOperation.java13
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/op/AssumeUnchangedOperation.java11
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/op/UntrackOperation.java11
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/op/UpdateOperation.java4
4 files changed, 16 insertions, 23 deletions
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/AddToIndexOperation.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/AddToIndexOperation.java
index 95ab51f..5d956d9 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/AddToIndexOperation.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/AddToIndexOperation.java
@@ -18,7 +18,6 @@ import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
@@ -27,13 +26,13 @@ import org.eclipse.egit.core.Activator;
import org.eclipse.egit.core.CoreText;
import org.eclipse.egit.core.project.RepositoryMapping;
import org.eclipse.jgit.lib.GitIndex;
-import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.lib.GitIndex.Entry;
+import org.eclipse.jgit.lib.Repository;
/**
*/
public class AddToIndexOperation implements IEGitOperation {
- private final Collection<IResource> rsrcList;
+ private final Collection<? extends IResource> rsrcList;
private final Collection<IFile> notAddedFiles;
private final IdentityHashMap<RepositoryMapping, Object> mappings;
@@ -45,7 +44,7 @@ public class AddToIndexOperation implements IEGitOperation {
* collection of {@link IResource}s which should be added to the
* relevant Git repositories.
*/
- public AddToIndexOperation(final Collection<IResource> rsrcs) {
+ public AddToIndexOperation(final Collection<? extends IResource> rsrcs) {
rsrcList = rsrcs;
mappings = new IdentityHashMap<RepositoryMapping, Object>();
notAddedFiles = new ArrayList<IFile>();
@@ -64,11 +63,11 @@ public class AddToIndexOperation implements IEGitOperation {
// GitIndex can not be updated if it contains staged entries
Collection<GitIndex> indexesWithStagedEntries = new ArrayList<GitIndex>();
try {
- for (Object obj : rsrcList) {
- obj = ((IAdaptable) obj).getAdapter(IResource.class);
- if (obj instanceof IFile)
+ for (IResource obj : rsrcList) {
+ if (obj instanceof IFile) {
addToIndex((IFile) obj, changedIndexes,
indexesWithStagedEntries);
+ }
monitor.worked(200);
}
if (!changedIndexes.isEmpty()) {
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/AssumeUnchangedOperation.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/AssumeUnchangedOperation.java
index b494a8f..d543a16 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/AssumeUnchangedOperation.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/AssumeUnchangedOperation.java
@@ -19,7 +19,6 @@ import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
@@ -37,7 +36,7 @@ import org.eclipse.osgi.util.NLS;
* Tell JGit to ignore changes in selected files
*/
public class AssumeUnchangedOperation implements IEGitOperation {
- private final Collection<IResource> rsrcList;
+ private final Collection<? extends IResource> rsrcList;
private final IdentityHashMap<Repository, DirCache> caches;
@@ -50,7 +49,7 @@ public class AssumeUnchangedOperation implements IEGitOperation {
* collection of {@link IResource}s which should be ignored when
* looking for changes or committing.
*/
- public AssumeUnchangedOperation(final Collection<IResource> rsrcs) {
+ public AssumeUnchangedOperation(final Collection<? extends IResource> rsrcs) {
rsrcList = rsrcs;
caches = new IdentityHashMap<Repository, DirCache>();
mappings = new IdentityHashMap<RepositoryMapping, Object>();
@@ -69,10 +68,8 @@ public class AssumeUnchangedOperation implements IEGitOperation {
m.beginTask(CoreText.AssumeUnchangedOperation_adding,
rsrcList.size() * 200);
try {
- for (Object obj : rsrcList) {
- obj = ((IAdaptable) obj).getAdapter(IResource.class);
- if (obj instanceof IResource)
- assumeValid((IResource) obj);
+ for (IResource resource : rsrcList) {
+ assumeValid(resource);
m.worked(200);
}
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/UntrackOperation.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/UntrackOperation.java
index 2c26770..ba3c28c 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/UntrackOperation.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/UntrackOperation.java
@@ -19,7 +19,6 @@ import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
@@ -46,7 +45,7 @@ import org.eclipse.osgi.util.NLS;
* </p>
*/
public class UntrackOperation implements IEGitOperation {
- private final Collection<IResource> rsrcList;
+ private final Collection<? extends IResource> rsrcList;
private final IdentityHashMap<Repository, DirCacheEditor> edits;
@@ -59,7 +58,7 @@ public class UntrackOperation implements IEGitOperation {
* collection of {@link IResource}s which should be removed from
* the relevant Git repositories.
*/
- public UntrackOperation(final Collection<IResource> rsrcs) {
+ public UntrackOperation(final Collection<? extends IResource> rsrcs) {
rsrcList = rsrcs;
edits = new IdentityHashMap<Repository, DirCacheEditor>();
mappings = new IdentityHashMap<RepositoryMapping, Object>();
@@ -77,10 +76,8 @@ public class UntrackOperation implements IEGitOperation {
m.beginTask(CoreText.AddOperation_adding, rsrcList.size() * 200);
try {
- for (Object obj : rsrcList) {
- obj = ((IAdaptable) obj).getAdapter(IResource.class);
- if (obj instanceof IResource)
- remove((IResource) obj);
+ for (IResource obj : rsrcList) {
+ remove(obj);
m.worked(200);
}
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/UpdateOperation.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/UpdateOperation.java
index 8412e4f..1201750 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/UpdateOperation.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/UpdateOperation.java
@@ -45,7 +45,7 @@ import org.eclipse.osgi.util.NLS;
* </p>
*/
public class UpdateOperation implements IEGitOperation {
- private final Collection<IResource> rsrcList;
+ private final Collection<? extends IResource> rsrcList;
/**
* Create a new operation to update files/folders.
@@ -54,7 +54,7 @@ public class UpdateOperation implements IEGitOperation {
* collection of {@link IResource}s which should be added to the
* relevant Git repositories.
*/
- public UpdateOperation(final Collection<IResource> rsrcs) {
+ public UpdateOperation(final Collection<? extends IResource> rsrcs) {
rsrcList = rsrcs;
}