Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Sohn2019-06-11 09:10:40 -0400
committerMatthias Sohn2019-06-11 09:34:51 -0400
commita62e0b6023d470afc579e014868cc49c3bdd20fb (patch)
tree617f12f941ee77d800de92a3175d956b6bfbe0cf
parent442cd079656ec49a921d76b9b7cccb985901ed78 (diff)
downloadegit-a62e0b6023d470afc579e014868cc49c3bdd20fb.tar.gz
egit-a62e0b6023d470afc579e014868cc49c3bdd20fb.tar.xz
egit-a62e0b6023d470afc579e014868cc49c3bdd20fb.zip
Cleanup removal of adapter workaround
- remove unnecessary casts - remove unnecessary type checks since they are already done by Adapters.adapt() Change-Id: I7ce38e96a9ce21977958f27b12810732fddf24c5 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/internal/storage/GitFileHistory.java42
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/operations/GitScopeUtil.java12
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/GitProjectPropertyPage.java12
3 files changed, 29 insertions, 37 deletions
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/storage/GitFileHistory.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/storage/GitFileHistory.java
index 0cf29b4b1..842a2f3ca 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/storage/GitFileHistory.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/storage/GitFileHistory.java
@@ -211,35 +211,35 @@ class GitFileHistory extends FileHistory implements IAdaptable {
}
private String getGitPath(IFileRevision revision) {
- if (revision instanceof CommitFileRevision)
+ if (revision instanceof CommitFileRevision) {
return ((CommitFileRevision) revision).getGitPath();
- else if (revision instanceof IAdaptable) {
- IResourceVariant variant = Adapters.adapt(((IAdaptable) revision),
- IResourceVariant.class);
-
- if (variant instanceof GitRemoteResource)
- return ((GitRemoteResource) variant).getPath();
}
+ IResourceVariant variant = Adapters.adapt(revision,
+ IResourceVariant.class);
+ if (variant instanceof GitRemoteResource) {
+ return ((GitRemoteResource) variant).getPath();
+ }
return null;
}
private RevCommit getRevCommit(IFileRevision revision) {
- if (revision instanceof CommitFileRevision)
+ if (revision instanceof CommitFileRevision) {
return ((CommitFileRevision) revision).getRevCommit();
- else if (revision instanceof IAdaptable) {
- IResourceVariant variant = Adapters.adapt(((IAdaptable) revision),
- IResourceVariant.class);
- if (variant instanceof GitRemoteResource) {
- final RevCommit commit = ((GitRemoteResource) variant)
- .getCommitId();
- try {
- return walk.parseCommit(commit);
- } catch (IOException e) {
- Activator.logError(NLS.bind(
- CoreText.GitFileHistory_invalidCommit,
- commit.getName(), resource.getName()), e);
- }
+ }
+ IResourceVariant variant = Adapters.adapt(revision,
+ IResourceVariant.class);
+ if (variant instanceof GitRemoteResource) {
+ final RevCommit commit = ((GitRemoteResource) variant)
+ .getCommitId();
+ try {
+ return walk.parseCommit(commit);
+ } catch (IOException e) {
+ Activator
+ .logError(
+ NLS.bind(CoreText.GitFileHistory_invalidCommit,
+ commit.getName(), resource.getName()),
+ e);
}
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/operations/GitScopeUtil.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/operations/GitScopeUtil.java
index 02034d581..d72302598 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/operations/GitScopeUtil.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/operations/GitScopeUtil.java
@@ -114,13 +114,11 @@ public class GitScopeUtil {
if (mapping != null) {
return mapping;
}
- if (o instanceof IAdaptable) {
- IContributorResourceAdapter adapted = Adapters.adapt(o,
- IContributorResourceAdapter.class);
- if (adapted instanceof IContributorResourceAdapter2) {
- IContributorResourceAdapter2 cra = (IContributorResourceAdapter2) adapted;
- return cra.getAdaptedResourceMapping((IAdaptable) o);
- }
+ IContributorResourceAdapter adapted = Adapters.adapt(o,
+ IContributorResourceAdapter.class);
+ if (adapted instanceof IContributorResourceAdapter2) {
+ IContributorResourceAdapter2 cra = (IContributorResourceAdapter2) adapted;
+ return cra.getAdaptedResourceMapping((IAdaptable) o);
}
return null;
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/GitProjectPropertyPage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/GitProjectPropertyPage.java
index 0a08cc512..2ca03deb8 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/GitProjectPropertyPage.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/GitProjectPropertyPage.java
@@ -18,7 +18,6 @@ import java.io.IOException;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.Adapters;
-import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.egit.core.project.RepositoryMapping;
import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.UIUtils;
@@ -83,14 +82,9 @@ public class GitProjectPropertyPage extends PropertyPage {
// Get the project that is the source of this property page
IProject project = null;
- final IAdaptable element = getElement();
- if (element instanceof IResource) {
- project = ((IResource) element).getProject();
- } else {
- IResource adapter = Adapters.adapt(element, IResource.class);
- if (adapter != null) {
- project = adapter.getProject();
- }
+ IResource resource = Adapters.adapt(getElement(), IResource.class);
+ if (resource != null) {
+ project = resource.getProject();
}
RepositoryMapping mapping = RepositoryMapping.getMapping(project);

Back to the top