generics
diff --git a/core/plugins/org.eclipse.dltk.formatter/src/org/eclipse/dltk/formatter/FormatterBlockNode.java b/core/plugins/org.eclipse.dltk.formatter/src/org/eclipse/dltk/formatter/FormatterBlockNode.java
index 8b2b474..5b58e48 100644
--- a/core/plugins/org.eclipse.dltk.formatter/src/org/eclipse/dltk/formatter/FormatterBlockNode.java
+++ b/core/plugins/org.eclipse.dltk.formatter/src/org/eclipse/dltk/formatter/FormatterBlockNode.java
@@ -13,7 +13,6 @@
import java.util.ArrayList;
import java.util.Collections;
-import java.util.Iterator;
import java.util.List;
public class FormatterBlockNode extends AbstractFormatterNode implements
@@ -26,12 +25,12 @@
super(document);
}
- private final List body = new ArrayList();
+ private final List<IFormatterNode> body = new ArrayList<IFormatterNode>();
- protected void acceptNodes(final List nodes, IFormatterContext context,
- IFormatterWriter visitor) throws Exception {
- for (Iterator i = nodes.iterator(); i.hasNext();) {
- IFormatterNode node = (IFormatterNode) i.next();
+ protected void acceptNodes(final List<IFormatterNode> nodes,
+ IFormatterContext context, IFormatterWriter visitor)
+ throws Exception {
+ for (IFormatterNode node : nodes) {
context.enter(node);
node.accept(context, visitor);
context.leave(node);
@@ -57,7 +56,7 @@
*/
public int getEndOffset() {
if (!body.isEmpty()) {
- return ((IFormatterNode) body.get(body.size() - 1)).getEndOffset();
+ return body.get(body.size() - 1).getEndOffset();
} else {
return DEFAULT_OFFSET;
}
@@ -68,7 +67,7 @@
*/
public int getStartOffset() {
if (!body.isEmpty()) {
- return ((IFormatterNode) body.get(0)).getStartOffset();
+ return body.get(0).getStartOffset();
} else {
return DEFAULT_OFFSET;
}
@@ -79,8 +78,7 @@
* org.eclipse.dltk.ruby.formatter.node.IFormatterContainerNode#isEmpty()
*/
public boolean isEmpty() {
- for (Iterator i = body.iterator(); i.hasNext();) {
- IFormatterNode node = (IFormatterNode) i.next();
+ for (IFormatterNode node : body) {
if (!node.isEmpty()) {
return false;
}
@@ -88,7 +86,7 @@
return true;
}
- public List getChildren() {
+ public List<IFormatterNode> getChildren() {
return Collections.unmodifiableList(body);
}
@@ -100,7 +98,7 @@
return true;
}
- public List getBody() {
+ public List<IFormatterNode> getBody() {
return body;
}
diff --git a/core/plugins/org.eclipse.dltk.formatter/src/org/eclipse/dltk/formatter/FormatterUtils.java b/core/plugins/org.eclipse.dltk.formatter/src/org/eclipse/dltk/formatter/FormatterUtils.java
index bbf3047..e1f4da5 100644
--- a/core/plugins/org.eclipse.dltk.formatter/src/org/eclipse/dltk/formatter/FormatterUtils.java
+++ b/core/plugins/org.eclipse.dltk.formatter/src/org/eclipse/dltk/formatter/FormatterUtils.java
@@ -69,10 +69,9 @@
return true;
}
- public static IFormatterTextNode[] toTextNodeArray(List list) {
+ public static IFormatterNode[] toTextNodeArray(List<IFormatterNode> list) {
if (list != null) {
- return (IFormatterTextNode[]) list
- .toArray(new IFormatterTextNode[list.size()]);
+ return list.toArray(new IFormatterNode[list.size()]);
} else {
return null;
}