ListenerList generification.
Change-Id: I72abc2805afbbe19f0f5db9d2e7d697f832e83f1
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
diff --git a/core/plugins/org.eclipse.dltk.console.ui/src/org/eclipse/dltk/console/ui/ScriptConsole.java b/core/plugins/org.eclipse.dltk.console.ui/src/org/eclipse/dltk/console/ui/ScriptConsole.java
index ca1476d..79f8fd5 100644
--- a/core/plugins/org.eclipse.dltk.console.ui/src/org/eclipse/dltk/console/ui/ScriptConsole.java
+++ b/core/plugins/org.eclipse.dltk.console.ui/src/org/eclipse/dltk/console/ui/ScriptConsole.java
@@ -175,7 +175,7 @@
private ScriptConsoleSession session;
- private ListenerList consoleListeners;
+ private ListenerList<IScriptConsoleListener> consoleListeners;
private ScriptConsolePrompt prompt;
@@ -195,7 +195,7 @@
public ScriptConsole(String consoleName, String consoleType, ImageDescriptor image) {
super(consoleName, consoleType, image, true);
- this.consoleListeners = new ListenerList(ListenerList.IDENTITY);
+ this.consoleListeners = new ListenerList<>(ListenerList.IDENTITY);
this.prompt = new ScriptConsolePrompt("=>", "->"); //$NON-NLS-1$ //$NON-NLS-2$
this.history = new ScriptConsoleHistory();
@@ -293,9 +293,8 @@
if (this.interpreter == null || !this.interpreter.isValid()) {
return new ScriptExecResult(Util.EMPTY_STRING);
}
- Object[] listeners = consoleListeners.getListeners();
- for (int i = 0; i < listeners.length; i++) {
- ((IScriptConsoleListener) listeners[i]).userRequest(userInput);
+ for (IScriptConsoleListener listener : consoleListeners) {
+ listener.userRequest(userInput);
}
IScriptExecResult output = interpreter.exec(userInput);
@@ -306,8 +305,8 @@
prompt.setMode(false);
}
- for (int i = 0; i < listeners.length; i++) {
- ((IScriptConsoleListener) listeners[i]).interpreterResponse(output);
+ for (IScriptConsoleListener listener : consoleListeners) {
+ listener.interpreterResponse(output);
}
return output;
@@ -417,8 +416,7 @@
}
/**
- * disposes of the listeners for each of the stream associated with this
- * console
+ * disposes of the listeners for each of the stream associated with this console
*/
private synchronized void disposeStreams() {
for (StreamListener listener : fStreamListeners) {
diff --git a/core/plugins/org.eclipse.dltk.core.manipulation/src/org/eclipse/dltk/internal/corext/refactoring/changes/WorkspaceTracker.java b/core/plugins/org.eclipse.dltk.core.manipulation/src/org/eclipse/dltk/internal/corext/refactoring/changes/WorkspaceTracker.java
index 1e574cb..2a6fa74 100644
--- a/core/plugins/org.eclipse.dltk.core.manipulation/src/org/eclipse/dltk/internal/corext/refactoring/changes/WorkspaceTracker.java
+++ b/core/plugins/org.eclipse.dltk.core.manipulation/src/org/eclipse/dltk/internal/corext/refactoring/changes/WorkspaceTracker.java
@@ -1,11 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
-
*******************************************************************************/
package org.eclipse.dltk.internal.corext.refactoring.changes;
@@ -14,50 +13,49 @@
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.ListenerList;
-
public class WorkspaceTracker {
- public final static WorkspaceTracker INSTANCE= new WorkspaceTracker();
-
+ public final static WorkspaceTracker INSTANCE = new WorkspaceTracker();
+
public interface Listener {
public void workspaceChanged();
}
-
- private ListenerList fListeners;
+
+ private ListenerList<Listener> fListeners;
private ResourceListener fResourceListener;
-
+
private WorkspaceTracker() {
- fListeners= new ListenerList();
+ fListeners = new ListenerList<>();
}
private class ResourceListener implements IResourceChangeListener {
+ @Override
public void resourceChanged(IResourceChangeEvent event) {
workspaceChanged();
}
}
-
+
private void workspaceChanged() {
- Object[] listeners= fListeners.getListeners();
- for (int i= 0; i < listeners.length; i++) {
- ((Listener)listeners[i]).workspaceChanged();
+ for (Listener listener : fListeners) {
+ listener.workspaceChanged();
}
}
-
+
public void addListener(Listener l) {
fListeners.add(l);
if (fResourceListener == null) {
- fResourceListener= new ResourceListener();
+ fResourceListener = new ResourceListener();
ResourcesPlugin.getWorkspace().addResourceChangeListener(fResourceListener);
}
}
-
+
public void removeListener(Listener l) {
if (fListeners.size() == 0)
return;
fListeners.remove(l);
if (fListeners.size() == 0) {
ResourcesPlugin.getWorkspace().removeResourceChangeListener(fResourceListener);
- fResourceListener= null;
+ fResourceListener = null;
}
}
}
diff --git a/core/plugins/org.eclipse.dltk.core/environment/org/eclipse/dltk/core/environment/EnvironmentManager.java b/core/plugins/org.eclipse.dltk.core/environment/org/eclipse/dltk/core/environment/EnvironmentManager.java
index 4ca68f4..830f719 100644
--- a/core/plugins/org.eclipse.dltk.core/environment/org/eclipse/dltk/core/environment/EnvironmentManager.java
+++ b/core/plugins/org.eclipse.dltk.core/environment/org/eclipse/dltk/core/environment/EnvironmentManager.java
@@ -98,7 +98,7 @@
private static final EnvironmentProviderManager manager = new EnvironmentProviderManager();
- private static ListenerList listeners = new ListenerList();
+ private static ListenerList<IEnvironmentChangedListener> listeners = new ListenerList<>();
private static final Map<IProject, IEnvironment> environmentCache = new HashMap<>();
@@ -389,36 +389,28 @@
}
public static void environmentAdded(IEnvironment environment) {
- Object[] environmentListeners = listeners.getListeners();
- for (int i = 0; i < environmentListeners.length; i++) {
- IEnvironmentChangedListener listener = (IEnvironmentChangedListener) environmentListeners[i];
+ for (IEnvironmentChangedListener listener : listeners) {
listener.environmentAdded(environment);
}
fireEnvirontmentChange();
}
public static void environmentRemoved(IEnvironment environment) {
- Object[] environmentListeners = listeners.getListeners();
- for (int i = 0; i < environmentListeners.length; i++) {
- IEnvironmentChangedListener listener = (IEnvironmentChangedListener) environmentListeners[i];
+ for (IEnvironmentChangedListener listener : listeners) {
listener.environmentRemoved(environment);
}
fireEnvirontmentChange();
}
public static void environmentChanged(IEnvironment environment) {
- Object[] environmentListeners = listeners.getListeners();
- for (int i = 0; i < environmentListeners.length; i++) {
- IEnvironmentChangedListener listener = (IEnvironmentChangedListener) environmentListeners[i];
+ for (IEnvironmentChangedListener listener : listeners) {
listener.environmentChanged(environment);
}
fireEnvirontmentChange();
}
public static void fireEnvirontmentChange() {
- Object[] environmentListeners = listeners.getListeners();
- for (int i = 0; i < environmentListeners.length; i++) {
- IEnvironmentChangedListener listener = (IEnvironmentChangedListener) environmentListeners[i];
+ for (IEnvironmentChangedListener listener : listeners) {
listener.environmentsModified();
}
}
diff --git a/core/plugins/org.eclipse.dltk.core/search/org/eclipse/dltk/core/mixin/MixinModel.java b/core/plugins/org.eclipse.dltk.core/search/org/eclipse/dltk/core/mixin/MixinModel.java
index 5fd81e0..15470f8 100644
--- a/core/plugins/org.eclipse.dltk.core/search/org/eclipse/dltk/core/mixin/MixinModel.java
+++ b/core/plugins/org.eclipse.dltk.core/search/org/eclipse/dltk/core/mixin/MixinModel.java
@@ -289,8 +289,7 @@
}
entry.expireTime = System.currentTimeMillis()
+ REQUEST_CACHE_EXPIRE_TIME;
- entry.modules = new HashSet<>(
- Arrays.asList(containedModules));
+ entry.modules = new HashSet<>(Arrays.asList(containedModules));
entry.prefix = pattern;
entry.keys = new HashSet<>();
for (Set<String> strs : keys.values()) {
@@ -693,7 +692,7 @@
ISourceModule module);
}
- private final ListenerList mixinObjectInitializeListeners = new ListenerList();
+ private final ListenerList<IMixinObjectInitializeListener> mixinObjectInitializeListeners = new ListenerList<>();
private static final Object[] NO_OBJECTS = new Object[0];
@@ -999,10 +998,8 @@
// called with lock being help
private void notifyInitializeListener(IMixinElement element,
ISourceModule module, Object o) {
- Object[] listeners = mixinObjectInitializeListeners.getListeners();
- for (int i = 0; i < listeners.length; i++) {
- ((IMixinObjectInitializeListener) (listeners[i]))
- .initialize(element, o, module);
+ for (IMixinObjectInitializeListener listener : mixinObjectInitializeListeners) {
+ listener.initialize(element, o, module);
}
}
diff --git a/core/plugins/org.eclipse.dltk.core/search/org/eclipse/dltk/core/search/indexing/IndexManager.java b/core/plugins/org.eclipse.dltk.core/search/org/eclipse/dltk/core/search/indexing/IndexManager.java
index c911245..0e69cf5 100644
--- a/core/plugins/org.eclipse.dltk.core/search/org/eclipse/dltk/core/search/indexing/IndexManager.java
+++ b/core/plugins/org.eclipse.dltk.core/search/org/eclipse/dltk/core/search/indexing/IndexManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -64,12 +64,12 @@
private boolean needToSave = false;
private static final CRC32 checksumCalculator = new CRC32();
private IPath scriptPluginLocation = null;
- private final ListenerList shutdownListeners = new ListenerList();
- private final ListenerList indexerThreadListeners = new ListenerList();
+ private final ListenerList<IShutdownListener> shutdownListeners = new ListenerList<>();
+ private final ListenerList<IIndexThreadListener> indexerThreadListeners = new ListenerList<>();
/* can only replace a current state if its less than the new one */
private SimpleLookupTable indexStates = null;
- private File savedIndexNamesFile = getScriptPluginWorkingLocation().append(
- "savedIndexNames.txt").toFile(); //$NON-NLS-1$
+ private File savedIndexNamesFile = getScriptPluginWorkingLocation()
+ .append("savedIndexNames.txt").toFile(); //$NON-NLS-1$
public static final Integer SAVED_STATE = Integer.valueOf(0);
public static final Integer UPDATING_STATE = Integer.valueOf(1);
public static final Integer UNKNOWN_STATE = Integer.valueOf(2);
@@ -116,8 +116,8 @@
public void cleanUpIndexes() {
SimpleLookupTable knownPaths = new SimpleLookupTable();
IDLTKSearchScope scope = BasicSearchEngine.createWorkspaceScope(null);
- PatternSearchJob job = new PatternSearchJob(null, SearchEngine
- .getDefaultSearchParticipant(), scope, null);
+ PatternSearchJob job = new PatternSearchJob(null,
+ SearchEngine.getDefaultSearchParticipant(), scope, null);
Index[] selectedIndexes = job.getIndexes(null);
for (int j = 0, max = selectedIndexes.length; j < max; j++) {
// TODO should use getJavaPluginWorkingLocation()+index simple name
@@ -150,8 +150,8 @@
if (!knownPaths.containsKey(fileName)
&& fileName.toLowerCase().endsWith(".index")) { //$NON-NLS-1$
if (VERBOSE) {
- Util
- .verbose("Deleting index file " + indexesFiles[i]); //$NON-NLS-1$
+ Util.verbose(
+ "Deleting index file " + indexesFiles[i]); //$NON-NLS-1$
}
indexesFiles[i].delete();
}
@@ -169,8 +169,8 @@
String fileName = Long.toString(checksumCalculator.getValue())
+ ".index"; //$NON-NLS-1$
if (VERBOSE) {
- Util
- .verbose("-> index name for " + pathString + " is " + fileName); //$NON-NLS-1$ //$NON-NLS-2$
+ Util.verbose(
+ "-> index name for " + pathString + " is " + fileName); //$NON-NLS-1$ //$NON-NLS-2$
}
indexLocation = getScriptPluginWorkingLocation().append(fileName)
.toOSString();
@@ -197,8 +197,8 @@
IDLTKLanguageToolkit toolkit = null;
toolkit = DLTKLanguageManager.getLanguageToolkit(scriptProject);
if (toolkit != null) {
- return DLTKLanguageManager.createSourceRequestor(toolkit
- .getNatureId());
+ return DLTKLanguageManager
+ .createSourceRequestor(toolkit.getNatureId());
}
return null;
}
@@ -213,8 +213,8 @@
IDLTKLanguageToolkit toolkit = DLTKLanguageManager
.getLanguageToolkit(project);
if (toolkit != null) {
- return DLTKLanguageManager.getSourceElementParser(toolkit
- .getNatureId());
+ return DLTKLanguageManager
+ .getSourceElementParser(toolkit.getNatureId());
}
return null;
}
@@ -225,7 +225,7 @@
* (reuseExistingFile) then read it and return this index and record it in
* memory - if (createIfMissing) then create a new empty index and record it
* in memory
- *
+ *
* Warning: Does not check whether index is consistent (not being used)
*/
public synchronized Index getIndex(IPath containerPath,
@@ -237,7 +237,7 @@
/**
* This indexes aren't required to be rebuilt.
- *
+ *
* @param prefix
* @return
*/
@@ -268,8 +268,8 @@
return index;
} catch (IOException e) {
if (VERBOSE) {
- Util
- .verbose("-> cannot reuse existing index: " + indexLocation + " path: " + prefix); //$NON-NLS-1$ //$NON-NLS-2$
+ Util.verbose("-> cannot reuse existing index: " //$NON-NLS-1$
+ + indexLocation + " path: " + prefix); //$NON-NLS-1$
}
}
}
@@ -278,8 +278,8 @@
try {
if (VERBOSE) {
- Util
- .verbose("-> create empty index: " + indexLocation + " path: " + prefix); //$NON-NLS-1$ //$NON-NLS-2$
+ Util.verbose("-> create empty index: " + indexLocation //$NON-NLS-1$
+ + " path: " + prefix); //$NON-NLS-1$
}
/* do not reuse index file */
@@ -292,8 +292,8 @@
return index;
} catch (IOException e) {
if (VERBOSE) {
- Util
- .verbose("-> unable to create empty index: " + indexLocation + " path: " + containerPath); //$NON-NLS-1$ //$NON-NLS-2$
+ Util.verbose("-> unable to create empty index: " //$NON-NLS-1$
+ + indexLocation + " path: " + containerPath); //$NON-NLS-1$
}
// The file could not be created. Possible reason: the
// project has been deleted.
@@ -313,7 +313,7 @@
* (reuseExistingFile) then read it and return this index and record it in
* memory - if (createIfMissing) then create a new empty index and record it
* in memory
- *
+ *
* Warning: Does not check whether index is consistent (not being used)
*/
public synchronized Index getIndex(IPath containerPath,
@@ -365,8 +365,9 @@
* index is already being rebuilt
*/
if (VERBOSE) {
- Util
- .verbose("-> cannot reuse existing index: " + indexLocation + " path: " + containerPathString); //$NON-NLS-1$ //$NON-NLS-2$
+ Util.verbose("-> cannot reuse existing index: " //$NON-NLS-1$
+ + indexLocation + " path: " //$NON-NLS-1$
+ + containerPathString);
}
if (!createIfMissing) {
this.rebuildIndex(indexLocation, containerPath);
@@ -391,8 +392,8 @@
if (createIfMissing) {
try {
if (VERBOSE) {
- Util
- .verbose("-> create empty index: " + indexLocation + " path: " + containerPathString); //$NON-NLS-1$ //$NON-NLS-2$
+ Util.verbose("-> create empty index: " + indexLocation //$NON-NLS-1$
+ + " path: " + containerPathString); //$NON-NLS-1$
}
if (mixin) {
index = new MixinIndex(indexLocation,
@@ -407,8 +408,9 @@
return index;
} catch (IOException e) {
if (VERBOSE) {
- Util
- .verbose("-> unable to create empty index: " + indexLocation + " path: " + containerPathString); //$NON-NLS-1$ //$NON-NLS-2$
+ Util.verbose("-> unable to create empty index: " //$NON-NLS-1$
+ + indexLocation + " path: " //$NON-NLS-1$
+ + containerPathString);
}
// The file could not be created. Possible reason: the
// project has been deleted.
@@ -472,8 +474,8 @@
String fileName = files[i].getAbsolutePath();
if (fileName.toLowerCase().endsWith(".index")) { //$NON-NLS-1$
if (VERBOSE) {
- Util
- .verbose("Deleting index file " + files[i]); //$NON-NLS-1$
+ Util.verbose(
+ "Deleting index file " + files[i]); //$NON-NLS-1$
}
files[i].delete();
}
@@ -518,8 +520,8 @@
@Override
protected void notifyIdle() {
- for (Object listener : indexerThreadListeners.getListeners()) {
- ((IIndexThreadListener) listener).aboutToBeIdle();
+ for (IIndexThreadListener listener : indexerThreadListeners) {
+ listener.aboutToBeIdle();
}
}
@@ -531,8 +533,8 @@
if (idlingTime > 1000 && this.needToSave) {
this.saveIndexes();
}
- for (Object listener : indexerThreadListeners.getListeners()) {
- ((IIndexThreadListener) listener).aboutToBeRun(idlingTime);
+ for (IIndexThreadListener listener : indexerThreadListeners) {
+ listener.aboutToBeRun(idlingTime);
}
}
@@ -560,8 +562,8 @@
// Try to search for specified container path using model
if (target == null || target instanceof IFileHandle) {
try {
- IScriptProject[] scriptProjects = ModelManager
- .getModelManager().getModel().getScriptProjects();
+ IScriptProject[] scriptProjects = ModelManager.getModelManager()
+ .getModel().getScriptProjects();
for (IScriptProject project : scriptProjects) {
IProjectFragment[] fragments = project
.getProjectFragments();
@@ -584,8 +586,8 @@
}
if (VERBOSE) {
- Util
- .verbose("-> request to rebuild index: " + indexLocation + " path: " + containerPath.toString()); //$NON-NLS-1$ //$NON-NLS-2$
+ Util.verbose("-> request to rebuild index: " + indexLocation //$NON-NLS-1$
+ + " path: " + containerPath.toString()); //$NON-NLS-1$
}
this.updateIndexState(indexLocation, REBUILDING_STATE);
@@ -627,8 +629,8 @@
Index index = (Index) this.indexes.get(indexLocation);
ReadWriteMonitor monitor = index == null ? null : index.monitor;
if (VERBOSE) {
- Util
- .verbose("-> recreating index: " + indexLocation + " for path: " + containerPathString); //$NON-NLS-1$ //$NON-NLS-2$
+ Util.verbose("-> recreating index: " + indexLocation //$NON-NLS-1$
+ + " for path: " + containerPathString); //$NON-NLS-1$
}
if (mixin) {
index = new MixinIndex(indexLocation, containerPathString,
@@ -645,8 +647,8 @@
// The file could not be created. Possible reason: the project has
// been deleted.
if (VERBOSE) {
- Util
- .verbose("-> failed to recreate index for path: " + containerPathString); //$NON-NLS-1$
+ Util.verbose("-> failed to recreate index for path: " //$NON-NLS-1$
+ + containerPathString);
e.printStackTrace();
}
return null;
@@ -859,9 +861,9 @@
this.saveIndex(index);
} catch (IOException e) {
if (VERBOSE) {
- Util
- .verbose(
- "-> got the following exception while saving:", System.err); //$NON-NLS-1$
+ Util.verbose(
+ "-> got the following exception while saving:", //$NON-NLS-1$
+ System.err);
e.printStackTrace();
}
allSaved = false;
@@ -882,9 +884,8 @@
@Override
public void shutdown() {
super.shutdown();
- Object[] listeners = shutdownListeners.getListeners();
- for (int i = 0; i < listeners.length; ++i) {
- ((IShutdownListener) listeners[i]).shutdown();
+ for (IShutdownListener listener : shutdownListeners) {
+ listener.shutdown();
}
shutdownListeners.clear();
}
@@ -895,17 +896,18 @@
buffer.append(super.toString());
buffer.append("In-memory indexes:\n"); //$NON-NLS-1$
int count = 0;
- for (Iterator iter = this.indexes.values().iterator(); iter.hasNext();) {
- buffer.append(++count)
- .append(" - ").append(iter.next().toString()).append('\n'); //$NON-NLS-1$
+ for (Iterator iter = this.indexes.values().iterator(); iter
+ .hasNext();) {
+ buffer.append(++count).append(" - ").append(iter.next().toString()) //$NON-NLS-1$
+ .append('\n');
}
return buffer.toString();
}
private char[] readIndexState() {
try {
- return org.eclipse.dltk.compiler.util.Util.getFileCharContent(
- this.savedIndexNamesFile, null);
+ return org.eclipse.dltk.compiler.util.Util
+ .getFileCharContent(this.savedIndexNamesFile, null);
} catch (IOException ignored) {
if (VERBOSE) {
Util.verbose("Failed to read saved index file names"); //$NON-NLS-1$
@@ -925,8 +927,8 @@
if ((this.indexStates.removeKey(locations[i]) != null)) {
changed = true;
if (VERBOSE) {
- Util
- .verbose("-> index state updated to: ? for: " + locations[i]); //$NON-NLS-1$
+ Util.verbose("-> index state updated to: ? for: " //$NON-NLS-1$
+ + locations[i]);
}
}
}
@@ -962,8 +964,8 @@
} else if (indexState == REBUILDING_STATE) {
state = "REBUILDING"; //$NON-NLS-1$
}
- Util
- .verbose("-> index state updated to: " + state + " for: " + indexLocation); //$NON-NLS-1$ //$NON-NLS-2$
+ Util.verbose("-> index state updated to: " + state + " for: " //$NON-NLS-1$ //$NON-NLS-2$
+ + indexLocation);
}
}
@@ -981,8 +983,8 @@
}
} catch (IOException ignored) {
if (VERBOSE) {
- Util.verbose(
- "Failed to write saved index file names", System.err); //$NON-NLS-1$
+ Util.verbose("Failed to write saved index file names", //$NON-NLS-1$
+ System.err);
}
} finally {
if (writer != null) {
diff --git a/core/plugins/org.eclipse.dltk.debug/src/org/eclipse/dltk/dbgp/internal/DbgpDebugingEngine.java b/core/plugins/org.eclipse.dltk.debug/src/org/eclipse/dltk/dbgp/internal/DbgpDebugingEngine.java
index 904b119..c2f93d6 100644
--- a/core/plugins/org.eclipse.dltk.debug/src/org/eclipse/dltk/dbgp/internal/DbgpDebugingEngine.java
+++ b/core/plugins/org.eclipse.dltk.debug/src/org/eclipse/dltk/dbgp/internal/DbgpDebugingEngine.java
@@ -135,21 +135,17 @@
fireObjectTerminated(e);
}
- private final ListenerList listeners = new ListenerList();
+ private final ListenerList<IDbgpRawListener> listeners = new ListenerList<>();
protected void firePacketReceived(IDbgpRawPacket content) {
- Object[] list = listeners.getListeners();
-
- for (int i = 0; i < list.length; ++i) {
- ((IDbgpRawListener) list[i]).dbgpPacketReceived(id, content);
+ for (IDbgpRawListener listener : listeners) {
+ listener.dbgpPacketReceived(id, content);
}
}
protected void firePacketSent(IDbgpRawPacket content) {
- Object[] list = listeners.getListeners();
-
- for (int i = 0; i < list.length; ++i) {
- ((IDbgpRawListener) list[i]).dbgpPacketSent(id, content);
+ for (IDbgpRawListener listener : listeners) {
+ listener.dbgpPacketSent(id, content);
}
}
diff --git a/core/plugins/org.eclipse.dltk.debug/src/org/eclipse/dltk/dbgp/internal/DbgpTermination.java b/core/plugins/org.eclipse.dltk.debug/src/org/eclipse/dltk/dbgp/internal/DbgpTermination.java
index 710e23c..7129744 100644
--- a/core/plugins/org.eclipse.dltk.debug/src/org/eclipse/dltk/dbgp/internal/DbgpTermination.java
+++ b/core/plugins/org.eclipse.dltk.debug/src/org/eclipse/dltk/dbgp/internal/DbgpTermination.java
@@ -11,14 +11,12 @@
import org.eclipse.core.runtime.ListenerList;
public abstract class DbgpTermination implements IDbgpTermination {
- private final ListenerList listeners = new ListenerList();
+ private final ListenerList<IDbgpTerminationListener> listeners = new ListenerList<>();
protected void fireObjectTerminated(final Exception e) {
Thread thread = new Thread(() -> {
- Object[] list = listeners.getListeners();
- for (int i = 0; i < list.length; ++i) {
- ((IDbgpTerminationListener) list[i])
- .objectTerminated(DbgpTermination.this, e);
+ for (IDbgpTerminationListener listener : listeners) {
+ listener.objectTerminated(DbgpTermination.this, e);
}
});
diff --git a/core/plugins/org.eclipse.dltk.debug/src/org/eclipse/dltk/dbgp/internal/managers/DbgpNotificationManager.java b/core/plugins/org.eclipse.dltk.debug/src/org/eclipse/dltk/dbgp/internal/managers/DbgpNotificationManager.java
index ca80652..8f688a4 100644
--- a/core/plugins/org.eclipse.dltk.debug/src/org/eclipse/dltk/dbgp/internal/managers/DbgpNotificationManager.java
+++ b/core/plugins/org.eclipse.dltk.debug/src/org/eclipse/dltk/dbgp/internal/managers/DbgpNotificationManager.java
@@ -19,14 +19,13 @@
public class DbgpNotificationManager extends DbgpWorkingThread
implements IDbgpNotificationManager {
- private final ListenerList listeners = new ListenerList();
+ private final ListenerList<IDbgpNotificationListener> listeners = new ListenerList<>();
private final IDbgpDebugingEngine engine;
protected void fireDbgpNotify(IDbgpNotification notification) {
- Object[] list = listeners.getListeners();
- for (int i = 0; i < list.length; ++i) {
- ((IDbgpNotificationListener) list[i]).dbgpNotify(notification);
+ for (IDbgpNotificationListener listener : listeners) {
+ listener.dbgpNotify(notification);
}
}
diff --git a/core/plugins/org.eclipse.dltk.debug/src/org/eclipse/dltk/dbgp/internal/managers/DbgpStreamManager.java b/core/plugins/org.eclipse.dltk.debug/src/org/eclipse/dltk/dbgp/internal/managers/DbgpStreamManager.java
index 32885c5..389e986 100644
--- a/core/plugins/org.eclipse.dltk.debug/src/org/eclipse/dltk/dbgp/internal/managers/DbgpStreamManager.java
+++ b/core/plugins/org.eclipse.dltk.debug/src/org/eclipse/dltk/dbgp/internal/managers/DbgpStreamManager.java
@@ -16,25 +16,23 @@
public class DbgpStreamManager extends DbgpWorkingThread
implements IDbgpStreamManager {
- private final ListenerList listeners = new ListenerList();
+ private final ListenerList<IDbgpStreamListener> listeners = new ListenerList<>();
private final IDbgpDebugingEngine engine;
protected void fireStderrReceived(String data) {
if (data == null || data.length() == 0)
return;
- Object[] list = listeners.getListeners();
- for (int i = 0; i < list.length; ++i) {
- ((IDbgpStreamListener) list[i]).stderrReceived(data);
+ for (IDbgpStreamListener listener : listeners) {
+ listener.stderrReceived(data);
}
}
protected void fireStdoutReceived(String data) {
if (data == null || data.length() == 0)
return;
- Object[] list = listeners.getListeners();
- for (int i = 0; i < list.length; ++i) {
- ((IDbgpStreamListener) list[i]).stdoutReceived(data);
+ for (IDbgpStreamListener listener : listeners) {
+ listener.stdoutReceived(data);
}
}
diff --git a/core/plugins/org.eclipse.dltk.debug/src/org/eclipse/dltk/internal/debug/core/model/HotCodeReplaceManager.java b/core/plugins/org.eclipse.dltk.debug/src/org/eclipse/dltk/internal/debug/core/model/HotCodeReplaceManager.java
index e533435..2e9b7bf 100644
--- a/core/plugins/org.eclipse.dltk.debug/src/org/eclipse/dltk/internal/debug/core/model/HotCodeReplaceManager.java
+++ b/core/plugins/org.eclipse.dltk.debug/src/org/eclipse/dltk/internal/debug/core/model/HotCodeReplaceManager.java
@@ -40,7 +40,7 @@
private ArrayList fHotSwapTargets = new ArrayList();
private ArrayList fNoHotSwapTargets = new ArrayList();
- private ListenerList fHotCodeReplaceListeners = new ListenerList();
+ private ListenerList<IHotCodeReplaceListener> fHotCodeReplaceListeners = new ListenerList<>();
public static synchronized HotCodeReplaceManager getDefault() {
if (instance == null) {
@@ -86,10 +86,8 @@
* Notifies listeners that a hot code replace attempt succeeded
*/
private void fireHCRSucceeded(IScriptDebugTarget target) {
- Object[] listeners = fHotCodeReplaceListeners.getListeners();
- for (int i = 0; i < listeners.length; i++) {
- ((IHotCodeReplaceListener) listeners[i])
- .hotCodeReplaceSucceeded(target);
+ for (IHotCodeReplaceListener listener : fHotCodeReplaceListeners) {
+ listener.hotCodeReplaceSucceeded(target);
}
}
@@ -99,10 +97,8 @@
*/
private void fireHCRFailed(IScriptDebugTarget target,
DebugException exception) {
- Object[] listeners = fHotCodeReplaceListeners.getListeners();
- for (int i = 0; i < listeners.length; i++) {
- ((IHotCodeReplaceListener) listeners[i])
- .hotCodeReplaceFailed(target, exception);
+ for (IHotCodeReplaceListener listener : fHotCodeReplaceListeners) {
+ listener.hotCodeReplaceFailed(target, exception);
}
}
diff --git a/core/plugins/org.eclipse.dltk.debug/src/org/eclipse/dltk/internal/debug/core/model/ScriptDebugTarget.java b/core/plugins/org.eclipse.dltk.debug/src/org/eclipse/dltk/internal/debug/core/model/ScriptDebugTarget.java
index d0119d5..62b2e92 100644
--- a/core/plugins/org.eclipse.dltk.debug/src/org/eclipse/dltk/internal/debug/core/model/ScriptDebugTarget.java
+++ b/core/plugins/org.eclipse.dltk.debug/src/org/eclipse/dltk/internal/debug/core/model/ScriptDebugTarget.java
@@ -65,7 +65,7 @@
private static final int THREAD_TERMINATION_TIMEOUT = 5000; // 5 seconds
- private final ListenerList listeners;
+ private final ListenerList<IScriptDebugTargetListener> listeners;
private IScriptStreamProxy streamProxy;
@@ -121,7 +121,7 @@
this.modelId = modelId;
- this.listeners = new ListenerList();
+ this.listeners = new ListenerList<>();
this.process = process;
this.launch = launch;
@@ -411,16 +411,14 @@
}
protected void fireTargetInitialized() {
- Object[] list = listeners.getListeners();
- for (int i = 0; i < list.length; ++i) {
- ((IScriptDebugTargetListener) list[i]).targetInitialized();
+ for (IScriptDebugTargetListener listener : listeners) {
+ listener.targetInitialized();
}
}
protected void fireTargetTerminating() {
- Object[] list = listeners.getListeners();
- for (int i = 0; i < list.length; ++i) {
- ((IScriptDebugTargetListener) list[i]).targetTerminating();
+ for (IScriptDebugTargetListener listener : listeners) {
+ listener.targetTerminating();
}
}
diff --git a/core/plugins/org.eclipse.dltk.debug/src/org/eclipse/dltk/internal/debug/core/model/ScriptThreadManager.java b/core/plugins/org.eclipse.dltk.debug/src/org/eclipse/dltk/internal/debug/core/model/ScriptThreadManager.java
index 0533104..45e5af4 100644
--- a/core/plugins/org.eclipse.dltk.debug/src/org/eclipse/dltk/internal/debug/core/model/ScriptThreadManager.java
+++ b/core/plugins/org.eclipse.dltk.debug/src/org/eclipse/dltk/internal/debug/core/model/ScriptThreadManager.java
@@ -67,7 +67,7 @@
}
}
- private final ListenerList listeners = new ListenerList(
+ private final ListenerList<IScriptThreadManagerListener> listeners = new ListenerList<>(
ListenerList.IDENTITY);
private final List<IScriptThread> threads = new ArrayList<>();
@@ -77,17 +77,14 @@
private final ScriptDebugTarget target;
protected void fireThreadAccepted(IScriptThread thread, boolean first) {
- Object[] list = listeners.getListeners();
- for (int i = 0; i < list.length; ++i) {
- ((IScriptThreadManagerListener) list[i]).threadAccepted(thread,
- first);
+ for (IScriptThreadManagerListener listener : listeners) {
+ listener.threadAccepted(thread, first);
}
}
protected void fireAllThreadsTerminated() {
- Object[] list = listeners.getListeners();
- for (int i = 0; i < list.length; ++i) {
- ((IScriptThreadManagerListener) list[i]).allThreadsTerminated();
+ for (IScriptThreadManagerListener listener : listeners) {
+ listener.allThreadsTerminated();
}
}
diff --git a/core/plugins/org.eclipse.dltk.launching/src/org/eclipse/dltk/launching/ScriptRuntime.java b/core/plugins/org.eclipse.dltk.launching/src/org/eclipse/dltk/launching/ScriptRuntime.java
index 1504240..6c63f87 100644
--- a/core/plugins/org.eclipse.dltk.launching/src/org/eclipse/dltk/launching/ScriptRuntime.java
+++ b/core/plugins/org.eclipse.dltk.launching/src/org/eclipse/dltk/launching/ScriptRuntime.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2016 IBM Corporation and others.
+ * Copyright (c) 2005, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -301,7 +301,7 @@
/**
* Interpreter change listeners
*/
- private static ListenerList fgInterpreterListeners = new ListenerList(
+ private static ListenerList<IInterpreterInstallChangedListener> fgInterpreterListeners = new ListenerList<>(
ListenerList.IDENTITY);
/**
@@ -1320,9 +1320,7 @@
private static void notifyDefaultInterpreterChanged(
IInterpreterInstall previous, IInterpreterInstall current) {
- Object[] listeners = fgInterpreterListeners.getListeners();
- for (int i = 0; i < listeners.length; i++) {
- IInterpreterInstallChangedListener listener = (IInterpreterInstallChangedListener) listeners[i];
+ for (IInterpreterInstallChangedListener listener : fgInterpreterListeners) {
listener.defaultInterpreterInstallChanged(previous, current);
}
}
@@ -1336,9 +1334,7 @@
*
*/
public static void fireInterpreterChanged(PropertyChangeEvent event) {
- Object[] listeners = fgInterpreterListeners.getListeners();
- for (int i = 0; i < listeners.length; i++) {
- IInterpreterInstallChangedListener listener = (IInterpreterInstallChangedListener) listeners[i];
+ for (IInterpreterInstallChangedListener listener : fgInterpreterListeners) {
listener.interpreterChanged(event);
}
}
@@ -1353,9 +1349,7 @@
*/
public static void fireInterpreterAdded(IInterpreterInstall Interpreter) {
if (!fgInitializingInterpreters) {
- Object[] listeners = fgInterpreterListeners.getListeners();
- for (int i = 0; i < listeners.length; i++) {
- IInterpreterInstallChangedListener listener = (IInterpreterInstallChangedListener) listeners[i];
+ for (IInterpreterInstallChangedListener listener : fgInterpreterListeners) {
listener.interpreterAdded(Interpreter);
}
}
@@ -1370,9 +1364,7 @@
*
*/
public static void fireInterpreterRemoved(IInterpreterInstall Interpreter) {
- Object[] listeners = fgInterpreterListeners.getListeners();
- for (int i = 0; i < listeners.length; i++) {
- IInterpreterInstallChangedListener listener = (IInterpreterInstallChangedListener) listeners[i];
+ for (IInterpreterInstallChangedListener listener : fgInterpreterListeners) {
listener.interpreterRemoved(Interpreter);
}
}
diff --git a/core/plugins/org.eclipse.dltk.testing/src/org/eclipse/dltk/internal/testing/model/DLTKTestingModel.java b/core/plugins/org.eclipse.dltk.testing/src/org/eclipse/dltk/internal/testing/model/DLTKTestingModel.java
index 5bed60b..d0ad409 100755
--- a/core/plugins/org.eclipse.dltk.testing/src/org/eclipse/dltk/internal/testing/model/DLTKTestingModel.java
+++ b/core/plugins/org.eclipse.dltk.testing/src/org/eclipse/dltk/internal/testing/model/DLTKTestingModel.java
@@ -8,7 +8,6 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-
package org.eclipse.dltk.internal.testing.model;
import java.io.File;
@@ -226,7 +225,7 @@
return null;
}
- private final ListenerList fTestRunSessionListeners = new ListenerList();
+ private final ListenerList<ITestRunSessionListener> fTestRunSessionListeners = new ListenerList<>();
/**
* Active test run sessions, youngest first.
*/
@@ -512,18 +511,14 @@
launchManager.removeLaunch(launch);
}
- Object[] listeners = fTestRunSessionListeners.getListeners();
- for (int i = 0; i < listeners.length; ++i) {
- ((ITestRunSessionListener) listeners[i])
- .sessionRemoved(testRunSession);
+ for (ITestRunSessionListener listener : fTestRunSessionListeners) {
+ listener.sessionRemoved(testRunSession);
}
}
private void notifyTestRunSessionAdded(TestRunSession testRunSession) {
- Object[] listeners = fTestRunSessionListeners.getListeners();
- for (int i = 0; i < listeners.length; ++i) {
- ((ITestRunSessionListener) listeners[i])
- .sessionAdded(testRunSession);
+ for (ITestRunSessionListener listener : fTestRunSessionListeners) {
+ listener.sessionAdded(testRunSession);
}
}
diff --git a/core/plugins/org.eclipse.dltk.testing/src/org/eclipse/dltk/internal/testing/model/TestRunSession.java b/core/plugins/org.eclipse.dltk.testing/src/org/eclipse/dltk/internal/testing/model/TestRunSession.java
index f1e9c12..9d7bc6f 100755
--- a/core/plugins/org.eclipse.dltk.testing/src/org/eclipse/dltk/internal/testing/model/TestRunSession.java
+++ b/core/plugins/org.eclipse.dltk.testing/src/org/eclipse/dltk/internal/testing/model/TestRunSession.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -55,8 +55,8 @@
import com.ibm.icu.text.SimpleDateFormat;
/**
- * A test run session holds all information about a test run, i.e.
- * launch configuration, launch, test tree (including results).
+ * A test run session holds all information about a test run, i.e. launch
+ * configuration, launch, test tree (including results).
*/
public class TestRunSession implements ITestRunSession, ITestSession {
@@ -73,47 +73,48 @@
private final ITestingEngine fTestingEngine;
private final ITestRunnerUI testRunnerUI;
private final ITestCategoryEngine[] categoryEngines;
-
+
/**
* Test runner client or <code>null</code>.
*/
private ITestRunnerClient fTestRunnerClient;
- private final ListenerList/*<ITestSessionListener>*/ fSessionListeners;
-
+ private final ListenerList<ITestSessionListener> fSessionListeners;
+
/**
* The model root, or <code>null</code> if swapped to disk.
*/
private TestRoot fTestRoot;
-
+
/**
- * The test run session's cached result, or <code>null</code> if <code>fTestRoot != null</code>.
+ * The test run session's cached result, or <code>null</code> if
+ * <code>fTestRoot != null</code>.
*/
private Result fTestResult;
-
+
/**
* Map from testId to testElement.
*/
private Map<String, TestElement> fIdToTest;
-
+
/**
* test categories
*/
private Map<String, TestCategoryElement> fCategoryMap;
/**
- * The TestSuites for which additional children are expected.
+ * The TestSuites for which additional children are expected.
*/
private List<IncompleteTestSuite> fIncompleteTestSuites;
-
+
/**
* Suite for unrooted test case elements, or <code>null</code>.
*/
private TestSuiteElement fUnrootedSuite;
-
- /**
- * Number of tests started during this test run.
- */
+
+ /**
+ * Number of tests started during this test run.
+ */
volatile int fStartedCount;
/**
* Number of tests ignored during this test run.
@@ -140,66 +141,69 @@
*/
volatile long fStartTime;
volatile boolean fIsRunning;
-
+
volatile boolean fIsStopped;
-
/**
* @param testRunName
- * @param project may be <code>null</code>
+ * @param project
+ * may be <code>null</code>
*/
public TestRunSession(String testRunName, IScriptProject project) {
- //TODO: check assumptions about non-null fields
+ // TODO: check assumptions about non-null fields
- fLaunch= null;
- fProject= null; //TODO
-
+ fLaunch = null;
+ fProject = null; // TODO
+
Assert.isNotNull(testRunName);
- fTestRunName= testRunName;
- fTestingEngine= NullTestingEngine.getInstance();
- testRunnerUI= NullTestRunnerUI.getInstance();
+ fTestRunName = testRunName;
+ fTestingEngine = NullTestingEngine.getInstance();
+ testRunnerUI = NullTestRunnerUI.getInstance();
categoryEngines = null;
-
- fTestRoot= new TestRoot(this);
- fIdToTest = new HashMap<String, TestElement>();
- fCategoryMap = new HashMap<String, TestCategoryElement>();
-
- fTestRunnerClient= null;
- fSessionListeners= new ListenerList();
+ fTestRoot = new TestRoot(this);
+ fIdToTest = new HashMap<>();
+ fCategoryMap = new HashMap<>();
+
+ fTestRunnerClient = null;
+
+ fSessionListeners = new ListenerList<>();
}
-
-
+
public TestRunSession(ILaunch launch, IScriptProject project,
ITestRunnerClient runnerClient) {
Assert.isNotNull(launch);
Assert.isNotNull(runnerClient);
-
- fLaunch= launch;
- fProject= project;
-
- ILaunchConfiguration launchConfiguration= launch.getLaunchConfiguration();
+
+ fLaunch = launch;
+ fProject = project;
+
+ ILaunchConfiguration launchConfiguration = launch
+ .getLaunchConfiguration();
if (launchConfiguration != null) {
- fTestRunName= launchConfiguration.getName();
- fTestingEngine= DLTKTestingConstants.getTestingEngine(launchConfiguration);
- testRunnerUI= fTestingEngine.getTestRunnerUI(project, launchConfiguration);
+ fTestRunName = launchConfiguration.getName();
+ fTestingEngine = DLTKTestingConstants
+ .getTestingEngine(launchConfiguration);
+ testRunnerUI = fTestingEngine.getTestRunnerUI(project,
+ launchConfiguration);
categoryEngines = TestCategoryEngineManager
.getCategoryEngines(testRunnerUI);
} else {
- fTestRunName= project.getElementName();
- fTestingEngine= NullTestingEngine.getInstance();
- testRunnerUI= NullTestRunnerUI.getInstance();
+ fTestRunName = project.getElementName();
+ fTestingEngine = NullTestingEngine.getInstance();
+ testRunnerUI = NullTestRunnerUI.getInstance();
categoryEngines = null;
}
-
- fTestRoot= new TestRoot(this);
- fIdToTest = new HashMap<String, TestElement>();
- fCategoryMap = new HashMap<String, TestCategoryElement>();
-
- fTestRunnerClient= runnerClient;
+
+ fTestRoot = new TestRoot(this);
+ fIdToTest = new HashMap<>();
+ fCategoryMap = new HashMap<>();
+
+ fTestRunnerClient = runnerClient;
fTestRunnerClient.startListening(new TestSessionNotifier());
-
- final ILaunchManager launchManager= DebugPlugin.getDefault().getLaunchManager();
+
+ final ILaunchManager launchManager = DebugPlugin.getDefault()
+ .getLaunchManager();
launchManager.addLaunchListener(new ILaunchesListener2() {
@Override
public void launchesTerminated(ILaunch[] launches) {
@@ -211,6 +215,7 @@
scheduleTestRunTerminated();
}
}
+
@Override
public void launchesRemoved(ILaunch[] launches) {
if (Arrays.asList(launches).contains(fLaunch)) {
@@ -221,9 +226,11 @@
scheduleTestRunTerminated();
}
}
+
@Override
public void launchesChanged(ILaunch[] launches) {
}
+
@Override
public void launchesAdded(ILaunch[] launches) {
}
@@ -246,35 +253,29 @@
}
});
- fSessionListeners= new ListenerList();
+ fSessionListeners = new ListenerList<>();
addTestSessionListener(new TestRunListenerAdapter(this));
}
-
+
void reset() {
- fStartedCount= 0;
- fFailureCount= 0;
- fErrorCount= 0;
- fIgnoredCount= 0;
- fTotalCount= 0;
- fCreatedTestCaseCount=0;
-
- fTestRoot= new TestRoot(this);
- fTestResult= null;
- fIdToTest = new HashMap<String, TestElement>();
- fCategoryMap = new HashMap<String, TestCategoryElement>();
+ fStartedCount = 0;
+ fFailureCount = 0;
+ fErrorCount = 0;
+ fIgnoredCount = 0;
+ fTotalCount = 0;
+ fCreatedTestCaseCount = 0;
+
+ fTestRoot = new TestRoot(this);
+ fTestResult = null;
+ fIdToTest = new HashMap<>();
+ fCategoryMap = new HashMap<>();
}
- /*
- * @see org.eclipse.dltk.testing.model.ITestElement#getId()
- */
@Override
public String getId() {
return fTestRunName;
}
- /* (non-Javadoc)
- * @see org.eclipse.jdt.junit.ITestRunSession#getProgressState()
- */
@Override
public ProgressState getProgressState() {
if (isRunning()) {
@@ -285,10 +286,7 @@
}
return ProgressState.COMPLETED;
}
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.junit.model.ITestElement#getTestResult(boolean)
- */
+
@Override
public Result getTestResult(boolean includeChildren) {
if (fTestRoot != null) {
@@ -297,45 +295,30 @@
return fTestResult;
}
}
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.junit.model.ITestElementContainer#getChildren()
- */
+
@Override
public ITestElement[] getChildren() {
return getTestRoot().getChildren();
}
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.junit.model.ITestElement#getFailureTrace()
- */
- /* (non-Javadoc)
- * @see org.eclipse.dltk.internal.testing.model.ITestSession#getFailureTrace()
- */
+
@Override
public FailureTrace getFailureTrace() {
return null;
}
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.junit.model.ITestElement#getParentContainer()
- */
+
@Override
public ITestElementContainer getParentContainer() {
return null;
}
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.junit.model.ITestElement#getTestRunSession()
- */
+
@Override
public ITestRunSession getTestRunSession() {
return this;
}
-
-
+
public TestRoot getTestRoot() {
- swapIn(); //TODO: TestRoot should stay (e.g. for getTestRoot().getStatus())
+ swapIn(); // TODO: TestRoot should stay (e.g. for
+ // getTestRoot().getStatus())
return fTestRoot;
}
@@ -345,66 +328,49 @@
public IScriptProject getLaunchedProject() {
return fProject;
}
-
+
public ITestingEngine getTestingEngine() {
return fTestingEngine;
}
- /* (non-Javadoc)
- * @see org.eclipse.dltk.internal.testing.model.ITestSession#getLaunch()
- */
@Override
public ILaunch getLaunch() {
return fLaunch;
}
-
+
@Override
public String getTestRunName() {
return fTestRunName;
}
-
- /* (non-Javadoc)
- * @see org.eclipse.dltk.internal.testing.model.ITestSession#getErrorCount()
- */
+
@Override
public int getErrorCount() {
return fErrorCount;
}
- /* (non-Javadoc)
- * @see org.eclipse.dltk.internal.testing.model.ITestSession#getFailureCount()
- */
@Override
public int getFailureCount() {
return fFailureCount;
}
- /* (non-Javadoc)
- * @see org.eclipse.dltk.internal.testing.model.ITestSession#getStartedCount()
- */
@Override
public int getStartedCount() {
return fStartedCount;
}
- /* (non-Javadoc)
- * @see org.eclipse.dltk.internal.testing.model.ITestSession#getIgnoredCount()
- */
@Override
public int getIgnoredCount() {
return fIgnoredCount;
}
-
+
public int getTotalCount() {
return fTotalCount;
}
- /* (non-Javadoc)
- * @see org.eclipse.dltk.internal.testing.model.ITestSession#setTotalCount(int)
- */
+
@Override
public void setTotalCount(int count) {
this.fTotalCount = count;
-// System.out.println("COUNT:" + count);
+ // System.out.println("COUNT:" + count);
}
/**
@@ -416,17 +382,11 @@
}
}
- /* (non-Javadoc)
- * @see org.eclipse.dltk.internal.testing.model.ITestSession#getStartTime()
- */
@Override
public long getStartTime() {
return fStartTime;
}
-
- /* (non-Javadoc)
- * @see org.eclipse.dltk.internal.testing.model.ITestSession#isStopped()
- */
+
@Override
public boolean isStopped() {
return fIsStopped;
@@ -436,66 +396,66 @@
swapIn();
fSessionListeners.add(listener);
}
-
+
public void removeTestSessionListener(ITestSessionListener listener) {
fSessionListeners.remove(listener);
}
-
+
public void swapOut() {
if (fTestRoot == null)
return;
if (isRunning() || isStarting() || isKeptAlive())
return;
-
- Object[] listeners= fSessionListeners.getListeners();
- for (int i= 0; i < listeners.length; ++i) {
- ITestSessionListener registered= (ITestSessionListener) listeners[i];
- if (! registered.acceptsSwapToDisk())
+
+ for (ITestSessionListener registered : fSessionListeners) {
+ if (!registered.acceptsSwapToDisk())
return;
}
-
+
try {
- File swapFile= getSwapFile();
-
+ File swapFile = getSwapFile();
+
DLTKTestingModel.exportTestRunSession(this, swapFile);
- fTestResult= fTestRoot.getTestResult(true);
- fTestRoot= null;
- fTestRunnerClient= null;
- fIdToTest = new HashMap<String, TestElement>();
- fCategoryMap = new HashMap<String, TestCategoryElement>();
- fIncompleteTestSuites= null;
- fUnrootedSuite= null;
-
+ fTestResult = fTestRoot.getTestResult(true);
+ fTestRoot = null;
+ fTestRunnerClient = null;
+ fIdToTest = new HashMap<>();
+ fCategoryMap = new HashMap<>();
+ fIncompleteTestSuites = null;
+ fUnrootedSuite = null;
+
} catch (IllegalStateException e) {
DLTKTestingPlugin.log(e);
} catch (CoreException e) {
DLTKTestingPlugin.log(e);
}
}
-
- /* (non-Javadoc)
+
+ /*
+ * (non-Javadoc)
+ *
* @see org.eclipse.dltk.internal.testing.model.ITestSession#isStarting()
*/
@Override
public boolean isStarting() {
- return getStartTime() == 0 && fLaunch != null && ! fLaunch.isTerminated();
+ return getStartTime() == 0 && fLaunch != null
+ && !fLaunch.isTerminated();
}
-
public void removeSwapFile() {
- File swapFile= getSwapFile();
+ File swapFile = getSwapFile();
if (swapFile.exists())
swapFile.delete();
}
private File getSwapFile() throws IllegalStateException {
- File historyDir= DLTKTestingPlugin.getHistoryDirectory();
- String isoTime= new SimpleDateFormat("yyyyMMdd-HHmmss.SSS").format(new Date(getStartTime())); //$NON-NLS-1$
- String swapFileName= isoTime + ".xml"; //$NON-NLS-1$
+ File historyDir = DLTKTestingPlugin.getHistoryDirectory();
+ String isoTime = new SimpleDateFormat("yyyyMMdd-HHmmss.SSS") //$NON-NLS-1$
+ .format(new Date(getStartTime()));
+ String swapFileName = isoTime + ".xml"; //$NON-NLS-1$
return new File(historyDir, swapFileName);
}
-
public void swapIn() {
if (fTestRoot != null)
return;
@@ -504,60 +464,64 @@
DLTKTestingModel.importIntoTestRunSession(getSwapFile(), this);
} catch (IllegalStateException e) {
DLTKTestingPlugin.log(e);
- fTestRoot= new TestRoot(this);
- fTestResult= null;
+ fTestRoot = new TestRoot(this);
+ fTestResult = null;
} catch (CoreException e) {
DLTKTestingPlugin.log(e);
- fTestRoot= new TestRoot(this);
- fTestResult= null;
+ fTestRoot = new TestRoot(this);
+ fTestResult = null;
}
}
public void stopTestRun() {
- if (isRunning() || ! isKeptAlive())
- fIsStopped= true;
+ if (isRunning() || !isKeptAlive())
+ fIsStopped = true;
if (fTestRunnerClient != null)
fTestRunnerClient.stopTest();
}
/**
- * @return <code>true</code> iff the runtime VM of this test session is still alive
+ * @return <code>true</code> iff the runtime VM of this test session is
+ * still alive
*/
public boolean isKeptAlive() {
- if (fTestRunnerClient != null
- && fLaunch != null
+ if (fTestRunnerClient != null && fLaunch != null
&& fTestRunnerClient.isRunning()
&& ILaunchManager.DEBUG_MODE.equals(fLaunch.getLaunchMode())) {
- ILaunchConfiguration config= fLaunch.getLaunchConfiguration();
+ ILaunchConfiguration config = fLaunch.getLaunchConfiguration();
try {
- return config != null
- && config.getAttribute(DLTKTestingConstants.ATTR_KEEPRUNNING, false);
+ return config != null && config.getAttribute(
+ DLTKTestingConstants.ATTR_KEEPRUNNING, false);
} catch (CoreException e) {
return false;
}
-
+
} else {
return false;
}
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.eclipse.dltk.internal.testing.model.ITestSession#isRunning()
*/
@Override
public boolean isRunning() {
return fIsRunning;
}
-
+
/**
* @param testElement
- * @param launchMode
+ * @param launchMode
* @return <code>false</code> iff the rerun could not be started
- * @throws CoreException
+ * @throws CoreException
*/
- public boolean rerunTest(ITestElement testElement, String launchMode) throws CoreException {
+ public boolean rerunTest(ITestElement testElement, String launchMode)
+ throws CoreException {
if (isKeptAlive()) {
- Status status= ((TestCaseElement) getTestElement(testElement.getId())).getStatus();
+ Status status = ((TestCaseElement) getTestElement(
+ testElement.getId())).getStatus();
if (status == Status.ERROR) {
fErrorCount--;
} else if (status == Status.FAILURE) {
@@ -565,38 +529,47 @@
}
/* TODO fTestRunnerClient.rerunTest(testId, className, testName); */
return true;
-
+
} else if (fLaunch != null) {
if (testRunnerUI instanceof ITestRunnerUIExtension) {
- return ((ITestRunnerUIExtension) testRunnerUI).rerunTest(
- fLaunch, testElement, launchMode);
+ return ((ITestRunnerUIExtension) testRunnerUI)
+ .rerunTest(fLaunch, testElement, launchMode);
}
// run the selected test using the previous launch configuration
- ILaunchConfiguration launchConfiguration= fLaunch.getLaunchConfiguration();
+ ILaunchConfiguration launchConfiguration = fLaunch
+ .getLaunchConfiguration();
if (launchConfiguration != null) {
- //String name= className;
- //if (testName != null)
- //name+= "."+testName; //$NON-NLS-1$
- //String configName= Messages.format(DLTKTestingMessages.TestRunnerViewPart_configName, name);
- //ILaunchConfigurationWorkingCopy tmp= launchConfiguration.copy(configName);
- // fix for bug: 64838 junit view run single test does not use correct class [JUnit]
-// tmp.setAttribute(ScriptLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, className);
+ // String name= className;
+ // if (testName != null)
+ // name+= "."+testName; //$NON-NLS-1$
+ // String configName=
+ // Messages.format(DLTKTestingMessages.TestRunnerViewPart_configName,
+ // name);
+ // ILaunchConfigurationWorkingCopy tmp=
+ // launchConfiguration.copy(configName);
+ // fix for bug: 64838 junit view run single test does not use
+ // correct class [JUnit]
+ // tmp.setAttribute(ScriptLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME,
+ // className);
// reset the container
- //tmp.setAttribute(DLTKTestingConstants.ATTR_TEST_CONTAINER, ""); //$NON-NLS-1$
- //if (testName != null) {
- //tmp.setAttribute(DLTKTestingConstants.ATTR_TEST_METHOD_NAME, testName);
- // String args= "-rerun "+testId;
- // tmp.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, args);
- //}
- //tmp.launch(launchMode, null);
+ // tmp.setAttribute(DLTKTestingConstants.ATTR_TEST_CONTAINER,
+ // ""); //$NON-NLS-1$
+ // if (testName != null) {
+ // tmp.setAttribute(DLTKTestingConstants.ATTR_TEST_METHOD_NAME,
+ // testName);
+ // String args= "-rerun "+testId;
+ // tmp.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS,
+ // args);
+ // }
+ // tmp.launch(launchMode, null);
return true;
}
}
-
+
return false;
}
-
+
public TestElement getTestElement(String id) {
return fIdToTest.get(id);
}
@@ -624,18 +597,19 @@
private TestElement addTreeEntry(String treeEntry) {
// format: testId","testName","isSuite","testcount
- int index0= treeEntry.indexOf(',');
- String id= treeEntry.substring(0, index0);
-
- StringBuffer testNameBuffer= new StringBuffer(100);
+ int index0 = treeEntry.indexOf(',');
+ String id = treeEntry.substring(0, index0);
+
+ StringBuffer testNameBuffer = new StringBuffer(100);
int index1 = scanTestName(treeEntry, index0 + 1, testNameBuffer, true);
- String testName= testNameBuffer.toString().trim();
-
- int index2= treeEntry.indexOf(',', index1 + 1);
- boolean isSuite= treeEntry.substring(index1 + 1, index2).equals("true"); //$NON-NLS-1$
-
- int testCount= Integer.parseInt(treeEntry.substring(index2 + 1));
-
+ String testName = testNameBuffer.toString().trim();
+
+ int index2 = treeEntry.indexOf(',', index1 + 1);
+ boolean isSuite = treeEntry.substring(index1 + 1, index2)
+ .equals("true"); //$NON-NLS-1$
+
+ int testCount = Integer.parseInt(treeEntry.substring(index2 + 1));
+
return addTreeEntry(id, testName, isSuite, testCount);
}
@@ -647,53 +621,62 @@
if (category == null) {
category = fTestRoot;
}
- return createTestElement(category, id, testName, isSuite, testCount);
+ return createTestElement(category, id, testName, isSuite,
+ testCount);
} else {
- int suiteIndex= fIncompleteTestSuites.size() - 1;
- IncompleteTestSuite openSuite= fIncompleteTestSuites.get(suiteIndex);
+ int suiteIndex = fIncompleteTestSuites.size() - 1;
+ IncompleteTestSuite openSuite = fIncompleteTestSuites
+ .get(suiteIndex);
openSuite.fOutstandingChildren--;
if (openSuite.fOutstandingChildren <= 0)
fIncompleteTestSuites.remove(suiteIndex);
- return createTestElement(openSuite.fTestSuiteElement, id, testName, isSuite, testCount);
+ return createTestElement(openSuite.fTestSuiteElement, id, testName,
+ isSuite, testCount);
}
}
- public TestElement createTestElement(TestContainerElement parent, String id, String testName, boolean isSuite, int testCount) {
+ public TestElement createTestElement(TestContainerElement parent, String id,
+ String testName, boolean isSuite, int testCount) {
TestElement testElement;
if (isSuite) {
- TestSuiteElement testSuiteElement= new TestSuiteElement(parent, id, testName, testCount);
- testElement= testSuiteElement;
+ TestSuiteElement testSuiteElement = new TestSuiteElement(parent, id,
+ testName, testCount);
+ testElement = testSuiteElement;
if (testCount > 0)
- fIncompleteTestSuites.add(new IncompleteTestSuite(testSuiteElement, testCount));
+ fIncompleteTestSuites.add(
+ new IncompleteTestSuite(testSuiteElement, testCount));
} else {
- testElement= new TestCaseElement(parent, id, testName);
+ testElement = new TestCaseElement(parent, id, testName);
++fCreatedTestCaseCount;
adjustTotalCount(fCreatedTestCaseCount);
}
fIdToTest.put(id, testElement);
return testElement;
}
-
+
/**
* Append the test name from <code>s</code> to <code>testName</code>.
- *
- * @param s the string to scan
- * @param start the offset of the first character in <code>s</code>
- * @param testName the result
- *
+ *
+ * @param s
+ * the string to scan
+ * @param start
+ * the offset of the first character in <code>s</code>
+ * @param testName
+ * the result
+ *
* @return the index of the next ','
*/
static int scanTestName(String s, int start, StringBuffer testName,
boolean breakOnComma) {
- boolean inQuote= false;
- int i= start;
+ boolean inQuote = false;
+ int i = start;
for (; i < s.length(); i++) {
- char c= s.charAt(i);
+ char c = s.charAt(i);
if (c == '\\' && !inQuote) {
- inQuote= true;
+ inQuote = true;
continue;
} else if (inQuote) {
- inQuote= false;
+ inQuote = false;
testName.append(c);
} else if (breakOnComma && c == ',')
break;
@@ -709,63 +692,56 @@
* events (broadcasted to {@link ITestSessionListener}s).
*/
private class TestSessionNotifier implements ITestRunListener2 {
-
+
@Override
public void testRunStarted(int testCount) {
- fIncompleteTestSuites= new ArrayList<IncompleteTestSuite>();
-
- fStartedCount= 0;
- fIgnoredCount= 0;
- fFailureCount= 0;
- fErrorCount= 0;
- fTotalCount= testCount;
+ fIncompleteTestSuites = new ArrayList<>();
+
+ fStartedCount = 0;
+ fIgnoredCount = 0;
+ fFailureCount = 0;
+ fErrorCount = 0;
+ fTotalCount = testCount;
fCreatedTestCaseCount = 0;
-
- fStartTime= System.currentTimeMillis();
- fIsRunning= true;
-
- Object[] listeners= fSessionListeners.getListeners();
- for (int i= 0; i < listeners.length; ++i) {
- ((ITestSessionListener) listeners[i]).sessionStarted();
+
+ fStartTime = System.currentTimeMillis();
+ fIsRunning = true;
+
+ for (ITestSessionListener listener : fSessionListeners) {
+ listener.sessionStarted();
}
}
-
+
@Override
public void testRunEnded(long elapsedTime) {
- fIsRunning= false;
-
- Object[] listeners= fSessionListeners.getListeners();
- for (int i= 0; i < listeners.length; ++i) {
- ((ITestSessionListener) listeners[i]).sessionEnded(elapsedTime);
+ fIsRunning = false;
+
+ for (ITestSessionListener listener : fSessionListeners) {
+ listener.sessionEnded(elapsedTime);
}
}
-
+
@Override
public void testRunStopped(long elapsedTime) {
- fIsRunning= false;
- fIsStopped= true;
-
- Object[] listeners= fSessionListeners.getListeners();
- for (int i= 0; i < listeners.length; ++i) {
- ((ITestSessionListener) listeners[i]).sessionStopped(elapsedTime);
+ fIsRunning = false;
+ fIsStopped = true;
+
+ for (ITestSessionListener listener : fSessionListeners) {
+ listener.sessionStopped(elapsedTime);
}
}
-
+
@Override
public void testRunTerminated() {
TestRunSession.this.testRunTerminated();
}
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.internal.junit.model.ITestRunListener2#testTreeEntry(java.lang.String)
- */
+
@Override
public void testTreeEntry(String description) {
- TestElement testElement= addTreeEntry(description);
-
- Object[] listeners= fSessionListeners.getListeners();
- for (int i= 0; i < listeners.length; ++i) {
- ((ITestSessionListener) listeners[i]).testAdded(testElement);
+ TestElement testElement = addTreeEntry(description);
+
+ for (ITestSessionListener listener : fSessionListeners) {
+ listener.testAdded(testElement);
}
}
@@ -775,27 +751,29 @@
TestElement testElement = addTreeEntry(testId, testName, isSuite,
testCount);
- Object[] listeners = fSessionListeners.getListeners();
- for (int i = 0; i < listeners.length; ++i) {
- ((ITestSessionListener) listeners[i]).testAdded(testElement);
+ for (ITestSessionListener listener : fSessionListeners) {
+ listener.testAdded(testElement);
}
}
-
- private TestElement createUnrootedTestElement(String testId, String testName) {
- TestSuiteElement unrootedSuite= getUnrootedSuite();
- TestElement testElement= createTestElement(unrootedSuite, testId, testName, false, 1);
-
- Object[] listeners= fSessionListeners.getListeners();
- for (int i= 0; i < listeners.length; ++i) {
- ((ITestSessionListener) listeners[i]).testAdded(testElement);
+
+ private TestElement createUnrootedTestElement(String testId,
+ String testName) {
+ TestSuiteElement unrootedSuite = getUnrootedSuite();
+ TestElement testElement = createTestElement(unrootedSuite, testId,
+ testName, false, 1);
+
+ for (ITestSessionListener listener : fSessionListeners) {
+ listener.testAdded(testElement);
}
-
+
return testElement;
}
private TestSuiteElement getUnrootedSuite() {
if (fUnrootedSuite == null) {
- fUnrootedSuite= (TestSuiteElement) createTestElement(fTestRoot, "-2", DLTKTestingMessages.TestRunSession_unrootedTests, true, 0); //$NON-NLS-1$
+ fUnrootedSuite = (TestSuiteElement) createTestElement(fTestRoot,
+ "-2", DLTKTestingMessages.TestRunSession_unrootedTests, //$NON-NLS-1$
+ true, 0);
}
return fUnrootedSuite;
}
@@ -803,39 +781,37 @@
@Override
public void testStarted(String testId, String testName) {
if (fStartedCount == 0) {
- Object[] listeners= fSessionListeners.getListeners();
- for (int i= 0; i < listeners.length; ++i) {
- ((ITestSessionListener) listeners[i]).runningBegins();
+ for (ITestSessionListener listener : fSessionListeners) {
+ listener.runningBegins();
}
}
- TestElement testElement= getTestElement(testId);
+ TestElement testElement = getTestElement(testId);
if (testElement == null) {
- testElement= createUnrootedTestElement(testId, testName);
- } else if (! (testElement instanceof TestCaseElement)) {
+ testElement = createUnrootedTestElement(testId, testName);
+ } else if (!(testElement instanceof TestCaseElement)) {
logUnexpectedTest(testId, testElement);
return;
}
- TestCaseElement testCaseElement= (TestCaseElement) testElement;
+ TestCaseElement testCaseElement = (TestCaseElement) testElement;
setStatus(testCaseElement, Status.RUNNING);
-
+
fStartedCount++;
-
- Object[] listeners= fSessionListeners.getListeners();
- for (int i= 0; i < listeners.length; ++i) {
- ((ITestSessionListener) listeners[i]).testStarted(testCaseElement);
+
+ for (ITestSessionListener listener : fSessionListeners) {
+ listener.testStarted(testCaseElement);
}
}
-
+
@Override
public void testEnded(String testId, String testName) {
- TestElement testElement= getTestElement(testId);
+ TestElement testElement = getTestElement(testId);
if (testElement == null) {
- testElement= createUnrootedTestElement(testId, testName);
- } else if (! (testElement instanceof TestCaseElement)) {
+ testElement = createUnrootedTestElement(testId, testName);
+ } else if (!(testElement instanceof TestCaseElement)) {
logUnexpectedTest(testId, testElement);
return;
}
- TestCaseElement testCaseElement= (TestCaseElement) testElement;
+ TestCaseElement testCaseElement = (TestCaseElement) testElement;
if (testName.startsWith(MessageIds.IGNORED_TEST_PREFIX)) {
testCaseElement.setIgnored(true);
fIgnoredCount++;
@@ -846,35 +822,41 @@
if (testCaseElement.getStatus() == Status.RUNNING)
setStatus(testCaseElement, Status.OK);
-
- Object[] listeners= fSessionListeners.getListeners();
- for (int i= 0; i < listeners.length; ++i) {
- ((ITestSessionListener) listeners[i]).testEnded(testCaseElement);
+
+ for (ITestSessionListener listener : fSessionListeners) {
+ listener.testEnded(testCaseElement);
}
}
-
-
- public void testFailed(int status, String testId, String testName, String trace) {
+
+ public void testFailed(int status, String testId, String testName,
+ String trace) {
testFailed(status, testId, testName, trace, null, null, -1);
}
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.internal.junit.model.ITestRunListener2#testFailed(int, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.jdt.internal.junit.model.ITestRunListener2#testFailed(
+ * int, java.lang.String, java.lang.String, java.lang.String,
+ * java.lang.String, java.lang.String)
*/
@Override
- public void testFailed(int statusCode, String testId, String testName, String trace, String expected, String actual, int code) {
- TestElement testElement= getTestElement(testId);
+ public void testFailed(int statusCode, String testId, String testName,
+ String trace, String expected, String actual, int code) {
+ TestElement testElement = getTestElement(testId);
if (testElement == null) {
- testElement= createUnrootedTestElement(testId, testName);
+ testElement = createUnrootedTestElement(testId, testName);
return;
}
- Status status= Status.convert(statusCode, code);
- registerTestFailureStatus(testElement, status, trace, nullifyEmpty(expected), nullifyEmpty(actual));
-
- Object[] listeners= fSessionListeners.getListeners();
- for (int i= 0; i < listeners.length; ++i) {
- ((ITestSessionListener) listeners[i]).testFailed(testElement, status, trace, expected, actual, code);
+ Status status = Status.convert(statusCode, code);
+ registerTestFailureStatus(testElement, status, trace,
+ nullifyEmpty(expected), nullifyEmpty(actual));
+
+ for (ITestSessionListener listener : fSessionListeners) {
+ listener.testFailed(testElement, status, trace, expected,
+ actual, code);
}
}
@@ -888,37 +870,48 @@
}
return string;
}
-
- public void testReran(String testId, String testClass, String testName, int status, String trace) {
+
+ public void testReran(String testId, String testClass, String testName,
+ int status, String trace) {
testReran(testId, testClass, testName, status, trace, "", ""); //$NON-NLS-1$ //$NON-NLS-2$
}
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.internal.junit.model.ITestRunListener2#testReran(java.lang.String, java.lang.String, java.lang.String, int, java.lang.String, java.lang.String, java.lang.String)
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.jdt.internal.junit.model.ITestRunListener2#testReran(java
+ * .lang.String, java.lang.String, java.lang.String, int,
+ * java.lang.String, java.lang.String, java.lang.String)
*/
@Override
- public void testReran(String testId, String className, String testName, int statusCode, String trace, String expectedResult, String actualResult) {
- TestElement testElement= getTestElement(testId);
+ public void testReran(String testId, String className, String testName,
+ int statusCode, String trace, String expectedResult,
+ String actualResult) {
+ TestElement testElement = getTestElement(testId);
if (testElement == null) {
- testElement= createUnrootedTestElement(testId, testName);
- } else if (! (testElement instanceof TestCaseElement)) {
+ testElement = createUnrootedTestElement(testId, testName);
+ } else if (!(testElement instanceof TestCaseElement)) {
logUnexpectedTest(testId, testElement);
return;
}
- TestCaseElement testCaseElement= (TestCaseElement) testElement;
-
- Status status= Status.convert(statusCode, ITestingClient.PASSED);
- registerTestFailureStatus(testElement, status, trace, nullifyEmpty(expectedResult), nullifyEmpty(actualResult));
-
- Object[] listeners= fSessionListeners.getListeners();
- for (int i= 0; i < listeners.length; ++i) {
- //TODO: post old & new status?
- ((ITestSessionListener) listeners[i]).testReran(testCaseElement, status, trace, expectedResult, actualResult);
+ TestCaseElement testCaseElement = (TestCaseElement) testElement;
+
+ Status status = Status.convert(statusCode, ITestingClient.PASSED);
+ registerTestFailureStatus(testElement, status, trace,
+ nullifyEmpty(expectedResult), nullifyEmpty(actualResult));
+
+ for (ITestSessionListener listener : fSessionListeners) {
+ // TODO: post old & new status?
+ listener.testReran(testCaseElement, status, trace,
+ expectedResult, actualResult);
}
}
-
+
private void logUnexpectedTest(String testId, TestElement testElement) {
-// DLTKTestingPlugin.log(new Exception("Unexpected TestElement type for testId '" + testId + "': " + testElement)); //$NON-NLS-1$ //$NON-NLS-2$
+ // DLTKTestingPlugin.log(new Exception("Unexpected TestElement type
+ // for testId '" + testId + "': " + testElement)); //$NON-NLS-1$
+ // //$NON-NLS-2$
}
}
@@ -928,23 +921,24 @@
return;
fIsRunning = false;
fIsStopped = true;
- Object[] listeners = fSessionListeners.getListeners();
- for (int i = 0; i < listeners.length; ++i) {
- ((ITestSessionListener) listeners[i]).sessionTerminated();
+ for (ITestSessionListener listener : fSessionListeners) {
+ listener.sessionTerminated();
}
}
private static class IncompleteTestSuite {
public TestSuiteElement fTestSuiteElement;
public int fOutstandingChildren;
-
- public IncompleteTestSuite(TestSuiteElement testSuiteElement, int outstandingChildren) {
- fTestSuiteElement= testSuiteElement;
- fOutstandingChildren= outstandingChildren;
+
+ public IncompleteTestSuite(TestSuiteElement testSuiteElement,
+ int outstandingChildren) {
+ fTestSuiteElement = testSuiteElement;
+ fOutstandingChildren = outstandingChildren;
}
}
-
- public void registerTestFailureStatus(TestElement testElement, Status status, String trace, String expected, String actual) {
+
+ public void registerTestFailureStatus(TestElement testElement,
+ Status status, String trace, String expected, String actual) {
testElement.setStatus(status, trace, expected, actual);
if (status.isError()) {
fErrorCount++;
@@ -955,31 +949,32 @@
public void registerTestEnded(TestElement testElement, boolean completed) {
if (testElement instanceof TestCaseElement) {
- if (! completed) {
+ if (!completed) {
return;
}
fStartedCount++;
if (((TestCaseElement) testElement).isIgnored()) {
fIgnoredCount++;
}
- if (! testElement.getStatus().isErrorOrFailure())
+ if (!testElement.getStatus().isErrorOrFailure())
setStatus(testElement, Status.OK);
}
}
-
+
private void setStatus(TestElement testElement, Status status) {
testElement.setStatus(status);
}
-
+
@Override
- public ITestElement[] getFailedTestElements(ITestElementPredicate predicate) {
- List<ITestElement> failures = new ArrayList<ITestElement>();
+ public ITestElement[] getFailedTestElements(
+ ITestElementPredicate predicate) {
+ List<ITestElement> failures = new ArrayList<>();
addFailures(failures, getTestRoot(), predicate);
return failures.toArray(new TestElement[failures.size()]);
}
- private void addFailures(List<ITestElement> failures, ITestElement testElement,
- ITestElementPredicate predicate) {
+ private void addFailures(List<ITestElement> failures,
+ ITestElement testElement, ITestElementPredicate predicate) {
Result testResult = testElement.getTestResult(true);
if ((testResult == Result.ERROR || testResult == Result.FAILURE)
&& predicate.matches(testElement)) {
@@ -1009,8 +1004,10 @@
public final ITestRunnerUI getTestRunnerUI() {
return testRunnerUI;
}
-
- /* (non-Javadoc)
+
+ /*
+ * (non-Javadoc)
+ *
* @see org.eclipse.jdt.junit.model.ITestElement#getElapsedTimeInSeconds()
*/
@Override
diff --git a/core/plugins/org.eclipse.dltk.testing/src/org/eclipse/dltk/testing/DLTKTestingPlugin.java b/core/plugins/org.eclipse.dltk.testing/src/org/eclipse/dltk/testing/DLTKTestingPlugin.java
index fa2054a..822dc11 100755
--- a/core/plugins/org.eclipse.dltk.testing/src/org/eclipse/dltk/testing/DLTKTestingPlugin.java
+++ b/core/plugins/org.eclipse.dltk.testing/src/org/eclipse/dltk/testing/DLTKTestingPlugin.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -50,32 +50,32 @@
/**
* The single instance of this plug-in runtime class.
*/
- private static DLTKTestingPlugin fgPlugin= null;
+ private static DLTKTestingPlugin fgPlugin = null;
- public static final String PLUGIN_ID= "org.eclipse.dltk.testing"; //$NON-NLS-1$
+ public static final String PLUGIN_ID = "org.eclipse.dltk.testing"; //$NON-NLS-1$
/**
* The class path variable referring to the junit home location
*/
- public final static String JUNIT_HOME= "JUNIT_HOME"; //$NON-NLS-1$
+ public final static String JUNIT_HOME = "JUNIT_HOME"; //$NON-NLS-1$
- private static final IPath ICONS_PATH= new Path("$nl$/icons/full"); //$NON-NLS-1$
- private static final String HISTORY_DIR_NAME= "history"; //$NON-NLS-1$
+ private static final IPath ICONS_PATH = new Path("$nl$/icons/full"); //$NON-NLS-1$
+ private static final String HISTORY_DIR_NAME = "history"; //$NON-NLS-1$
- private final DLTKTestingModel fTestingModel= new DLTKTestingModel();
+ private final DLTKTestingModel fTestingModel = new DLTKTestingModel();
/**
* List storing the registered test run listeners
*/
- private ListenerList/*<TestRunListener>*/fNewTestRunListeners;
+ private ListenerList<TestRunListener> fNewTestRunListeners;
private BundleContext fBundleContext;
- private static boolean fIsStopped= false;
+ private static boolean fIsStopped = false;
public DLTKTestingPlugin() {
- fgPlugin= this;
- fNewTestRunListeners= new ListenerList();
+ fgPlugin = this;
+ fNewTestRunListeners = new ListenerList<>();
}
public static DLTKTestingPlugin getDefault() {
@@ -83,7 +83,7 @@
}
public static Shell getActiveWorkbenchShell() {
- IWorkbenchWindow workBenchWindow= getActiveWorkbenchWindow();
+ IWorkbenchWindow workBenchWindow = getActiveWorkbenchWindow();
if (workBenchWindow == null)
return null;
return workBenchWindow.getShell();
@@ -91,20 +91,20 @@
/**
* Returns the active workbench window
- *
+ *
* @return the active workbench window
*/
public static IWorkbenchWindow getActiveWorkbenchWindow() {
if (fgPlugin == null)
return null;
- IWorkbench workBench= fgPlugin.getWorkbench();
+ IWorkbench workBench = fgPlugin.getWorkbench();
if (workBench == null)
return null;
return workBench.getActiveWorkbenchWindow();
}
public static IWorkbenchPage getActivePage() {
- IWorkbenchWindow activeWorkbenchWindow= getActiveWorkbenchWindow();
+ IWorkbenchWindow activeWorkbenchWindow = getActiveWorkbenchWindow();
if (activeWorkbenchWindow == null)
return null;
return activeWorkbenchWindow.getActivePage();
@@ -119,7 +119,8 @@
}
public static void log(String message, Throwable e) {
- log(new Status(IStatus.ERROR, getPluginId(), IStatus.ERROR, message, e));
+ log(new Status(IStatus.ERROR, getPluginId(), IStatus.ERROR, message,
+ e));
}
public static void log(IStatus status) {
@@ -127,41 +128,48 @@
}
public static ImageDescriptor getImageDescriptor(String relativePath) {
- IPath path= ICONS_PATH.append(relativePath);
+ IPath path = ICONS_PATH.append(relativePath);
return createImageDescriptor(getDefault().getBundle(), path, true);
}
/**
- * Sets the three image descriptors for enabled, disabled, and hovered to an action. The actions
- * are retrieved from the *lcl16 folders.
- *
- * @param action the action
- * @param iconName the icon name
+ * Sets the three image descriptors for enabled, disabled, and hovered to an
+ * action. The actions are retrieved from the *lcl16 folders.
+ *
+ * @param action
+ * the action
+ * @param iconName
+ * the icon name
*/
- public static void setLocalImageDescriptors(IAction action, String iconName) {
+ public static void setLocalImageDescriptors(IAction action,
+ String iconName) {
setImageDescriptors(action, "lcl16", iconName); //$NON-NLS-1$
}
- private static void setImageDescriptors(IAction action, String type, String relPath) {
- ImageDescriptor id= createImageDescriptor("d" + type, relPath, false); //$NON-NLS-1$
+ private static void setImageDescriptors(IAction action, String type,
+ String relPath) {
+ ImageDescriptor id = createImageDescriptor("d" + type, relPath, false); //$NON-NLS-1$
if (id != null)
action.setDisabledImageDescriptor(id);
- ImageDescriptor descriptor= createImageDescriptor("e" + type, relPath, true); //$NON-NLS-1$
+ ImageDescriptor descriptor = createImageDescriptor("e" + type, relPath, //$NON-NLS-1$
+ true);
action.setHoverImageDescriptor(descriptor);
action.setImageDescriptor(descriptor);
}
/*
- * Creates an image descriptor for the given prefix and name in the JDT UI bundle. The path can
- * contain variables like $NL$.
- * If no image could be found, <code>useMissingImageDescriptor</code> decides if either
- * the 'missing image descriptor' is returned or <code>null</code>.
- * or <code>null</code>.
+ * Creates an image descriptor for the given prefix and name in the JDT UI
+ * bundle. The path can contain variables like $NL$. If no image could be
+ * found, <code>useMissingImageDescriptor</code> decides if either the
+ * 'missing image descriptor' is returned or <code>null</code>. or
+ * <code>null</code>.
*/
- private static ImageDescriptor createImageDescriptor(String pathPrefix, String imageName, boolean useMissingImageDescriptor) {
- IPath path= ICONS_PATH.append(pathPrefix).append(imageName);
- return createImageDescriptor(DLTKTestingPlugin.getDefault().getBundle(), path, useMissingImageDescriptor);
+ private static ImageDescriptor createImageDescriptor(String pathPrefix,
+ String imageName, boolean useMissingImageDescriptor) {
+ IPath path = ICONS_PATH.append(pathPrefix).append(imageName);
+ return createImageDescriptor(DLTKTestingPlugin.getDefault().getBundle(),
+ path, useMissingImageDescriptor);
}
/**
@@ -169,16 +177,17 @@
* contain variables like $NL$. If no image could be found,
* <code>useMissingImageDescriptor</code> decides if either the 'missing
* image descriptor' is returned or <code>null</code>.
- *
+ *
* @param bundle
* @param path
* @param useMissingImageDescriptor
- * @return an {@link ImageDescriptor}, or <code>null</code> iff there's
- * no image at the given location and
+ * @return an {@link ImageDescriptor}, or <code>null</code> iff there's no
+ * image at the given location and
* <code>useMissingImageDescriptor</code> is <code>true</code>
*/
- private static ImageDescriptor createImageDescriptor(Bundle bundle, IPath path, boolean useMissingImageDescriptor) {
- URL url= FileLocator.find(bundle, path, null);
+ private static ImageDescriptor createImageDescriptor(Bundle bundle,
+ IPath path, boolean useMissingImageDescriptor) {
+ URL url = FileLocator.find(bundle, path, null);
if (url != null) {
return ImageDescriptor.createFromURL(url);
}
@@ -191,19 +200,19 @@
@Override
public void start(BundleContext context) throws Exception {
super.start(context);
- fBundleContext= context;
+ fBundleContext = context;
fTestingModel.start();
}
@Override
public void stop(BundleContext context) throws Exception {
- fIsStopped= true;
+ fIsStopped = true;
try {
fTestingModel.stop();
} finally {
super.stop(context);
}
- fBundleContext= null;
+ fBundleContext = null;
}
public static ITestingModel getModel() {
@@ -211,15 +220,16 @@
}
/**
- * Returns the bundle for a given bundle name,
- * regardless whether the bundle is resolved or not.
- *
- * @param bundleName the bundle name
+ * Returns the bundle for a given bundle name, regardless whether the bundle
+ * is resolved or not.
+ *
+ * @param bundleName
+ * the bundle name
* @return the bundle
* @since 3.2
*/
public Bundle getBundle(String bundleName) {
- Bundle[] bundles= getBundles(bundleName, null);
+ Bundle[] bundles = getBundles(bundleName, null);
if (bundles != null && bundles.length > 0)
return bundles[0];
return null;
@@ -227,19 +237,21 @@
/**
* Returns the bundles for a given bundle name,
- *
- * @param bundleName the bundle name
+ *
+ * @param bundleName
+ * the bundle name
* @return the bundles of the given name
*/
public Bundle[] getBundles(String bundleName, String version) {
- Bundle[] bundles= Platform.getBundles(bundleName, version);
+ Bundle[] bundles = Platform.getBundles(bundleName, version);
if (bundles != null)
return bundles;
// Accessing unresolved bundle
- ServiceReference<PackageAdmin> serviceRef= fBundleContext.getServiceReference(PackageAdmin.class);
- PackageAdmin admin= fBundleContext.getService(serviceRef);
- bundles= admin.getBundles(bundleName, version);
+ ServiceReference<PackageAdmin> serviceRef = fBundleContext
+ .getServiceReference(PackageAdmin.class);
+ PackageAdmin admin = fBundleContext.getService(serviceRef);
+ bundles = admin.getBundles(bundleName, version);
if (bundles != null && bundles.length > 0)
return bundles;
return null;
@@ -248,7 +260,7 @@
/**
* @return a <code>ListenerList</code> of all <code>TestRunListener</code>s
*/
- public ListenerList/*<TestRunListener>*/getNewTestRunListeners() {
+ public ListenerList<TestRunListener> getNewTestRunListeners() {
return fNewTestRunListeners;
}
@@ -257,16 +269,17 @@
}
public IDialogSettings getDialogSettingsSection(String name) {
- IDialogSettings dialogSettings= getDialogSettings();
- IDialogSettings section= dialogSettings.getSection(name);
+ IDialogSettings dialogSettings = getDialogSettings();
+ IDialogSettings section = dialogSettings.getSection(name);
if (section == null) {
- section= dialogSettings.addNewSection(name);
+ section = dialogSettings.addNewSection(name);
}
return section;
}
public static File getHistoryDirectory() throws IllegalStateException {
- File historyDir= getDefault().getStateLocation().append(HISTORY_DIR_NAME).toFile();
+ File historyDir = getDefault().getStateLocation()
+ .append(HISTORY_DIR_NAME).toFile();
if (!historyDir.isDirectory()) {
historyDir.mkdir();
}
diff --git a/core/plugins/org.eclipse.dltk.validators.core/src/org/eclipse/dltk/validators/core/ValidatorRuntime.java b/core/plugins/org.eclipse.dltk.validators.core/src/org/eclipse/dltk/validators/core/ValidatorRuntime.java
index 5ed6473..9287179 100644
--- a/core/plugins/org.eclipse.dltk.validators.core/src/org/eclipse/dltk/validators/core/ValidatorRuntime.java
+++ b/core/plugins/org.eclipse.dltk.validators.core/src/org/eclipse/dltk/validators/core/ValidatorRuntime.java
@@ -53,7 +53,8 @@
private static boolean fgInitializingValidators = false;
private static boolean isInitialized = false;
//
- private static final ListenerList fgValidatorListeners = new ListenerList(ListenerList.IDENTITY);
+ private static final ListenerList<IValidatorChangedListener> fgValidatorListeners = new ListenerList<>(
+ ListenerList.IDENTITY);
public static final String ANY_NATURE = "#"; //$NON-NLS-1$
@@ -232,8 +233,7 @@
}
public static void fireValidatorChanged(IValidator validator) {
- Object[] listeners = fgValidatorListeners.getListeners();
- for (int i = 0; i < listeners.length; i++) {
+ for (IValidatorChangedListener listener : fgValidatorListeners) {
// IValidatorChangedListener listener = (IValidatorChangedListener)
// listeners[i];
// listener.validatorChanged(validator);
@@ -242,8 +242,7 @@
public static void fireValidatorAdded(IValidator Interpreter) {
if (!fgInitializingValidators) {
- Object[] listeners = fgValidatorListeners.getListeners();
- for (int i = 0; i < listeners.length; i++) {
+ for (IValidatorChangedListener listener : fgValidatorListeners) {
// IValidatorChangedListener listener =
// (IValidatorChangedListener) listeners[i];
// listener.validatorAdded(Interpreter);
@@ -252,8 +251,7 @@
}
public static void fireValidatorRemoved(IValidator Interpreter) {
- Object[] listeners = fgValidatorListeners.getListeners();
- for (int i = 0; i < listeners.length; i++) {
+ for (IValidatorChangedListener listener : fgValidatorListeners) {
// IValidatorChangedListener listener = (IValidatorChangedListener)
// listeners[i];
// listener.validatorRemoved(Interpreter);
@@ -261,8 +259,8 @@
}
/**
- * Returns array of validator types which are not built-in, i.e. new
- * instances of that types could be added by the user.
+ * Returns array of validator types which are not built-in, i.e. new instances
+ * of that types could be added by the user.
*
* @return
*/