Issue 35551. Log more information to debug the issue.

I don't know how to reproduce this issue.
So, I have to add logging to gather more information.

R=brianwilkerson@google.com, paulberry@google.com

Bug: https://github.com/dart-lang/sdk/issues/35551
Change-Id: I6c7de530a76998697577bd088f74bd2e9ac79cc4
Reviewed-on: https://dart-review.googlesource.com/c/89420
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
diff --git a/pkg/analyzer/lib/src/summary/resynthesize.dart b/pkg/analyzer/lib/src/summary/resynthesize.dart
index ae35bf7..3c6b194 100644
--- a/pkg/analyzer/lib/src/summary/resynthesize.dart
+++ b/pkg/analyzer/lib/src/summary/resynthesize.dart
@@ -1458,6 +1458,19 @@
 
   @override
   _ReferenceInfo getReferenceInfo(int index) {
+    // We don't know how to reproduce this.
+    // https://github.com/dart-lang/sdk/issues/35551
+    // https://github.com/dart-lang/sdk/issues/34534
+    // So, adding logging to gather more information.
+    if (index >= referenceInfos.length) {
+      var buffer = StringBuffer();
+      buffer.writeln('librarySource: ${unit.librarySource}');
+      buffer.writeln('unitSource: ${unit.source}');
+      buffer.writeln('unlinkedUnit: ${unlinkedUnit.toJson()}');
+      buffer.writeln('linkedUnit: ${linkedUnit.toJson()}');
+      throw StateError(buffer.toString());
+    }
+
     _ReferenceInfo result = referenceInfos[index];
     if (result == null) {
       LinkedReference linkedReference = linkedUnit.references[index];