Fix infinite recursion in reexport tagger (#1838)

* Fix infinite recursion in reexport tagger

* add shelf_exception_handler to bots

* Reduce analyzer requirement to keep us in the 2.0 SDK window
diff --git a/lib/src/model.dart b/lib/src/model.dart
index b8b7b63..b8533f1 100644
--- a/lib/src/model.dart
+++ b/lib/src/model.dart
@@ -5037,9 +5037,16 @@
       packages.where((p) => p.documentedWhere != DocumentLocation.missing);
 
   Map<LibraryElement, Set<Library>> _libraryElementReexportedBy = new Map();
+  /// Prevent cycles from breaking our stack.
+  Set<Tuple2<Library, LibraryElement>> _reexportsTagged = new Set();
   void _tagReexportsFor(
       final Library topLevelLibrary, final LibraryElement libraryElement,
       [ExportElement lastExportedElement]) {
+    Tuple2<Library, LibraryElement> key = new Tuple2(topLevelLibrary, libraryElement);
+    if (_reexportsTagged.contains(key)) {
+      return;
+    }
+    _reexportsTagged.add(key);
     if (libraryElement == null) {
       // The first call to _tagReexportFor should not have a null libraryElement.
       assert(lastExportedElement != null);
@@ -5064,6 +5071,7 @@
     if (allLibraries.keys.length != _lastSizeOfAllLibraries) {
       _lastSizeOfAllLibraries = allLibraries.keys.length;
       _libraryElementReexportedBy = new Map<LibraryElement, Set<Library>>();
+      _reexportsTagged = new Set();
       for (Library library in publicLibraries) {
         _tagReexportsFor(library, library.element);
       }
diff --git a/pubspec.yaml b/pubspec.yaml
index c9a798b..320dbb0 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -8,7 +8,7 @@
   sdk: '>=2.0.0 <3.0.0'
 
 dependencies:
-  analyzer: ^0.33.1
+  analyzer: ^0.33.3+1
   args: '>=1.4.1 <2.0.0'
   collection: ^1.2.0
   crypto: ^2.0.6
diff --git a/testing/test_package/lib/fake.dart b/testing/test_package/lib/fake.dart
index 82adf57..f484d3e 100644
--- a/testing/test_package/lib/fake.dart
+++ b/testing/test_package/lib/fake.dart
@@ -57,6 +57,10 @@
 export 'package:test_package_imported/categoryExporting.dart'
     show IAmAClassWithCategories;
 
+// Explicitly export ourselves, because why not.
+// ignore: uri_does_not_exist
+export 'package:test_package/fake.dart';
+
 abstract class ImplementingThingy implements BaseThingy {}
 
 abstract class BaseThingy {
diff --git a/tool/travis.sh b/tool/travis.sh
index 66c8a6e..d4b0ade 100755
--- a/tool/travis.sh
+++ b/tool/travis.sh
@@ -28,6 +28,7 @@
   else
     PACKAGE_NAME=angular PACKAGE_VERSION=">=5.0.0-beta <5.1.0" DARTDOC_PARAMS="--include=angular,angular.security" pub run grinder build-pub-package
   fi
+  PACKAGE_NAME=shelf_exception_handler PACKAGE_VERSION=">=0.2.0" pub run grinder build-pub-package
 elif [ "$DARTDOC_BOT" = "sdk-analyzer" ]; then
   echo "Running main dartdoc bot against the SDK analyzer"
   DARTDOC_GRIND_STEP=buildbot-no-publish pub run grinder test-with-analyzer-sdk