Generify o.e.dltk.ruby.testing.

Obvious stuff only.

Change-Id: I6e08b9931654d40f4688dd203c947cec82ec038f
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
diff --git a/plugins/org.eclipse.dltk.ruby.testing/src/org/eclipse/dltk/ruby/testing/internal/AbstractRubyTestRunnerUI.java b/plugins/org.eclipse.dltk.ruby.testing/src/org/eclipse/dltk/ruby/testing/internal/AbstractRubyTestRunnerUI.java
index e20f3a5..c5af7e4 100644
--- a/plugins/org.eclipse.dltk.ruby.testing/src/org/eclipse/dltk/ruby/testing/internal/AbstractRubyTestRunnerUI.java
+++ b/plugins/org.eclipse.dltk.ruby.testing/src/org/eclipse/dltk/ruby/testing/internal/AbstractRubyTestRunnerUI.java
@@ -97,13 +97,11 @@
 		return null;
 	}
 
-	/*
-	 * @see AbstractTestRunnerUI#getAdapter(java.lang.Class)
-	 */
+	@SuppressWarnings("unchecked")
 	@Override
-	public Object getAdapter(Class adapter) {
+	public <T> T getAdapter(Class<T> adapter) {
 		if (ITestElementResolver.class.equals(adapter)) {
-			return this;
+			return (T) this;
 		} else {
 			return super.getAdapter(adapter);
 		}
diff --git a/plugins/org.eclipse.dltk.ruby.testing/src/org/eclipse/dltk/ruby/testing/internal/AbstractTestingEngineValidateVisitor.java b/plugins/org.eclipse.dltk.ruby.testing/src/org/eclipse/dltk/ruby/testing/internal/AbstractTestingEngineValidateVisitor.java
index 9d63c34..542d7a5 100644
--- a/plugins/org.eclipse.dltk.ruby.testing/src/org/eclipse/dltk/ruby/testing/internal/AbstractTestingEngineValidateVisitor.java
+++ b/plugins/org.eclipse.dltk.ruby.testing/src/org/eclipse/dltk/ruby/testing/internal/AbstractTestingEngineValidateVisitor.java
@@ -32,7 +32,7 @@
 
 public class AbstractTestingEngineValidateVisitor extends ASTVisitor {
 
-	private final Stack stack = new Stack();
+	private final Stack<ASTNode> stack = new Stack<ASTNode>();
 
 	/**
 	 * @param call
@@ -56,7 +56,7 @@
 	 * @param nodeClass
 	 * @return
 	 */
-	protected boolean isNodeOnStack(Class nodeClass) {
+	protected boolean isNodeOnStack(Class<?> nodeClass) {
 		for (int i = stack.size(); --i >= 0;) {
 			if (nodeClass.isAssignableFrom(stack.get(i).getClass())) {
 				return true;
@@ -91,10 +91,10 @@
 		else {
 			String classKey = className.replaceAll("::", //$NON-NLS-1$
 					String.valueOf(IIndexConstants.SEPARATOR));
-			Set processedKeys = new HashSet();
-			for (Iterator iter = declaration.getSuperClassNames().iterator(); iter
+			Set<String> processedKeys = new HashSet<String>();
+			for (Iterator<String> iter = declaration.getSuperClassNames().iterator(); iter
 					.hasNext();) {
-				String superClass = (String) iter.next();
+				String superClass = iter.next();
 				RubyMixinModel model = RubyMixinModel.getInstance(module
 						.getScriptProject());
 				RubyMixinClass mixinClass = model
@@ -127,8 +127,7 @@
 
 	protected boolean isRequire(CallExpression call, String moduleName) {
 		if (isRequire(call)) {
-			final ASTNode argument = (ASTNode) call.getArgs().getChilds()
-					.get(0);
+			final ASTNode argument = call.getArgs().getChilds().get(0);
 			return isStringLiteralArgument(argument, moduleName);
 		}
 		return false;
diff --git a/plugins/org.eclipse.dltk.ruby.testing/src/org/eclipse/dltk/ruby/testing/internal/RubyTestingLaunchShortcut.java b/plugins/org.eclipse.dltk.ruby.testing/src/org/eclipse/dltk/ruby/testing/internal/RubyTestingLaunchShortcut.java
index a781fae..d53a409 100644
--- a/plugins/org.eclipse.dltk.ruby.testing/src/org/eclipse/dltk/ruby/testing/internal/RubyTestingLaunchShortcut.java
+++ b/plugins/org.eclipse.dltk.ruby.testing/src/org/eclipse/dltk/ruby/testing/internal/RubyTestingLaunchShortcut.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2008 xored software, Inc.
+ * Copyright (c) 2008, 2016 xored software, Inc.
  *
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
@@ -117,7 +117,7 @@
 					case IModelElement.SCRIPT_PROJECT: {
 						IProject project = ((IScriptProject) element)
 								.getProject();
-						List configs = new ArrayList();
+						List<ILaunchConfiguration> configs = new ArrayList<ILaunchConfiguration>();
 						IFolder specFolder = project.getFolder("test"); //$NON-NLS-1$
 						if (specFolder != null && specFolder.exists())
 							configs.add(findOrCreateLaunch(specFolder, mode));
@@ -126,7 +126,7 @@
 							configs.add(findOrCreateLaunch(specFolder, mode));
 						ILaunchConfiguration config = null;
 						if (configs.size() == 1) {
-							config = (ILaunchConfiguration) configs.get(0);
+							config = configs.get(0);
 						} else if (configs.size() > 1) {
 							config = chooseConfiguration(configs, mode);
 						}
@@ -332,7 +332,7 @@
 	 * @return ILaunchConfiguration
 	 * @throws InterruptedException
 	 */
-	private ILaunchConfiguration chooseConfiguration(List configList,
+	private ILaunchConfiguration chooseConfiguration(List<ILaunchConfiguration> configList,
 			String mode) throws InterruptedException {
 		IDebugModelPresentation labelProvider = DebugUITools
 				.newDebugModelPresentation();
@@ -494,7 +494,7 @@
 				.getLaunchConfigurations(configType);
 		String[] attributeToCompare = getAttributeNamesToCompare();
 
-		ArrayList candidateConfigs = new ArrayList(configs.length);
+		ArrayList<ILaunchConfiguration> candidateConfigs = new ArrayList<ILaunchConfiguration>(configs.length);
 		for (int i = 0; i < configs.length; i++) {
 			ILaunchConfiguration config = configs[i];
 			if (hasSameAttributes(config, temporary, attributeToCompare)) {
@@ -512,7 +512,7 @@
 		if (candidateCount == 0) {
 			return null;
 		} else if (candidateCount == 1) {
-			return (ILaunchConfiguration) candidateConfigs.get(0);
+			return candidateConfigs.get(0);
 		} else {
 			// Prompt the user to choose a config. A null result means the user
 			// cancelled the dialog, in which case this method returns null,
diff --git a/plugins/org.eclipse.dltk.ruby.testing/src/org/eclipse/dltk/ruby/testing/internal/RubyTestingMainLaunchConfigurationTab.java b/plugins/org.eclipse.dltk.ruby.testing/src/org/eclipse/dltk/ruby/testing/internal/RubyTestingMainLaunchConfigurationTab.java
index 79304ea..1c69aa2 100644
--- a/plugins/org.eclipse.dltk.ruby.testing/src/org/eclipse/dltk/ruby/testing/internal/RubyTestingMainLaunchConfigurationTab.java
+++ b/plugins/org.eclipse.dltk.ruby.testing/src/org/eclipse/dltk/ruby/testing/internal/RubyTestingMainLaunchConfigurationTab.java
@@ -68,7 +68,7 @@
 
 	private Button detect;
 	private Combo engineType;
-	private Map nameToId = new HashMap();
+	private Map<String, String> nameToId = new HashMap<String, String>();
 	private Label engineMessageLabel;
 	private Label engineMessageImageLabel;
 
@@ -198,7 +198,7 @@
 	}
 
 	private IModelElement chooseContainer(IModelElement initElement) {
-		Class[] acceptedClasses = new Class[] { IProjectFragment.class,
+		Class<?>[] acceptedClasses = new Class[] { IProjectFragment.class,
 				IScriptProject.class, IScriptFolder.class };
 		TypedElementSelectionValidator validator = new TypedElementSelectionValidator(
 				acceptedClasses, false) {
@@ -532,7 +532,7 @@
 	}
 
 	private String getEngineId() {
-		return (String) this.nameToId.get(this.engineType.getText());
+		return this.nameToId.get(this.engineType.getText());
 	}
 
 	@Override
diff --git a/plugins/org.eclipse.dltk.ruby.testing/src/org/eclipse/dltk/ruby/testing/internal/rspec/RSpecTestRunnerUI.java b/plugins/org.eclipse.dltk.ruby.testing/src/org/eclipse/dltk/ruby/testing/internal/rspec/RSpecTestRunnerUI.java
index baa05a8..192cac0 100644
--- a/plugins/org.eclipse.dltk.ruby.testing/src/org/eclipse/dltk/ruby/testing/internal/rspec/RSpecTestRunnerUI.java
+++ b/plugins/org.eclipse.dltk.ruby.testing/src/org/eclipse/dltk/ruby/testing/internal/rspec/RSpecTestRunnerUI.java
@@ -114,10 +114,10 @@
 			AbstractTestingEngineValidateVisitor {
 
 		protected ASTNode collectArgs(final CallArgumentsList args,
-				final List texts) {
+				final List<String> texts) {
 			ASTNode lastArg = null;
-			for (Iterator i = args.getChilds().iterator(); i.hasNext();) {
-				final Object arg = i.next();
+			for (Iterator<ASTNode> i = args.getChilds().iterator(); i.hasNext();) {
+				final ASTNode arg = i.next();
 				if (arg instanceof RubyCallArgument) {
 					final ASTNode value = ((RubyCallArgument) arg).getValue();
 					final String text = toText(value);
@@ -148,9 +148,9 @@
 		 * @param value
 		 * @return
 		 */
-		protected boolean isMatched(String value, List texts) {
+		protected boolean isMatched(String value, List<String> texts) {
 			final StringBuffer sb = new StringBuffer();
-			for (Iterator i = texts.iterator(); i.hasNext();) {
+			for (Iterator<String> i = texts.iterator(); i.hasNext();) {
 				if (sb.length() != 0) {
 					sb.append(' ');
 				}
@@ -190,7 +190,7 @@
 					if (isMethodCall(call, RSpecUtils.CONTEXT_METHODS)) {
 						final CallArgumentsList args = call.getArgs();
 						if (args.getChilds().size() >= 1) {
-							final List texts = new ArrayList();
+							final List<String> texts = new ArrayList<String>();
 							final ASTNode lastArg = collectArgs(args, texts);
 							if (!texts.isEmpty()
 									&& isMatched(contextName, texts)) {
@@ -230,7 +230,7 @@
 
 		}
 
-		private final Stack states = new Stack();
+		private final Stack<State> states = new Stack<State>();
 
 		@Override
 		public boolean visitGeneral(ASTNode node) throws Exception {
@@ -241,7 +241,7 @@
 					if (args.getChilds().size() >= 1) {
 						if (isMethodCall(call, RSpecUtils.CONTEXT_METHODS)) {
 							boolean matched = false;
-							final List texts = new ArrayList();
+							final List<String> texts = new ArrayList<String>();
 							final ASTNode lastArg = collectArgs(args, texts);
 							if (!texts.isEmpty()
 									&& isMatched(contextName, texts)) {
@@ -254,7 +254,7 @@
 							states.push(new State(node, matched));
 						} else if (isMatchingContext()
 								&& isMethodCall(call, RSpecUtils.TEST_METHODS)) {
-							final List texts = new ArrayList();
+							final List<String> texts = new ArrayList<String>();
 							final ASTNode lastArg = collectArgs(args, texts);
 							if (!texts.isEmpty() && isMatched(testName, texts)) {
 								assert (lastArg != null);
@@ -271,7 +271,7 @@
 
 		private boolean isMatchingContext() {
 			if (!states.isEmpty()) {
-				final State state = (State) states.peek();
+				final State state = states.peek();
 				return state.isMatched;
 			}
 			return false;
@@ -280,7 +280,7 @@
 		@Override
 		public void endvisitGeneral(ASTNode node) throws Exception {
 			if (!states.isEmpty()) {
-				final State state = (State) states.peek();
+				final State state = states.peek();
 				if (state.callNode == node) {
 					states.pop();
 				}
@@ -291,7 +291,7 @@
 
 	private static class MethodRequestor extends SearchRequestor {
 
-		final Set resources = new HashSet();
+		final Set<IResource> resources = new HashSet<IResource>();
 
 		@Override
 		public void acceptSearchMatch(SearchMatch match) throws CoreException {
@@ -305,7 +305,7 @@
 	@Override
 	protected TestElementResolution resolveTestSuite(ITestSuiteElement element) {
 		final ITestElement[] children = element.getChildren();
-		final Set locations = new HashSet();
+		final Set<String> locations = new HashSet<String>();
 		for (int i = 0; i < children.length; ++i) {
 			if (children[i] instanceof ITestCaseElement) {
 				final ITestCaseElement caseElement = (ITestCaseElement) children[i];
@@ -321,11 +321,11 @@
 				}
 			}
 		}
-		final Set processedResources = new HashSet();
+		final Set<IResource> processedResources = new HashSet<IResource>();
 		final RSpecContextLocator locator = new RSpecContextLocator(element
 				.getSuiteTypeName());
-		for (Iterator i = locations.iterator(); i.hasNext();) {
-			final ISourceModule module = findSourceModule((String) i.next());
+		for (Iterator<String> i = locations.iterator(); i.hasNext();) {
+			final ISourceModule module = findSourceModule(i.next());
 			if (module != null) {
 				if (module.getResource() != null) {
 					processedResources.add(module.getResource());
@@ -353,11 +353,11 @@
 
 	private TestElementResolution searchMethodReferences(
 			final IDLTKSearchScope scope, final RSpecContextLocator locator,
-			final String methodName, final Set processedResources) {
-		final Set describeReferences = findMethodReferences(scope, methodName);
+			final String methodName, final Set<IResource> processedResources) {
+		final Set<IResource> describeReferences = findMethodReferences(scope, methodName);
 		describeReferences.removeAll(processedResources);
-		for (Iterator i = describeReferences.iterator(); i.hasNext();) {
-			final IResource resource = (IResource) i.next();
+		for (Iterator<IResource> i = describeReferences.iterator(); i.hasNext();) {
+			final IResource resource = i.next();
 			if (resource instanceof IFile) {
 				final IFile file = (IFile) resource;
 				processedResources.add(file);
@@ -373,7 +373,7 @@
 		return null;
 	}
 
-	private Set findMethodReferences(final IDLTKSearchScope scope,
+	private Set<IResource> findMethodReferences(final IDLTKSearchScope scope,
 			final String methodName) {
 		final SearchPattern pattern = SearchPattern.createPattern(methodName,
 				IDLTKSearchConstants.METHOD, IDLTKSearchConstants.REFERENCES,
@@ -389,7 +389,7 @@
 			final String msg = "Error in search method references {0})"; //$NON-NLS-1$
 			RubyTestingPlugin.error(NLS.bind(msg, methodName), e);
 		}
-		final Set resources = requestor.resources;
+		final Set<IResource> resources = requestor.resources;
 		return resources;
 	}
 
diff --git a/plugins/org.eclipse.dltk.ruby.testing/src/org/eclipse/dltk/ruby/testing/internal/rspec/RspecTestingEngine.java b/plugins/org.eclipse.dltk.ruby.testing/src/org/eclipse/dltk/ruby/testing/internal/rspec/RspecTestingEngine.java
index 9db6d24..104b93f 100644
--- a/plugins/org.eclipse.dltk.ruby.testing/src/org/eclipse/dltk/ruby/testing/internal/rspec/RspecTestingEngine.java
+++ b/plugins/org.eclipse.dltk.ruby.testing/src/org/eclipse/dltk/ruby/testing/internal/rspec/RspecTestingEngine.java
@@ -81,7 +81,7 @@
 			super.endvisitGeneral(node);
 		}
 
-		private final Stack contextCalls = new Stack();
+		private final Stack<ASTNode> contextCalls = new Stack<ASTNode>();
 
 		public IStatus getStatus() {
 			if (weight >= REQUIRE_WEIGHT + TEST_WEIGHT) {
diff --git a/plugins/org.eclipse.dltk.ruby.testing/src/org/eclipse/dltk/ruby/testing/internal/testunit/TestUnitTestRunnerUI.java b/plugins/org.eclipse.dltk.ruby.testing/src/org/eclipse/dltk/ruby/testing/internal/testunit/TestUnitTestRunnerUI.java
index fd1cf22..2655039 100644
--- a/plugins/org.eclipse.dltk.ruby.testing/src/org/eclipse/dltk/ruby/testing/internal/testunit/TestUnitTestRunnerUI.java
+++ b/plugins/org.eclipse.dltk.ruby.testing/src/org/eclipse/dltk/ruby/testing/internal/testunit/TestUnitTestRunnerUI.java
@@ -162,20 +162,19 @@
 						.trim();
 			}
 			if (shouldName.length() != 0) {
-				final Set resources = new HashSet();
+				final Set<IFile> resources = new HashSet<IFile>();
 				for (Iterator i = types.iterator(); i.hasNext();) {
 					final IType type = (IType) i.next();
 					final IResource resource = type.getResource();
 					if (resource != null && resource instanceof IFile) {
-						resources.add(resource);
+						resources.add((IFile) resource);
 					}
 				}
 				if (resources.isEmpty()) {
 					return null;
 				}
-				for (Iterator i = resources.iterator(); i.hasNext();) {
-					final ISourceModule module = (ISourceModule) DLTKCore
-							.create((IFile) i.next());
+				for (Iterator<IFile> i = resources.iterator(); i.hasNext();) {
+					final ISourceModule module = (ISourceModule) DLTKCore.create(i.next());
 					final TestElementResolution resolution = findShould(module,
 							className, shouldName);
 					if (resolution != null) {
@@ -206,7 +205,7 @@
 			this.shouldName = shouldName;
 		}
 
-		final Stack typeMatches = new Stack();
+		final Stack<Boolean> typeMatches = new Stack<Boolean>();
 
 		@Override
 		public boolean visit(TypeDeclaration s) throws Exception {
@@ -229,7 +228,7 @@
 
 		private boolean isMatchedType() {
 			for (int i = 0, size = typeMatches.size(); i < size; ++i) {
-				Boolean value = (Boolean) typeMatches.get(i);
+				Boolean value = typeMatches.get(i);
 				if (value.booleanValue()) {
 					return true;
 				}
@@ -237,7 +236,7 @@
 			return false;
 		}
 
-		final Stack calls = new Stack();
+		final Stack<CallExpression> calls = new Stack<CallExpression>();
 
 		@Override
 		public boolean visitGeneral(ASTNode node) throws Exception {
@@ -292,7 +291,7 @@
 		 */
 		private boolean isShouldMatched(String value) {
 			for (int i = 0; i < calls.size(); ++i) {
-				final CallExpression call = (CallExpression) calls.get(i);
+				final CallExpression call = calls.get(i);
 				if (ShouldaUtils.SHOULD.equals(call.getName())) {
 					if (!startsWith(value, ShouldaUtils.SHOULD)) {
 						return false;
@@ -371,7 +370,7 @@
 	}
 
 	private static final class TypeSearchRequestor extends SearchRequestor {
-		final List types = new ArrayList();
+		final List<Object> types = new ArrayList<Object>();
 
 		@Override
 		public void acceptSearchMatch(SearchMatch match) throws CoreException {