Use Multi-catch in org.eclipse.compare
Change-Id: I1c113ee473ad351959bf74e1340085ac2f1fa007
Signed-off-by: Lars Vogel <Lars.Vogel@vogella.com>
Also-by: Karsten Thoms <karsten.thoms@itemis.de>
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareEditorInput.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareEditorInput.java
index d8c155a..0d5ff3f 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareEditorInput.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareEditorInput.java
@@ -1467,9 +1467,7 @@
}
});
return true;
- } catch (InterruptedException x) {
- // Ignore
- } catch (OperationCanceledException x) {
+ } catch (InterruptedException | OperationCanceledException x) {
// Ignore
} catch (InvocationTargetException x) {
ErrorDialog.openError(fComposite.getShell(), CompareMessages.CompareDialog_error_title, null,
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditor.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditor.java
index 735ce13..7da9a8e 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditor.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditor.java
@@ -521,9 +521,7 @@
try {
operation.run(progressMonitor);
firePropertyChange(PROP_DIRTY);
- } catch (InterruptedException x) {
- // NeedWork
- } catch (OperationCanceledException x) {
+ } catch (InterruptedException | OperationCanceledException x) {
// NeedWork
} catch (InvocationTargetException x) {
String title= Utilities.getString("CompareEditor.saveError.title"); //$NON-NLS-1$
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java
index a26bfe7..eb2f655 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java
@@ -1278,9 +1278,7 @@
return ITypedElement.UNKNOWN_TYPE;
}
return ITypedElement.TEXT_TYPE;
- } catch (CoreException ex) {
- // be silent and return UNKNOWN_TYPE
- } catch (IOException ex) {
+ } catch (CoreException | IOException ex) {
// be silent and return UNKNOWN_TYPE
} finally {
if (is != null) {
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/EditionAction.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/EditionAction.java
index 0bbfb72..b6612c7 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/EditionAction.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/EditionAction.java
@@ -212,9 +212,7 @@
try {
String text= Utilities.readString(sa);
document.replace(0, document.getLength(), text);
- } catch (CoreException e) {
- throw new InvocationTargetException(e);
- } catch (BadLocationException e) {
+ } catch (CoreException | BadLocationException e) {
throw new InvocationTargetException(e);
}
}
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/StreamMergerDescriptor.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/StreamMergerDescriptor.java
index 2f38f2a..c76f8d3 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/StreamMergerDescriptor.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/StreamMergerDescriptor.java
@@ -38,11 +38,7 @@
public IStreamMerger createStreamMerger() {
try {
return (IStreamMerger) fElement.createExecutableExtension(CLASS_ATTRIBUTE);
- } catch (CoreException ex) {
- //ExceptionHandler.handle(ex, SearchMessages.getString("Search.Error.createSorter.title"), SearchMessages.getString("Search.Error.createSorter.message")); //$NON-NLS-2$ //$NON-NLS-1$
- return null;
- } catch (ClassCastException ex) {
- //ExceptionHandler.displayMessageDialog(ex, SearchMessages.getString("Search.Error.createSorter.title"), SearchMessages.getString("Search.Error.createSorter.message")); //$NON-NLS-2$ //$NON-NLS-1$
+ } catch (CoreException | ClassCastException ex) {
return null;
}
}
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/Worker.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/Worker.java
index 23b0385..a702c1e 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/Worker.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/Worker.java
@@ -72,10 +72,7 @@
try {
performNextTask(progress);
progress.checkCanceled();
- } catch (OperationCanceledException e) {
- // Only cancel all the work if the outer monitor is canceled.
- progress.checkCanceled();
- } catch (InterruptedException e) {
+ } catch (OperationCanceledException | InterruptedException e) {
// Only cancel all the work if the outer monitor is canceled.
progress.checkCanceled();
} catch (InvocationTargetException e) {
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/InputPatchPage.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/InputPatchPage.java
index 0453443..475fb97 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/InputPatchPage.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/InputPatchPage.java
@@ -284,11 +284,7 @@
patchFileURL), getContainer());
if (contents != null)
reader = new StringReader(contents);
- } catch (MalformedURLException e) {
- // ignore as we tested it with modify listener on combo
- } catch (InvocationTargetException e) { // ignore
- } catch (OperationCanceledException e) { // ignore
- } catch (InterruptedException e) { // ignore
+ } catch (MalformedURLException | InvocationTargetException | OperationCanceledException | InterruptedException e) { // ignore
}
}
fPatchSource= PatchMessages.InputPatchPage_URL_title;
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PreviewPatchPage2.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PreviewPatchPage2.java
index 4f72a80..b3a969c 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PreviewPatchPage2.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PreviewPatchPage2.java
@@ -136,8 +136,7 @@
// Initialize the input
try {
fInput.run(null);
- } catch (InterruptedException e) {//ignore
- } catch (InvocationTargetException e) {//ignore
+ } catch (InterruptedException | InvocationTargetException e) {//ignore
}
Label label = new Label(composite, SWT.NONE);
@@ -300,8 +299,7 @@
}
monitor.done();
});
- } catch (InvocationTargetException e) { //ignore
- } catch (InterruptedException e) { //ignore
+ } catch (InvocationTargetException | InterruptedException e) { //ignore
}
}
};
@@ -326,8 +324,7 @@
}
monitor.done();
});
- } catch (InvocationTargetException e) { //ignore
- } catch (InterruptedException e) { //ignore
+ } catch (InvocationTargetException | InterruptedException e) { //ignore
}
}
@@ -657,9 +654,7 @@
PlatformUI.getWorkbench().getProgressService().run(true, true,
monitor -> result[0]= patcher.guessFuzzFactor(monitor)
);
- } catch (InvocationTargetException ex) {
- // NeedWork
- } catch (InterruptedException ex) {
+ } catch (InvocationTargetException | InterruptedException ex) {
// NeedWork
}
return result[0];
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DocumentRangeNode.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DocumentRangeNode.java
index 28fad01..aa694c5 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DocumentRangeNode.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DocumentRangeNode.java
@@ -118,9 +118,7 @@
fRange= new Position(start, length);
try {
fBaseDocument.addPosition(RANGE_CATEGORY, fRange);
- } catch (BadPositionCategoryException ex) {
- CompareUIPlugin.log(ex);
- } catch (BadLocationException ex) {
+ } catch (BadPositionCategoryException | BadLocationException ex) {
CompareUIPlugin.log(ex);
}
}
@@ -222,9 +220,7 @@
fBaseDocument.addPosition(RANGE_CATEGORY, p);
fAppendPosition= p;
}
- } catch (BadPositionCategoryException ex) {
- // silently ignored
- } catch (BadLocationException ex) {
+ } catch (BadPositionCategoryException | BadLocationException ex) {
// silently ignored
}
}
@@ -244,9 +240,7 @@
fBaseDocument.addPosition(RANGE_CATEGORY, p);
fAppendPosition= p;
return fAppendPosition;
- } catch (BadPositionCategoryException ex) {
- // silently ignored
- } catch (BadLocationException ex) {
+ } catch (BadPositionCategoryException | BadLocationException ex) {
// silently ignored
}
}