Skip to content

Commit dde6fff

Browse files
committed
Fix/cleanup compiler warnings in TestRunnerViewPart
* Stop using deprecated URL contructor * Fix inner class typo * Remove empty method * Use pattern matching
1 parent 7a19801 commit dde6fff

1 file changed

Lines changed: 13 additions & 34 deletions

File tree

debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/ui/TestRunnerViewPart.java

Lines changed: 13 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
L * Copyright (c) 2000, 2018 IBM Corporation and others.
2+
L * Copyright (c) 2000, 2026 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,8 +13,12 @@
1313
*******************************************************************************/
1414
package org.eclipse.unittest.internal.ui;
1515

16+
import static org.eclipse.core.runtime.Assert.isNotNull;
17+
1618
import java.lang.reflect.InvocationTargetException;
1719
import java.net.MalformedURLException;
20+
import java.net.URI;
21+
import java.net.URISyntaxException;
1822
import java.net.URL;
1923
import java.text.MessageFormat;
2024
import java.time.Duration;
@@ -67,7 +71,6 @@
6771
import org.eclipse.core.commands.ExecutionException;
6872
import org.eclipse.core.commands.IHandler;
6973

70-
import org.eclipse.core.runtime.Assert;
7174
import org.eclipse.core.runtime.CoreException;
7275
import org.eclipse.core.runtime.IProgressMonitor;
7376
import org.eclipse.core.runtime.IStatus;
@@ -331,13 +334,13 @@ public void partHidden(IWorkbenchPartReference ref) {
331334

332335
protected boolean fPartIsVisible = false;
333336

334-
private static class UnitTesttPasteAction extends Action {
337+
private static class UnitTestPasteAction extends Action {
335338
private final Shell fShell;
336339
private final Clipboard fClipboard;
337340

338-
public UnitTesttPasteAction(Shell shell, Clipboard clipboard) {
341+
public UnitTestPasteAction(Shell shell, Clipboard clipboard) {
339342
super(Messages.TestRunnerViewPart_PasteAction_label);
340-
Assert.isNotNull(clipboard);
343+
isNotNull(clipboard);
341344
fShell = shell;
342345
fClipboard = clipboard;
343346
}
@@ -361,8 +364,8 @@ public void run() {
361364
private boolean isValidUrl(String urlData) {
362365
try {
363366
@SuppressWarnings("unused")
364-
URL url = new URL(urlData);
365-
} catch (MalformedURLException e) {
367+
URL url = new URI(urlData).toURL();
368+
} catch (MalformedURLException | URISyntaxException e) {
366369
return false;
367370
}
368371
return true;
@@ -1408,11 +1411,10 @@ public void createPartControl(Composite parent) {
14081411
fCopyAction.setActionDefinitionId(ActionFactory.COPY.getCommandId());
14091412
actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(), fCopyAction);
14101413

1411-
fPasteAction = new UnitTesttPasteAction(parent.getShell(), fClipboard);
1414+
fPasteAction = new UnitTestPasteAction(parent.getShell(), fClipboard);
14121415
fPasteAction.setActionDefinitionId(ActionFactory.PASTE.getCommandId());
14131416
actionBars.setGlobalActionHandler(ActionFactory.PASTE.getId(), fPasteAction);
14141417

1415-
initPageSwitcher();
14161418
addDropAdapter(parent);
14171419

14181420
fOriginalViewImage = getTitleImage();
@@ -1474,29 +1476,6 @@ public void drop(final DropTargetEvent event) {
14741476
dropTarget.addDropListener(new DropAdapter());
14751477
}
14761478

1477-
private void initPageSwitcher() {
1478-
/*
1479-
* @SuppressWarnings("unused") PageSwitcher pageSwitcher= new PageSwitcher(this)
1480-
* {
1481-
*
1482-
* @Override public Object[] getPages() { return
1483-
* fViewHistory.getHistoryEntries().toArray(); }
1484-
*
1485-
* @Override public String getName(Object page) { return
1486-
* fViewHistory.getText((TestRunSession) page); }
1487-
*
1488-
* @Override public ImageDescriptor getImageDescriptor(Object page) { return
1489-
* fViewHistory.getImageDescriptor(page); }
1490-
*
1491-
* @Override public void activatePage(Object page) {
1492-
* fViewHistory.setActiveEntry((TestRunSession) page); }
1493-
*
1494-
* @Override public int getCurrentPageIndex() { return
1495-
* fViewHistory.getHistoryEntries().indexOf(fViewHistory.getCurrentEntry()); }
1496-
* };
1497-
*/
1498-
}
1499-
15001479
private void addResizeListener(Composite parent) {
15011480
parent.addControlListener(ControlListener.controlResizedAdapter(e -> {
15021481
computeOrientation();
@@ -1654,8 +1633,8 @@ private IStatusLineManager getStatusLine() {
16541633

16551634
if (activePart instanceof IEditorPart activeEditorPart) {
16561635
IEditorActionBarContributor contributor = activeEditorPart.getEditorSite().getActionBarContributor();
1657-
if (contributor instanceof EditorActionBarContributor) {
1658-
return ((EditorActionBarContributor) contributor).getActionBars().getStatusLineManager();
1636+
if (contributor instanceof EditorActionBarContributor editorActionBar) {
1637+
return editorActionBar.getActionBars().getStatusLineManager();
16591638
}
16601639
}
16611640
// no active part

0 commit comments

Comments
 (0)