remove unused DocumentationCommentToken.references field

Change-Id: Ia35dfe2c69d4f35d3a54dd0fcb026de23d888d1c
Reviewed-on: https://dart-review.googlesource.com/68520
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
diff --git a/pkg/analyzer/lib/src/dart/ast/ast.dart b/pkg/analyzer/lib/src/dart/ast/ast.dart
index 409d219..7a6d522 100644
--- a/pkg/analyzer/lib/src/dart/ast/ast.dart
+++ b/pkg/analyzer/lib/src/dart/ast/ast.dart
@@ -2206,7 +2206,7 @@
   }
 
   @override
-  Token get beginToken => _identifier.beginToken;
+  Token get beginToken => newKeyword ?? _identifier.beginToken;
 
   @override
   Iterable<SyntacticEntity> get childEntities =>
diff --git a/pkg/analyzer/lib/src/dart/ast/utilities.dart b/pkg/analyzer/lib/src/dart/ast/utilities.dart
index b942974..f0966b1 100644
--- a/pkg/analyzer/lib/src/dart/ast/utilities.dart
+++ b/pkg/analyzer/lib/src/dart/ast/utilities.dart
@@ -259,9 +259,22 @@
   }
 
   @override
-  CommentReference visitCommentReference(CommentReference node) =>
-      astFactory.commentReference(
-          cloneToken(node.newKeyword), cloneNode(node.identifier));
+  CommentReference visitCommentReference(CommentReference node) {
+    Token token = node.beginToken;
+    Token lastCloned = new Token.eof(-1);
+    while (token != null) {
+      Token clone = token.copy();
+      _clonedTokens[token] = clone;
+      lastCloned.setNext(clone);
+      lastCloned = clone;
+      if (token.isEof) {
+        break;
+      }
+      token = token.next;
+    }
+    return astFactory.commentReference(
+        cloneToken(node.newKeyword), cloneNode(node.identifier));
+  }
 
   @override
   CompilationUnit visitCompilationUnit(CompilationUnit node) {
@@ -1001,12 +1014,6 @@
         CommentToken c2 = clone.precedingComments;
         while (c1 != null && c2 != null) {
           _clonedTokens[c1] = c2;
-          if (c1 is DocumentationCommentToken &&
-              c2 is DocumentationCommentToken) {
-            for (int i = 0; i < c1.references.length; i++) {
-              _clonedTokens[c1.references[i]] = c2.references[i];
-            }
-          }
           c1 = c1.next;
           c2 = c2.next;
         }
diff --git a/pkg/analyzer/lib/src/generated/parser.dart b/pkg/analyzer/lib/src/generated/parser.dart
index 9422646..4e0133d 100644
--- a/pkg/analyzer/lib/src/generated/parser.dart
+++ b/pkg/analyzer/lib/src/generated/parser.dart
@@ -1901,7 +1901,6 @@
                     comment.substring(leftIndex + 1, rightIndex), nameOffset);
                 if (reference != null) {
                   references.add(reference);
-                  token.references.add(reference.beginToken);
                 }
               }
             }
@@ -1922,7 +1921,6 @@
             nameToken.setNext(new Token.eof(nameToken.end));
             references.add(astFactory.commentReference(
                 null, astFactory.simpleIdentifier(nameToken)));
-            token.references.add(nameToken);
             // next character
             rightIndex = leftIndex + 1;
           }
diff --git a/pkg/analyzer/test/generated/parser_test.dart b/pkg/analyzer/test/generated/parser_test.dart
index f06a44b..adfc022 100644
--- a/pkg/analyzer/test/generated/parser_test.dart
+++ b/pkg/analyzer/test/generated/parser_test.dart
@@ -13694,16 +13694,13 @@
     List<CommentReference> references = parser.parseCommentReferences(tokens);
     expectNotNullIfNoErrors(references);
     assertNoErrors();
-    List<Token> tokenReferences = token.references;
     expect(references, hasLength(2));
-    expect(tokenReferences, hasLength(2));
     {
       CommentReference reference = references[0];
       expect(reference, isNotNull);
       expect(reference.identifier, isNotNull);
       expect(reference.offset, 12);
-      // the reference is recorded in the comment token
-      Token referenceToken = tokenReferences[0];
+      Token referenceToken = reference.identifier.beginToken;
       expect(referenceToken.offset, 12);
       expect(referenceToken.lexeme, 'a');
     }
@@ -13712,8 +13709,7 @@
       expect(reference, isNotNull);
       expect(reference.identifier, isNotNull);
       expect(reference.offset, 20);
-      // the reference is recorded in the comment token
-      Token referenceToken = tokenReferences[1];
+      Token referenceToken = reference.identifier.beginToken;
       expect(referenceToken.offset, 20);
       expect(referenceToken.lexeme, 'bb');
     }
@@ -13727,12 +13723,10 @@
         parser.parseCommentReferences(<DocumentationCommentToken>[docToken]);
     expectNotNullIfNoErrors(references);
     assertNoErrors();
-    expect(docToken.references, hasLength(1));
     expect(references, hasLength(1));
-    Token referenceToken = docToken.references[0];
     CommentReference reference = references[0];
+    Token referenceToken = reference.identifier.beginToken;
     expect(reference, isNotNull);
-    expect(docToken.references[0], same(reference.beginToken));
     expect(reference.identifier, isNotNull);
     expect(reference.identifier.isSynthetic, isTrue);
     expect(reference.identifier.name, "");
@@ -13750,10 +13744,9 @@
         parser.parseCommentReferences(<DocumentationCommentToken>[docToken]);
     expectNotNullIfNoErrors(references);
     assertNoErrors();
-    expect(docToken.references, hasLength(1));
     expect(references, hasLength(1));
-    Token referenceToken = docToken.references[0];
     CommentReference reference = references[0];
+    Token referenceToken = reference.identifier.beginToken;
     expect(reference, isNotNull);
     expect(referenceToken, same(reference.beginToken));
     expect(reference.identifier, isNotNull);
diff --git a/pkg/front_end/lib/src/fasta/parser/parser.dart b/pkg/front_end/lib/src/fasta/parser/parser.dart
index c3071fd..73a08d7 100644
--- a/pkg/front_end/lib/src/fasta/parser/parser.dart
+++ b/pkg/front_end/lib/src/fasta/parser/parser.dart
@@ -6036,7 +6036,6 @@
     if (token.isUserDefinableOperator) {
       if (token.next.isEof) {
         listener.handleCommentReference(newKeyword, prefix, period, token);
-        commentToken.references.add(begin);
         return;
       }
     } else {
@@ -6044,7 +6043,6 @@
       if (token.next.isEof) {
         if (token.isIdentifier) {
           listener.handleCommentReference(newKeyword, prefix, period, token);
-          commentToken.references.add(begin);
           return;
         }
         Keyword keyword = token.keyword;
diff --git a/pkg/front_end/lib/src/fasta/scanner/token.dart b/pkg/front_end/lib/src/fasta/scanner/token.dart
index bd837c1..f10081d 100644
--- a/pkg/front_end/lib/src/fasta/scanner/token.dart
+++ b/pkg/front_end/lib/src/fasta/scanner/token.dart
@@ -189,9 +189,6 @@
 
 class DartDocToken extends CommentToken
     implements analyzer.DocumentationCommentToken {
-  @override
-  final List<Token> references = <Token>[];
-
   /**
    * Creates a lazy comment token. If [canonicalize] is true, the string
    * is canonicalized before the token is created.
@@ -214,12 +211,8 @@
       : super._(type, valueOrLazySubstring, charOffset);
 
   @override
-  DartDocToken copy() {
-    DartDocToken copy =
-        new DartDocToken._(type, valueOrLazySubstring, charOffset);
-    references.forEach((ref) => copy.references.add(ref.copy()));
-    return copy;
-  }
+  DartDocToken copy() =>
+      new DartDocToken._(type, valueOrLazySubstring, charOffset);
 }
 
 /**
diff --git a/pkg/front_end/lib/src/scanner/token.dart b/pkg/front_end/lib/src/scanner/token.dart
index 3543578..d1c6d0e 100644
--- a/pkg/front_end/lib/src/scanner/token.dart
+++ b/pkg/front_end/lib/src/scanner/token.dart
@@ -108,13 +108,6 @@
  */
 class DocumentationCommentToken extends CommentToken {
   /**
-   * The references embedded within the documentation comment.
-   * This list will be empty unless this is a documentation comment that has
-   * references embedded within it.
-   */
-  final List<Token> references = <Token>[];
-
-  /**
    * Initialize a newly created token to represent a token of the given [type]
    * with the given [value] at the given [offset].
    */
@@ -122,12 +115,7 @@
       : super(type, value, offset);
 
   @override
-  CommentToken copy() {
-    DocumentationCommentToken copy =
-        new DocumentationCommentToken(type, _value, offset);
-    references.forEach((ref) => copy.references.add(ref.copy()));
-    return copy;
-  }
+  CommentToken copy() => new DocumentationCommentToken(type, _value, offset);
 }
 
 /**