Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergey Prigogin2016-10-14 15:29:09 -0400
committerSergey Prigogin2016-10-14 16:55:57 -0400
commitb5c052a00231a41f5cf4161f556d2cf99cb740cf (patch)
tree59f08535db0e0498b1f830d286f266682dcf6ef0
parent3712ffe070c523ab17649977fcf8787f57132c57 (diff)
downloadeclipse.platform.team-b5c052a00231a41f5cf4161f556d2cf99cb740cf.tar.gz
eclipse.platform.team-b5c052a00231a41f5cf4161f556d2cf99cb740cf.tar.xz
eclipse.platform.team-b5c052a00231a41f5cf4161f556d2cf99cb740cf.zip
Code cleanup.
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/Policy.java1
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/Utilities.java33
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/HunkTypedElement.java27
3 files changed, 22 insertions, 39 deletions
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/Policy.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/Policy.java
index d51bff8b5..5f4058035 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/Policy.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/Policy.java
@@ -22,6 +22,7 @@ public class Policy {
public static boolean debugContentMergeViewer = false;
static final DebugOptionsListener DEBUG_OPTIONS_LISTENER = new DebugOptionsListener() {
+ @Override
public void optionsChanged(DebugOptions options) {
boolean DEBUG = options.getBooleanOption(CompareUIPlugin.PLUGIN_ID + "/debug", false); //$NON-NLS-1$
debugContentMergeViewer = DEBUG && options.getBooleanOption(CompareUIPlugin.PLUGIN_ID + "/content_merge_viewer", false); //$NON-NLS-1$
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/Utilities.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/Utilities.java
index 73a8e9bc7..6c9e7d665 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/Utilities.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/Utilities.java
@@ -765,17 +765,11 @@ public class Utilities {
public static boolean isHunk(Object input) {
if (input != null && input instanceof DiffNode){
ITypedElement right = ((DiffNode) input).getRight();
- if (right != null) {
- Object element = Adapters.adapt(right, IHunk.class);
- if (element instanceof IHunk)
- return true;
- }
+ if (Adapters.adapt(right, IHunk.class) != null)
+ return true;
ITypedElement left = ((DiffNode) input).getLeft();
- if (left != null) {
- Object element = Adapters.adapt(left, IHunk.class);
- if (element instanceof IHunk)
- return true;
- }
+ if (Adapters.adapt(left, IHunk.class) != null)
+ return true;
}
return false;
}
@@ -783,18 +777,14 @@ public class Utilities {
public static boolean isHunkOk(Object input) {
if (input != null && input instanceof DiffNode){
ITypedElement right = ((DiffNode) input).getRight();
- if (right != null) {
- Object element = Adapters.adapt(right, HunkResult.class);
- if (element instanceof HunkResult) {
- return ((HunkResult)element).isOK();
- }
+ HunkResult element = Adapters.adapt(right, HunkResult.class);
+ if (element != null) {
+ return element.isOK();
}
ITypedElement left = ((DiffNode) input).getLeft();
- if (left != null) {
- Object element = Adapters.adapt(left, HunkResult.class);
- if (element instanceof HunkResult)
- return ((HunkResult)element).isOK();
- }
+ element = Adapters.adapt(left, HunkResult.class);
+ if (element != null)
+ return element.isOK();
}
return false;
}
@@ -862,8 +852,7 @@ public class Utilities {
final String[] result = new String[1];
context.run(true, true, new IRunnableWithProgress() {
@Override
- public void run(IProgressMonitor monitor)
- throws InvocationTargetException, InterruptedException {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
SubMonitor progress = SubMonitor.convert(monitor,
PatchMessages.InputPatchPage_URLConnecting, 100);
try {
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/HunkTypedElement.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/HunkTypedElement.java
index 9f2091ee4..07b35c4e1 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/HunkTypedElement.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/HunkTypedElement.java
@@ -28,7 +28,6 @@ import org.eclipse.jface.resource.LocalResourceManager;
import org.eclipse.swt.graphics.Image;
public class HunkTypedElement implements ITypedElement, IEncodedStreamContentAccessor, IAdaptable {
-
private final HunkResult fHunkResult;
private final boolean fIsAfterState;
private final boolean fFullContext;
@@ -39,9 +38,7 @@ public class HunkTypedElement implements ITypedElement, IEncodedStreamContentAcc
this.fFullContext = fullContext;
}
- /* (non-Javadoc)
- * @see org.eclipse.compare.ITypedElement#getImage()
- */
+ @Override
public Image getImage() {
LocalResourceManager imageCache = PatchCompareEditorInput.getImageCache(fHunkResult.getDiffResult().getConfiguration());
ImageDescriptor imageDesc = CompareUIPlugin.getImageDescriptor(ICompareUIConstants.HUNK_OBJ);
@@ -72,28 +69,23 @@ public class HunkTypedElement implements ITypedElement, IEncodedStreamContentAcc
return Patcher.getPatcher(fHunkResult.getDiffResult().getConfiguration());
}
- /* (non-Javadoc)
- * @see org.eclipse.compare.ITypedElement#getName()
- */
+ @Override
public String getName() {
return fHunkResult.getHunk().getLabel();
}
- /* (non-Javadoc)
- * @see org.eclipse.compare.ITypedElement#getType()
- */
+ @Override
public String getType() {
return fHunkResult.getDiffResult().getDiff().getTargetPath(fHunkResult.getDiffResult().getConfiguration()).getFileExtension();
}
- /* (non-Javadoc)
- * @see org.eclipse.compare.IStreamContentAccessor#getContents()
- */
+ @Override
public InputStream getContents() throws CoreException {
String contents = fHunkResult.getContents(fIsAfterState, fFullContext);
return FileDiffResult.asInputStream(contents, fHunkResult.getCharset());
}
+ @Override
public String getCharset() throws CoreException {
return fHunkResult.getCharset();
}
@@ -102,12 +94,13 @@ public class HunkTypedElement implements ITypedElement, IEncodedStreamContentAcc
return fHunkResult;
}
- public Object getAdapter(Class adapter) {
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T> T getAdapter(Class<T> adapter) {
if (adapter == IHunk.class)
- return fHunkResult.getHunk();
+ return (T) fHunkResult.getHunk();
if (adapter == HunkResult.class)
- return fHunkResult;
+ return (T) fHunkResult;
return Platform.getAdapterManager().getAdapter(this, adapter);
}
-
}

Back to the top