ListenerList generification.

Change-Id: Ia5ef62364af0a32952c398ce505c5c01a22bb458
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
diff --git a/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/core/RubyPlugin.java b/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/core/RubyPlugin.java
index 7b49da4..a56c3dd 100644
--- a/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/core/RubyPlugin.java
+++ b/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/core/RubyPlugin.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
@@ -35,9 +35,8 @@
 	public static final String PLUGIN_ID = "org.eclipse.dltk.ruby.core"; //$NON-NLS-1$
 
 	public static final boolean DUMP_EXCEPTIONS_TO_CONSOLE = Boolean
-			.valueOf(
-					Platform
-							.getDebugOption("org.eclipse.dltk.ruby.core/dumpErrorsToConsole")) //$NON-NLS-1$
+			.valueOf(Platform.getDebugOption(
+					"org.eclipse.dltk.ruby.core/dumpErrorsToConsole")) //$NON-NLS-1$
 			.booleanValue();
 
 	// The shared instance
@@ -55,7 +54,7 @@
 		super.start(context);
 	}
 
-	private final ListenerList shutdownListeners = new ListenerList();
+	private final ListenerList<IShutdownListener> shutdownListeners = new ListenerList<>();
 
 	public void addShutdownListener(IShutdownListener listener) {
 		shutdownListeners.add(listener);
@@ -63,9 +62,8 @@
 
 	@Override
 	public void stop(BundleContext context) throws Exception {
-		Object[] listeners = shutdownListeners.getListeners();
-		for (int i = 0; i < listeners.length; ++i) {
-			((IShutdownListener) listeners[i]).shutdown();
+		for (IShutdownListener listener : shutdownListeners) {
+			listener.shutdown();
 		}
 		shutdownListeners.clear();
 		plugin = null;
@@ -75,7 +73,7 @@
 
 	/**
 	 * Returns the shared instance
-	 * 
+	 *
 	 * @return the shared instance
 	 */
 	public static RubyPlugin getDefault() {
@@ -88,15 +86,15 @@
 		String message = ex.getMessage();
 		if (message == null)
 			message = "(no message)"; //$NON-NLS-1$
-		getDefault().getLog().log(
-				new Status(IStatus.ERROR, PLUGIN_ID, 0, message, ex));
+		getDefault().getLog()
+				.log(new Status(IStatus.ERROR, PLUGIN_ID, 0, message, ex));
 	}
 
 	public static void log(String message) {
 		if (DLTKCore.DEBUG || DUMP_EXCEPTIONS_TO_CONSOLE)
 			System.out.println(message);
-		getDefault().getLog().log(
-				new Status(IStatus.WARNING, PLUGIN_ID, 0, message, null));
+		getDefault().getLog()
+				.log(new Status(IStatus.WARNING, PLUGIN_ID, 0, message, null));
 	}
 
 	/**
@@ -122,7 +120,7 @@
 	 * <p>
 	 * This method can be called concurrently.
 	 * </p>
-	 * 
+	 *
 	 * @param monitor
 	 *            a progress monitor, or <code>null</code> if progress reporting
 	 *            and cancellation are not desired
@@ -135,9 +133,8 @@
 			throws CoreException {
 		try {
 			if (monitor != null)
-				monitor
-						.beginTask(Messages.RubyPlugin_initializingDltkRuby,
-								100);
+				monitor.beginTask(Messages.RubyPlugin_initializingDltkRuby,
+						100);
 
 			// dummy query for waiting until the indexes are ready
 			SearchEngine engine = new SearchEngine();
@@ -145,33 +142,38 @@
 					.createWorkspaceScope(RubyLanguageToolkit.getDefault());
 			try {
 				if (monitor != null)
-					monitor
-							.subTask(Messages.RubyPlugin_initializingSearchEngine);
-				engine.searchAllTypeNames(
-						null,
-						SearchPattern.R_EXACT_MATCH,
+					monitor.subTask(
+							Messages.RubyPlugin_initializingSearchEngine);
+				engine.searchAllTypeNames(null, SearchPattern.R_EXACT_MATCH,
 						"!@$#!@".toCharArray(), //$NON-NLS-1$
 						SearchPattern.R_PATTERN_MATCH
 								| SearchPattern.R_CASE_SENSITIVE,
-						IDLTKSearchConstants.TYPE,
-						scope,
+						IDLTKSearchConstants.TYPE, scope,
 						new NopTypeNameRequestor(),
 						// will not activate index query caches if indexes are
 						// not ready, since it would take to long
 						// to wait until indexes are fully rebuild
 						IDLTKSearchConstants.CANCEL_IF_NOT_READY_TO_SEARCH,
-						monitor == null ? null : new SubProgressMonitor(
-								monitor, 49) // 49% of the time is spent in the
-						// dummy search
-						);
+						monitor == null ? null
+								: new SubProgressMonitor(monitor, 49) // 49% of
+																		// the
+																		// time
+																		// is
+																		// spent
+																		// in
+																		// the
+				// dummy search
+				);
 
 				// String[] mainClasses = new String[] {
-				//	"Object", "String", "Fixnum", "Array", "Regexp", "Class", "Kernel" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
+				// "Object", "String", "Fixnum", "Array", "Regexp", "Class",
+				// "Kernel" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+				// //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
 				// for (int i = 0; i < mainClasses.length; i++) {
 				// RubyMixinModel.getInstance().createRubyElement(
 				// mainClasses[i]);
 				// RubyMixinModel.getInstance().createRubyElement(
-				//	mainClasses[i] + "%"); //$NON-NLS-1$
+				// mainClasses[i] + "%"); //$NON-NLS-1$
 				// monitor.worked(10);
 				// }
 				// RubyMixinModel.getRawInstance().find("$*"); //$NON-NLS-1$
diff --git a/plugins/org.eclipse.dltk.ruby.ui/src/org/eclipse/dltk/ruby/internal/ui/RubyUI.java b/plugins/org.eclipse.dltk.ruby.ui/src/org/eclipse/dltk/ruby/internal/ui/RubyUI.java
index cad2605..7ae7b3d 100644
--- a/plugins/org.eclipse.dltk.ruby.ui/src/org/eclipse/dltk/ruby/internal/ui/RubyUI.java
+++ b/plugins/org.eclipse.dltk.ruby.ui/src/org/eclipse/dltk/ruby/internal/ui/RubyUI.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
@@ -30,7 +30,7 @@
 
 	private RubyTextTools fRubyTextTools;
 	
-	private ListenerList shutdownListeners = new ListenerList();
+	private ListenerList<IShutdownListener> shutdownListeners = new ListenerList<>();
 
 	/**
 	 * The constructor
@@ -52,9 +52,8 @@
 
 	@Override
 	public void stop(BundleContext context) throws Exception {
-		Object[] listeners = shutdownListeners.getListeners();
-		for (int i = 0; i < listeners.length; ++i) {
-			((IShutdownListener) listeners[i]).shutdown();
+		for (IShutdownListener listener : shutdownListeners) {
+			listener.shutdown();
 		}
 		shutdownListeners.clear();
 		plugin = null;
diff --git a/plugins/org.eclipse.dltk.ruby.ui/src/org/eclipse/dltk/ruby/internal/ui/docs/Watchdog.java b/plugins/org.eclipse.dltk.ruby.ui/src/org/eclipse/dltk/ruby/internal/ui/docs/Watchdog.java
index a7421b6..e56b9b3 100644
--- a/plugins/org.eclipse.dltk.ruby.ui/src/org/eclipse/dltk/ruby/internal/ui/docs/Watchdog.java
+++ b/plugins/org.eclipse.dltk.ruby.ui/src/org/eclipse/dltk/ruby/internal/ui/docs/Watchdog.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2008, 2016 xored software, Inc. and others.
+ * Copyright (c) 2008, 2017 xored software, Inc. and others.
  *
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
@@ -15,7 +15,7 @@
 
 public class Watchdog implements Runnable {
 
-	private ListenerList timeoutListeners = new ListenerList();
+	private ListenerList<WatchdogListener> timeoutListeners = new ListenerList<>();
 
 	private final long timeout;
 
@@ -37,9 +37,8 @@
 	}
 
 	protected final void fireTimeoutOccured() {
-		Object[] listeners = timeoutListeners.getListeners();
-		for (int i = 0; i < listeners.length; ++i) {
-			((WatchdogListener) listeners[i]).timeoutOccured();
+		for (WatchdogListener listener : timeoutListeners) {
+			listener.timeoutOccured();
 		}
 	}
 
diff --git a/plugins/org.eclipse.dltk.ruby.ui/src/org/eclipse/dltk/ruby/internal/ui/editor/RubyEditor.java b/plugins/org.eclipse.dltk.ruby.ui/src/org/eclipse/dltk/ruby/internal/ui/editor/RubyEditor.java
index 967d9c4..ca75549 100644
--- a/plugins/org.eclipse.dltk.ruby.ui/src/org/eclipse/dltk/ruby/internal/ui/editor/RubyEditor.java
+++ b/plugins/org.eclipse.dltk.ruby.ui/src/org/eclipse/dltk/ruby/internal/ui/editor/RubyEditor.java
@@ -1,11 +1,10 @@
 /*******************************************************************************
- * 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
  * http://www.eclipse.org/legal/epl-v10.html
  *
- 
  *******************************************************************************/
 package org.eclipse.dltk.ruby.internal.ui.editor;
 
@@ -125,7 +124,7 @@
 					.prependVerifyKeyListener(fBracketInserter);
 	}
 
-	private static ListenerList doSetInputListeners = new ListenerList();
+	private static ListenerList<IRubyEditorListener> doSetInputListeners = new ListenerList<>();
 
 	public static void addListener(IRubyEditorListener listener) {
 		doSetInputListeners.add(listener);
@@ -136,9 +135,7 @@
 	}
 
 	protected void notifyDoSetInput(IModelElement element) {
-		Object[] listeners2 = doSetInputListeners.getListeners();
-		for (int i = 0; i < listeners2.length; i++) {
-			IRubyEditorListener listener = (IRubyEditorListener) listeners2[i];
+		for (IRubyEditorListener listener : doSetInputListeners) {
 			if (listener != null) {
 				listener.notifyDoSetInput(element);
 			}