| Index: compiler/java/com/google/dart/compiler/ast/DartUnit.java
|
| diff --git a/compiler/java/com/google/dart/compiler/ast/DartUnit.java b/compiler/java/com/google/dart/compiler/ast/DartUnit.java
|
| index 01c6b3df71f6463fe561166c472cf5f8b138d72f..fabd1aca4629bf334c789b6add249d1c81b4d4ac 100644
|
| --- a/compiler/java/com/google/dart/compiler/ast/DartUnit.java
|
| +++ b/compiler/java/com/google/dart/compiler/ast/DartUnit.java
|
| @@ -4,12 +4,9 @@
|
|
|
| package com.google.dart.compiler.ast;
|
|
|
| -import com.google.common.collect.Lists;
|
| import com.google.common.collect.Sets;
|
| import com.google.dart.compiler.DartSource;
|
|
|
| -import java.util.ArrayList;
|
| -import java.util.Collections;
|
| import java.util.List;
|
| import java.util.Set;
|
|
|
| @@ -21,22 +18,17 @@ public class DartUnit extends DartNode {
|
| private static final long serialVersionUID = -3407637869012712127L;
|
|
|
| private LibraryUnit library;
|
| - private List<DartDirective> directives;
|
| - private final List<DartNode> topLevelNodes = Lists.newArrayList();
|
| + private final NodeList<DartDirective> directives = NodeList.create(this);
|
| + private final NodeList<DartNode> topLevelNodes = NodeList.create(this);
|
| + private final NodeList<DartComment> comments = NodeList.create(this);
|
| private final DartSource source;
|
| private final boolean isDiet;
|
| - /** A list of comments. May be null. */
|
| - private List<DartComment> comments;
|
|
|
| public DartUnit(DartSource source, boolean isDiet) {
|
| this.source = source;
|
| this.isDiet = isDiet;
|
| }
|
|
|
| - public void addTopLevelNode(DartNode node) {
|
| - topLevelNodes.add(becomeParentOf(node));
|
| - }
|
| -
|
| public String getSourceName() {
|
| return source.getName();
|
| }
|
| @@ -46,19 +38,8 @@ public class DartUnit extends DartNode {
|
| return source;
|
| }
|
|
|
| - public void addComment(DartComment comment) {
|
| - if (comments == null) {
|
| - comments = new ArrayList<DartComment>();
|
| - }
|
| - comments.add(becomeParentOf(comment));
|
| - }
|
| -
|
| public List<DartComment> getComments() {
|
| - return comments == null ? null : Collections.unmodifiableList(comments);
|
| - }
|
| -
|
| - public boolean removeComment(DartComment comment) {
|
| - return comments == null ? false : comments.remove(comment);
|
| + return comments;
|
| }
|
|
|
| public void setLibrary(LibraryUnit library) {
|
| @@ -75,13 +56,9 @@ public class DartUnit extends DartNode {
|
|
|
| @Override
|
| public void visitChildren(ASTVisitor<?> visitor) {
|
| - if (directives != null) {
|
| - visitor.visit(directives);
|
| - }
|
| - visitor.visit(topLevelNodes);
|
| - if (comments != null) {
|
| - visitor.visit(comments);
|
| - }
|
| + directives.accept(visitor);
|
| + topLevelNodes.accept(visitor);
|
| + comments.accept(visitor);
|
| }
|
|
|
| @Override
|
| @@ -97,22 +74,9 @@ public class DartUnit extends DartNode {
|
| }
|
|
|
| /**
|
| - * Add the specified directive to the receiver's list of directives
|
| - */
|
| - public void addDirective(DartDirective directive) {
|
| - if (directives == null) {
|
| - directives = new ArrayList<DartDirective>();
|
| - }
|
| - directives.add(becomeParentOf(directive));
|
| - }
|
| -
|
| - /**
|
| - * Answer the receiver's directives or <code>null</code> if none
|
| + * Answer the receiver's directives, not <code>null</code>.
|
| */
|
| public List<DartDirective> getDirectives() {
|
| - if (directives == null) {
|
| - return Collections.<DartDirective> emptyList();
|
| - }
|
| return directives;
|
| }
|
|
|
|
|