Generify o.e.dltk.ruby.core.
Handle toArray cases in src.
Change-Id: I27427259f5b6646a3be6917f6662b1bc7e51f597
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
diff --git a/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/internal/callhierarchy/RubyCallProcessor.java b/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/internal/callhierarchy/RubyCallProcessor.java
index b6cd248..f70134c 100644
--- a/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/internal/callhierarchy/RubyCallProcessor.java
+++ b/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/internal/callhierarchy/RubyCallProcessor.java
@@ -16,7 +16,6 @@
import org.eclipse.dltk.ast.references.SimpleReference;
import org.eclipse.dltk.core.ICallProcessor;
import org.eclipse.dltk.core.IModelElement;
-import org.eclipse.dltk.core.ISourceModule;
import org.eclipse.dltk.core.search.IDLTKSearchConstants;
import org.eclipse.dltk.core.search.IDLTKSearchScope;
import org.eclipse.dltk.core.search.SearchEngine;
diff --git a/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/internal/callhierarchy/RubyCalleeProcessor.java b/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/internal/callhierarchy/RubyCalleeProcessor.java
index bbbef7e..2579f2a 100644
--- a/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/internal/callhierarchy/RubyCalleeProcessor.java
+++ b/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/internal/callhierarchy/RubyCalleeProcessor.java
@@ -1,11 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2005, 2007 IBM Corporation and others.
+ * Copyright (c) 2005, 2016 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.callhierarchy;
@@ -87,7 +86,7 @@
public IMethod[] findMethods(final String methodName, int argCount,
int sourcePosition) {
- final List methods = new ArrayList();
+ final List<IMethod> methods = new ArrayList<IMethod>();
ISourceModule module = this.method.getSourceModule();
try {
IModelElement[] elements = module.codeSelect(sourcePosition, /*
@@ -98,14 +97,14 @@
1);
for (int i = 0; i < elements.length; ++i) {
if (elements[i] instanceof IMethod) {
- methods.add(elements[i]);
+ methods.add((IMethod) elements[i]);
}
}
} catch (ModelException e) {
e.printStackTrace();
}
- return (IMethod[]) methods.toArray(new IMethod[methods.size()]);
+ return methods.toArray(new IMethod[methods.size()]);
}
protected void search(String patternString, int searchFor, int limitTo,
diff --git a/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/internal/core/codeassist/RubyCompletionEngine.java b/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/internal/core/codeassist/RubyCompletionEngine.java
index 2ef556f..ddf8c00 100644
--- a/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/internal/core/codeassist/RubyCompletionEngine.java
+++ b/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/internal/core/codeassist/RubyCompletionEngine.java
@@ -426,7 +426,7 @@
IMixinSearchRequestor {
private String lastParent = null;
private boolean lastParentIsSuperClass = true;
- private final List group = new ArrayList();
+ private final List<RubyMixinMethod> group = new ArrayList<RubyMixinMethod>();
private final RubyMixinClass klass;
private final boolean isSelf;
@@ -499,8 +499,7 @@
public void flush() {
if (group.size() > 0) {
- RubyMixinMethod[] mixinMethods = (RubyMixinMethod[]) group
- .toArray(new RubyMixinMethod[group.size()]);
+ RubyMixinMethod[] mixinMethods = group.toArray(new RubyMixinMethod[group.size()]);
final List methods = RubyModelUtils.getAllSourceMethods(
mixinMethods, klass);
int skew = 0;
diff --git a/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/internal/core/codeassist/RubyKeyword.java b/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/internal/core/codeassist/RubyKeyword.java
index a1647e6..71e0aec 100644
--- a/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/internal/core/codeassist/RubyKeyword.java
+++ b/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/internal/core/codeassist/RubyKeyword.java
@@ -1,15 +1,11 @@
/*******************************************************************************
- * Copyright (c) 2005, 2007 IBM Corporation and others.
+ * Copyright (c) 2005, 2016 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.core.codeassist;
import java.util.ArrayList;
@@ -23,11 +19,11 @@
"sub", "sub!", "gsub", "gsub!", "scan", "index", "match", "require" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
public static String[] findByPrefix (String prefix) {
- List result = new ArrayList ();
+ List<String> result = new ArrayList<String> ();
for (int i = 0; i < sKeywords.length; i++) {
if (sKeywords[i].startsWith(prefix))
result.add(sKeywords[i]);
}
- return (String[]) result.toArray(new String[result.size()]);
+ return result.toArray(new String[result.size()]);
}
}
diff --git a/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/internal/core/codeassist/RubySelectionEngine.java b/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/internal/core/codeassist/RubySelectionEngine.java
index f46d9cb..e43d77e 100644
--- a/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/internal/core/codeassist/RubySelectionEngine.java
+++ b/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/internal/core/codeassist/RubySelectionEngine.java
@@ -83,7 +83,7 @@
protected int actualSelectionEnd;
- private Set selectionElements = new HashSet();
+ private Set<IModelElement> selectionElements = new HashSet<IModelElement>();
private RubySelectionParser parser = new RubySelectionParser();
@@ -179,8 +179,7 @@
RubyPlugin.log(e);
}
- return (IModelElement[]) selectionElements
- .toArray(new IModelElement[selectionElements.size()]);
+ return selectionElements.toArray(new IModelElement[selectionElements.size()]);
}
private void selectOnSuper(ModuleDeclaration parsedUnit,
@@ -248,7 +247,7 @@
RubyMixinElementInfo info = (RubyMixinElementInfo) eObjects[i];
Object obj = info.getObject();
if (obj instanceof IModelElement) {
- this.selectionElements.add(obj);
+ this.selectionElements.add((IModelElement) obj);
}
}
}
diff --git a/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/internal/parser/mixin/AliasedRubyMixinMethod.java b/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/internal/parser/mixin/AliasedRubyMixinMethod.java
index c75356a..6c844ff 100644
--- a/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/internal/parser/mixin/AliasedRubyMixinMethod.java
+++ b/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/internal/parser/mixin/AliasedRubyMixinMethod.java
@@ -58,16 +58,15 @@
@Override
public RubyMixinVariable[] getVariables() {
- List result = new ArrayList();
+ List<RubyMixinVariable> result = new ArrayList<RubyMixinVariable>();
IMixinElement mixinElement = model.getRawModel().get(alias.getOldKey());
IMixinElement[] children = mixinElement.getChildren();
for (int i = 0; i < children.length; i++) {
IRubyMixinElement element = model.createRubyElement(children[i]);
if (element instanceof RubyMixinVariable)
- result.add(element);
+ result.add((RubyMixinVariable) element);
}
- return (RubyMixinVariable[]) result
- .toArray(new RubyMixinVariable[result.size()]);
+ return result.toArray(new RubyMixinVariable[result.size()]);
}
}
diff --git a/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/internal/parser/mixin/RubyMixinClass.java b/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/internal/parser/mixin/RubyMixinClass.java
index 5623732..27b12a9 100644
--- a/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/internal/parser/mixin/RubyMixinClass.java
+++ b/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/internal/parser/mixin/RubyMixinClass.java
@@ -1,11 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2005, 2007 IBM Corporation and others.
+ * Copyright (c) 2005, 2016 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.parser.mixin;
@@ -84,7 +83,7 @@
}
public IType[] getSourceTypes() {
- List result = new ArrayList();
+ List<IType> result = new ArrayList<IType>();
IMixinElement mixinElement = model.getRawModel().get(key);
Object[] allObjects = mixinElement.getAllObjects();
for (int i = 0; i < allObjects.length; i++) {
@@ -94,10 +93,10 @@
if (info.getKind() == RubyMixinElementInfo.K_CLASS
|| info.getKind() == RubyMixinElementInfo.K_MODULE) {
if (info.getObject() != null)
- result.add(info.getObject());
+ result.add((IType) info.getObject());
}
}
- return (IType[]) result.toArray(new IType[result.size()]);
+ return result.toArray(new IType[result.size()]);
}
public RubyMixinClass getSuperclass() {
@@ -173,7 +172,7 @@
IMixinElement mixinElement = model.getRawModel().get(key);
if (mixinElement == null)
return new RubyMixinClass[0];
- List result = new ArrayList();
+ List<RubyMixinClass> result = new ArrayList<RubyMixinClass>();
HashSet names = new HashSet();
Object[] allObjects = mixinElement.getAllObjects();
for (int i = 0; i < allObjects.length; i++) {
@@ -192,12 +191,11 @@
// TODO if element is not found - try to use different path
// combinations
if (element instanceof RubyMixinClass)
- result.add(element);
+ result.add((RubyMixinClass) element);
}
}
}
- return (RubyMixinClass[]) result.toArray(new RubyMixinClass[result
- .size()]);
+ return result.toArray(new RubyMixinClass[result.size()]);
}
/**
@@ -209,7 +207,7 @@
IMixinElement mixinElement = model.getRawModel().get(key);
if (mixinElement == null)
return new RubyMixinClass[0];
- List result = new ArrayList();
+ List<RubyMixinClass> result = new ArrayList<RubyMixinClass>();
HashSet names = new HashSet();
Object[] allObjects = mixinElement.getAllObjects();
for (int i = 0; i < allObjects.length; i++) {
@@ -225,12 +223,11 @@
extKey += RubyMixin.INSTANCE_SUFFIX;
IRubyMixinElement element = model.createRubyElement(extKey);
if (element instanceof RubyMixinClass)
- result.add(element);
+ result.add((RubyMixinClass) element);
}
}
}
- return (RubyMixinClass[]) result.toArray(new RubyMixinClass[result
- .size()]);
+ return result.toArray(new RubyMixinClass[result.size()]);
}
public void findMethods(IMixinSearchPattern pattern,
@@ -296,7 +293,7 @@
}
public RubyMixinMethod[] findMethods(IMixinSearchPattern pattern) {
- final List result = new ArrayList();
+ final List<RubyMixinMethod> result = new ArrayList<RubyMixinMethod>();
this.findMethods(pattern, new IMixinSearchRequestor() {
final Set names = new HashSet();
@@ -310,8 +307,7 @@
}
}, new HashSet());
- return (RubyMixinMethod[]) result.toArray(new RubyMixinMethod[result
- .size()]);
+ return result.toArray(new RubyMixinMethod[result.size()]);
}
public RubyMixinMethod getMethod(String name) {
@@ -368,26 +364,25 @@
}
public RubyMixinClass[] getClasses() {
- List result = new ArrayList();
+ List<RubyMixinClass> result = new ArrayList<RubyMixinClass>();
IMixinElement mixinElement = model.getRawModel().get(key);
IMixinElement[] children = mixinElement.getChildren();
for (int i = 0; i < children.length; i++) {
IRubyMixinElement element = model.createRubyElement(children[i]);
if (element instanceof RubyMixinClass)
- result.add(element);
+ result.add((RubyMixinClass) element);
}
- return (RubyMixinClass[]) result.toArray(new RubyMixinClass[result
- .size()]);
+ return result.toArray(new RubyMixinClass[result.size()]);
}
public RubyMixinVariable[] getFields() {
- List result = new ArrayList();
+ List<RubyMixinVariable> result = new ArrayList<RubyMixinVariable>();
IMixinElement mixinElement = model.getRawModel().get(key);
IMixinElement[] children = mixinElement.getChildren();
for (int i = 0; i < children.length; i++) {
IRubyMixinElement element = model.createRubyElement(children[i]);
if (element instanceof RubyMixinVariable)
- result.add(element);
+ result.add((RubyMixinVariable) element);
}
RubyMixinClass superclass = getSuperclass();
if (superclass != null && superclass.key != "Object" //$NON-NLS-1$
@@ -398,8 +393,7 @@
result.addAll(Arrays.asList(superFields));
}
- return (RubyMixinVariable[]) result
- .toArray(new RubyMixinVariable[result.size()]);
+ return result.toArray(new RubyMixinVariable[result.size()]);
}
}
diff --git a/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/internal/parser/mixin/RubyMixinMethod.java b/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/internal/parser/mixin/RubyMixinMethod.java
index b39389f..867e830 100644
--- a/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/internal/parser/mixin/RubyMixinMethod.java
+++ b/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/internal/parser/mixin/RubyMixinMethod.java
@@ -83,28 +83,28 @@
final IMixinElement mixinElement = model.getRawModel().get(key);
if (mixinElement != null) {
final Object[] allObjects = mixinElement.getAllObjects();
- final List result = new ArrayList();
+ final List<IMethod> result = new ArrayList<IMethod>();
for (int i = 0; i < allObjects.length; i++) {
RubyMixinElementInfo info = (RubyMixinElementInfo) allObjects[i];
if (info.getKind() == RubyMixinElementInfo.K_METHOD) {
- result.add(info.getObject());
+ result.add((IMethod) info.getObject());
}
}
- return (IMethod[]) result.toArray(new IMethod[result.size()]);
+ return result.toArray(new IMethod[result.size()]);
}
return new IMethod[0];
}
public RubyMixinVariable[] getVariables() {
- List result = new ArrayList();
+ List<RubyMixinVariable> result = new ArrayList<RubyMixinVariable>();
IMixinElement mixinElement = model.getRawModel().get(key);
IMixinElement[] children = mixinElement.getChildren();
for (int i = 0; i < children.length; i++) {
IRubyMixinElement element = model.createRubyElement(children[i]);
if (element instanceof RubyMixinVariable)
- result.add(element);
+ result.add((RubyMixinVariable) element);
}
- return (RubyMixinVariable[]) result
+ return result
.toArray(new RubyMixinVariable[result.size()]);
}
diff --git a/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/internal/parser/mixin/RubyMixinVariable.java b/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/internal/parser/mixin/RubyMixinVariable.java
index dc7b36c..fcf6cb3 100644
--- a/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/internal/parser/mixin/RubyMixinVariable.java
+++ b/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/internal/parser/mixin/RubyMixinVariable.java
@@ -1,11 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2005, 2007 IBM Corporation and others.
+ * Copyright (c) 2005, 2016 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.parser.mixin;
@@ -31,16 +30,16 @@
}
public IField[] getSourceFields () {
- List result = new ArrayList ();
+ List<IField> result = new ArrayList<IField> ();
IMixinElement mixinElement = model.getRawModel().get(key);
Object[] allObjects = mixinElement.getAllObjects();
for (int i = 0; i < allObjects.length; i++) {
RubyMixinElementInfo info = (RubyMixinElementInfo) allObjects[i];
if (info.getKind() == RubyMixinElementInfo.K_VARIABLE) {
- result.add (info.getObject());
+ result.add ((IField) info.getObject());
}
}
- return (IField[]) result.toArray(new IField[result.size()]);
+ return result.toArray(new IField[result.size()]);
}
diff --git a/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/internal/typehierarchy/RubyTypeHierarchyEngine.java b/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/internal/typehierarchy/RubyTypeHierarchyEngine.java
index 0d1712a..fde96ea 100644
--- a/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/internal/typehierarchy/RubyTypeHierarchyEngine.java
+++ b/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/internal/typehierarchy/RubyTypeHierarchyEngine.java
@@ -29,7 +29,7 @@
public static IType[] locateSuperTypes( IType type, IProgressMonitor monitor ) {
try {
String[] superTypes = type.getSuperClasses();
- List types = new ArrayList();
+ List<IType> types = new ArrayList<IType>();
if (superTypes != null) {
monitor.beginTask(Messages.RubyTypeHierarchyEngine_collectingTypes, superTypes.length);
IDLTKSearchScope scope = SearchEngine.createWorkspaceScope(DLTKLanguageManager.getLanguageToolkit(type));
@@ -46,7 +46,7 @@
}
}
}
- return (IType[])types.toArray(new IType[types.size()]);
+ return types.toArray(new IType[types.size()]);
} catch (ModelException e) {
e.printStackTrace();
} catch (CoreException e) {
@@ -84,14 +84,14 @@
private static class SearchRequestor extends TypeNameMatchRequestor {
private volatile boolean fStop;
- private List fResult;
+ private List<TypeNameMatch> fResult;
public SearchRequestor() {
super();
- fResult= new ArrayList(5);
+ fResult= new ArrayList<TypeNameMatch>(5);
}
public TypeNameMatch[] getResult() {
- return (TypeNameMatch[])fResult.toArray(new TypeNameMatch[fResult.size()]);
+ return fResult.toArray(new TypeNameMatch[fResult.size()]);
}
public void cancel() {
fStop= true;
diff --git a/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/typeinference/LocalVariableInfo.java b/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/typeinference/LocalVariableInfo.java
index 7178118..8312ec2 100644
--- a/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/typeinference/LocalVariableInfo.java
+++ b/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/typeinference/LocalVariableInfo.java
@@ -1,15 +1,11 @@
/*******************************************************************************
- * Copyright (c) 2005, 2007 IBM Corporation and others.
+ * Copyright (c) 2005, 2016 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.typeinference;
import java.util.List;
@@ -112,8 +108,8 @@
this.conditionalAssignments = conditionalAssignments;
}
- public void setConditionalAssignments(List conditionalAssignments) {
- this.conditionalAssignments = (RubyAssignment[]) conditionalAssignments
+ public void setConditionalAssignments(List<RubyAssignment> conditionalAssignments) {
+ this.conditionalAssignments = conditionalAssignments
.toArray(new RubyAssignment[conditionalAssignments.size()]);
}
diff --git a/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/typeinference/RubyEvaluatorFactory.java b/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/typeinference/RubyEvaluatorFactory.java
index e54eb49..f4a2f86 100644
--- a/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/typeinference/RubyEvaluatorFactory.java
+++ b/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/typeinference/RubyEvaluatorFactory.java
@@ -41,7 +41,7 @@
}
static {
- List factories = new ArrayList();
+ List<FactoryInfo> factories = new ArrayList<FactoryInfo>();
IConfigurationElement[] elements = Platform.getExtensionRegistry()
.getConfigurationElementsFor(GOAL_EVALUATOR_FACTORIES_EXT);
for (int i = 0; i < elements.length; i++) {
@@ -56,15 +56,11 @@
e.printStackTrace();
}
}
- f = (FactoryInfo[]) factories.toArray(new FactoryInfo[factories.size()]);
- Arrays.sort(f, new Comparator() {
-
- public int compare(Object arg0, Object arg1) {
- FactoryInfo f1 = (FactoryInfo) arg0;
- FactoryInfo f2 = (FactoryInfo) arg1;
+ f = factories.toArray(new FactoryInfo[factories.size()]);
+ Arrays.sort(f, new Comparator<FactoryInfo>() {
+ public int compare(FactoryInfo f1, FactoryInfo f2) {
return f2.priority - f1.priority;
}
-
});
}
diff --git a/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/typeinference/RubyModelUtils.java b/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/typeinference/RubyModelUtils.java
index de6bd3f..74aded9 100644
--- a/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/typeinference/RubyModelUtils.java
+++ b/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/typeinference/RubyModelUtils.java
@@ -188,7 +188,7 @@
ISourceModule modelModule, ModuleDeclaration parsedUnit,
String prefix, int position) {
Assert.isNotNull(prefix);
- List result = new ArrayList();
+ List<IField> result = new ArrayList<IField>();
String[] keys = RubyTypeInferencingUtils.getModelStaticScopesKeys(
rubyModel.getRawModel(), parsedUnit, position);
@@ -244,7 +244,7 @@
}
}
- return (IField[]) result.toArray(new IField[result.size()]);
+ return result.toArray(new IField[result.size()]);
}
/**
@@ -326,7 +326,7 @@
org.eclipse.dltk.core.ISourceModule modelModule,
ModuleDeclaration moduleDeclaration, IEvaluatedType type,
String prefix) {
- List result = new ArrayList();
+ List<IMethod> result = new ArrayList<IMethod>();
if (type instanceof RubyClassType) {
RubyClassType rubyClassType = (RubyClassType) type;
RubyMixinClass rubyClass = mixinModel
@@ -348,7 +348,7 @@
}
}
}
- return (IMethod[]) result.toArray(new IMethod[result.size()]);
+ return result.toArray(new IMethod[result.size()]);
}
public static IMethod[] searchClassMethodsExact(
@@ -356,7 +356,7 @@
org.eclipse.dltk.core.ISourceModule modelModule,
ModuleDeclaration moduleDeclaration, IEvaluatedType type,
String methodName) {
- List result = new ArrayList();
+ List<IMethod> result = new ArrayList<IMethod>();
if (type instanceof RubyClassType) {
RubyClassType rubyClassType = (RubyClassType) type;
RubyMixinClass rubyClass = mixinModel
@@ -378,7 +378,7 @@
}
}
}
- return (IMethod[]) result.toArray(new IMethod[result.size()]);
+ return result.toArray(new IMethod[result.size()]);
}
private static void addVariablesFrom(RubyMixinVariable[] fields2,
@@ -466,22 +466,21 @@
public static FakeMethod[] getFakeMethods(ModelElement parent, String klass) {
Metaclass metaclass = BuiltinMethodsDatabase.get(klass);
if (metaclass != null) {
- List fakeMethods = new ArrayList();
+ List<FakeMethod> fakeMethods = new ArrayList<FakeMethod>();
addFakeMethods(parent, metaclass, fakeMethods);
- return (FakeMethod[]) fakeMethods
- .toArray(new FakeMethod[fakeMethods.size()]);
+ return fakeMethods.toArray(new FakeMethod[fakeMethods.size()]);
}
// XXX the following code is legacy
String[] names = getBuiltinMethodNames(klass);
if (names == null)
return new FakeMethod[0];
- List methods = new ArrayList();
+ List<FakeMethod> methods = new ArrayList<FakeMethod>();
for (int i = 0; i < names.length; i++) {
FakeMethod method = new FakeMethod(parent, names[i]);
method.setReceiver(klass);
methods.add(method);
}
- return (FakeMethod[]) methods.toArray(new FakeMethod[methods.size()]);
+ return methods.toArray(new FakeMethod[methods.size()]);
}
private static void addFakeMethods(ModelElement parent,
@@ -535,21 +534,20 @@
Metaclass metaclass = BuiltinMethodsDatabase.get(klass);
if (metaclass != null) {
ClassMetaclass metaMetaclass = metaclass.getMetaClass();
- List fakeMethods = new ArrayList();
+ List<FakeMethod> fakeMethods = new ArrayList<FakeMethod>();
addFakeMethods(parent, metaMetaclass, fakeMethods);
- return (FakeMethod[]) fakeMethods
- .toArray(new FakeMethod[fakeMethods.size()]);
+ return fakeMethods.toArray(new FakeMethod[fakeMethods.size()]);
}
String[] names = getBuiltinMetaMethodNames(klass);
if (names == null)
return new FakeMethod[0];
- List methods = new ArrayList();
+ List<FakeMethod> methods = new ArrayList<FakeMethod>();
for (int i = 0; i < names.length; i++) {
FakeMethod method = new FakeMethod(parent, names[i]);
method.setReceiver(klass);
methods.add(method);
}
- return (FakeMethod[]) methods.toArray(new FakeMethod[methods.size()]);
+ return methods.toArray(new FakeMethod[methods.size()]);
}
public static String[] getBuiltinMethodNames(String klass) {
@@ -578,7 +576,7 @@
public static IType[] findTopLevelTypes(ISourceModule module,
String namePrefix) {
- List result = new ArrayList();
+ List<IType> result = new ArrayList<IType>();
try {
// TODO: add handling of "require"
@@ -586,36 +584,36 @@
for (int i = 0; i < children.length; i++) {
if (children[i] instanceof IType
&& children[i].getElementName().startsWith(namePrefix))
- result.add(children[i]);
+ result.add((IType) children[i]);
}
} catch (ModelException e) {
e.printStackTrace();
}
- return (IType[]) result.toArray(new IType[result.size()]);
+ return result.toArray(new IType[result.size()]);
}
public static IField[] findTopLevelFields(ISourceModule module,
String namePrefix) {
- List result = new ArrayList();
+ List<IField> result = new ArrayList<IField>();
try {
IModelElement[] children = module.getChildren();
for (int i = 0; i < children.length; i++) {
if (children[i] instanceof IField
&& children[i].getElementName().startsWith(namePrefix))
- result.add(children[i]);
+ result.add((IField) children[i]);
}
} catch (ModelException e) {
e.printStackTrace();
}
- return (IField[]) result.toArray(new IField[result.size()]);
+ return result.toArray(new IField[result.size()]);
}
public static IMethod[] findTopLevelMethods(IScriptProject project,
String namePattern) {
- final List result = new ArrayList();
+ final List<IMethod> result = new ArrayList<IMethod>();
SearchRequestor requestor = new SearchRequestor() {
@Override
@@ -650,7 +648,7 @@
e.printStackTrace();
}
- return (IMethod[]) result.toArray(new IMethod[result.size()]);
+ return result.toArray(new IMethod[result.size()]);
}
/**
diff --git a/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/typeinference/RubyTypeInferencingUtils.java b/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/typeinference/RubyTypeInferencingUtils.java
index 289de62..546c5f9 100644
--- a/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/typeinference/RubyTypeInferencingUtils.java
+++ b/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/typeinference/RubyTypeInferencingUtils.java
@@ -63,7 +63,7 @@
* Searches all top level types, which starts with prefix
*/
public static IType[] getAllTypes(ISourceModule module, String prefix) {
- final List types = new ArrayList();
+ final List<IType> types = new ArrayList<IType>();
TypeNameMatchRequestor requestor = new TypeNameMatchRequestor() {
@@ -80,12 +80,12 @@
ScriptModelUtil.searchTypeDeclarations(module.getScriptProject(),
prefix + "*", requestor); //$NON-NLS-1$
- return (IType[]) types.toArray(new IType[types.size()]);
+ return types.toArray(new IType[types.size()]);
}
public static ASTNode[] getAllStaticScopes(ModuleDeclaration rootNode,
final int requestedOffset) {
- final Collection scopes = new ArrayList();
+ final Collection<ASTNode> scopes = new ArrayList<ASTNode>();
ASTVisitor visitor = new OffsetTargetedASTVisitor(requestedOffset) {
@Override
public boolean visitInteresting(MethodDeclaration s) {
@@ -128,7 +128,7 @@
}
if (scopes.size() == 0)
scopes.add(rootNode);
- return (ASTNode[]) scopes.toArray(new ASTNode[scopes.size()]);
+ return scopes.toArray(new ASTNode[scopes.size()]);
}
public static IMixinElement[] getModelStaticScopes(MixinModel model,
@@ -209,7 +209,7 @@
public static RubyAssignment[] findLocalVariableAssignments(
final ASTNode scope, final ASTNode nextScope, final String varName) {
- final Collection assignments = new ArrayList();
+ final Collection<RubyAssignment> assignments = new ArrayList<RubyAssignment>();
ASTVisitor visitor = new ASTVisitor() {
@Override
@@ -249,8 +249,7 @@
} catch (Exception e) {
RubyPlugin.log(e);
}
- return (RubyAssignment[]) assignments
- .toArray(new RubyAssignment[assignments.size()]);
+ return assignments.toArray(new RubyAssignment[assignments.size()]);
}
public static boolean isRootLocalScope(ASTNode node) {
@@ -260,12 +259,11 @@
}
public static IEvaluatedType combineTypes(Collection evaluaedTypes) {
- Set types = new HashSet(evaluaedTypes);
+ Set<IEvaluatedType> types = new HashSet<IEvaluatedType>(evaluaedTypes);
types.remove(null);
if (types.size() > 1 && types.contains(RecursionTypeCall.INSTANCE))
types.remove(RecursionTypeCall.INSTANCE);
- return combineUniqueTypes((IEvaluatedType[]) types
- .toArray(new IEvaluatedType[types.size()]));
+ return combineUniqueTypes(types.toArray(new IEvaluatedType[types.size()]));
}
private static IEvaluatedType combineUniqueTypes(IEvaluatedType[] types) {
@@ -338,7 +336,7 @@
}
- private List assignements;
+ private List<VariableAssignment> assignements;
private Stack level = new Stack();
private int maxLevel;
@@ -352,7 +350,7 @@
this.root = root;
this.offset = offset;
this.maxLevel = 0;
- this.assignements = new ArrayList();
+ this.assignements = new ArrayList<VariableAssignment>();
this.level.clear();
}
@@ -398,7 +396,7 @@
}
public RubyAssignment getUnconditionalAssignment() {
- VariableAssignment[] array = (VariableAssignment[]) assignements
+ VariableAssignment[] array = assignements
.toArray(new VariableAssignment[assignements.size()]);
for (int i = array.length - 1; i >= 0; i--) {
VariableAssignment a = array[i];
diff --git a/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/typeinference/evaluators/CaseStatementTypeEvaluator.java b/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/typeinference/evaluators/CaseStatementTypeEvaluator.java
index be12afa..899b143 100644
--- a/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/typeinference/evaluators/CaseStatementTypeEvaluator.java
+++ b/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/typeinference/evaluators/CaseStatementTypeEvaluator.java
@@ -40,14 +40,14 @@
if (!(expression instanceof RubyCaseStatement))
return IGoal.NO_GOALS;
RubyCaseStatement caseSt = (RubyCaseStatement) expression;
- List subgoals = new ArrayList();
+ List<IGoal> subgoals = new ArrayList<IGoal>();
List whens = caseSt.getWhens();
for (Iterator iterator = whens.iterator(); iterator.hasNext();) {
RubyWhenStatement when = (RubyWhenStatement) iterator.next();
ASTNode body = when.getBody();
subgoals.add(new ExpressionTypeGoal(this.goal.getContext(), body));
}
- return (IGoal[]) subgoals.toArray(new IGoal[subgoals.size()]);
+ return subgoals.toArray(new IGoal[subgoals.size()]);
}
@Override
diff --git a/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/typeinference/evaluators/RubyVariableTypeEvaluator.java b/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/typeinference/evaluators/RubyVariableTypeEvaluator.java
index f6ed73c..79b2f73 100644
--- a/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/typeinference/evaluators/RubyVariableTypeEvaluator.java
+++ b/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/typeinference/evaluators/RubyVariableTypeEvaluator.java
@@ -31,7 +31,7 @@
public class RubyVariableTypeEvaluator extends GoalEvaluator {
- private List possibilities = new ArrayList();
+ private List<IGoal> possibilities = new ArrayList<IGoal>();
private List results = new ArrayList();
private boolean init = false;
@@ -88,8 +88,7 @@
}
}
}
- return (IGoal[]) possibilities.toArray(new IGoal[possibilities
- .size()]);
+ return possibilities.toArray(new IGoal[possibilities.size()]);
} else {
if (result != null)
results.add(result);
diff --git a/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/typeinference/evaluators/VariableReferenceEvaluator.java b/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/typeinference/evaluators/VariableReferenceEvaluator.java
index 5b51ea2..6876da0 100644
--- a/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/typeinference/evaluators/VariableReferenceEvaluator.java
+++ b/plugins/org.eclipse.dltk.ruby.core/src/org/eclipse/dltk/ruby/typeinference/evaluators/VariableReferenceEvaluator.java
@@ -108,7 +108,7 @@
info = RubyTypeInferencingUtils.inspectLocalVariable(rootNode,
expression.sourceStart(), varName);
- List poss = new ArrayList();
+ List<IGoal> poss = new ArrayList<IGoal>();
if (info != null) {
if (info.getLastAssignment() != null
@@ -149,7 +149,7 @@
}
}
- return (IGoal[]) poss.toArray(new IGoal[poss.size()]);
+ return poss.toArray(new IGoal[poss.size()]);
} else {
IEvaluatedType selfClass = RubyTypeInferencingUtils
@@ -161,7 +161,7 @@
ref.getName(), selfKey, ref.getVariableKind()) };
} else if (selfClass instanceof AmbiguousType) {
AmbiguousType ambiType = (AmbiguousType) selfClass;
- List goalList = new ArrayList();
+ List<IGoal> goalList = new ArrayList<IGoal>();
IEvaluatedType[] possibleTypes = ambiType.getPossibleTypes();
for (int cnt = 0, max = possibleTypes.length; cnt < max; cnt++) {
if (possibleTypes[cnt] instanceof RubyClassType) {
@@ -171,7 +171,7 @@
ref.getName(), selfKey, ref.getVariableKind()));
}
}
- return (IGoal[]) goalList.toArray(new IGoal[goalList.size()]);
+ return goalList.toArray(new IGoal[goalList.size()]);
}
}
return IGoal.NO_GOALS;
@@ -240,7 +240,7 @@
@Override
public IGoal[] subGoalDone(IGoal subgoal, Object result, GoalState state) {
if (subgoal == callsGoal) {
- List possibles = new ArrayList();
+ List<IGoal> possibles = new ArrayList<IGoal>();
if (result != null) {
ItemReference[] refs = (ItemReference[]) result;
for (int i = 0; i < refs.length; i++) { // TODO: for performance
@@ -269,7 +269,7 @@
}
}
}
- return (IGoal[]) possibles.toArray(new IGoal[possibles.size()]);
+ return possibles.toArray(new IGoal[possibles.size()]);
} else if ((result != null) && !(result instanceof UnknownType))
results.add(result);
return IGoal.NO_GOALS;