Cleanup unused interfaces (#1871)

* Delete unused code and add a trivial test

* dartfmt
diff --git a/lib/src/html/template_data.dart b/lib/src/html/template_data.dart
index ced3611..fe1b058 100644
--- a/lib/src/html/template_data.dart
+++ b/lib/src/html/template_data.dart
@@ -9,32 +9,15 @@
   String get toolVersion;
 }
 
-class Subnav {
-  final String name;
-  final String href;
-
-  Subnav(this.name, this.href);
-
-  @override
-  String toString() => name;
-}
-
 abstract class TemplateData<T extends Documentable> {
   final PackageGraph packageGraph;
   final HtmlOptions htmlOptions;
 
-  List<Subnav> _subNameItemCache;
-
   TemplateData(this.htmlOptions, this.packageGraph);
 
-  List<Category> get displayedCategories => <Category>[];
-  String get documentation => self.documentation;
-  String get oneLineDoc => self.oneLineDoc;
   String get title;
   String get layoutTitle;
   String get metaDescription;
-  String get name => self.name;
-  String get kind => self is ModelElement ? (self as ModelElement).kind : null;
 
   List get navLinks;
   List get navLinksWithGenerics => [];
@@ -48,24 +31,12 @@
   bool get includeVersion => false;
 
   bool get hasHomepage => false;
-  String get homepage => null;
-
-  bool get hasSubNav => subnavItems.isNotEmpty;
-
-  List<Subnav> get subnavItems {
-    if (_subNameItemCache == null) {
-      _subNameItemCache = getSubNavItems().toList();
-    }
-    return _subNameItemCache;
-  }
 
   String get htmlBase;
   T get self;
   String get version => htmlOptions.toolVersion;
   String get relCanonicalPrefix => htmlOptions.relCanonicalPrefix;
 
-  Iterable<Subnav> getSubNavItems() => <Subnav>[];
-
   String _layoutTitle(String name, String kind, bool isDeprecated) {
     if (isDeprecated) {
       return '<span class="deprecated">${name}</span> ${kind}';
@@ -73,14 +44,6 @@
       return '${name} ${kind}';
     }
   }
-
-  Iterable<Subnav> _gatherSubnavForInvokable(ModelElement element) {
-    if (element.hasSourceCode) {
-      return [new Subnav('Source', '${element.href}#source')];
-    } else {
-      return <Subnav>[];
-    }
-  }
 }
 
 class PackageTemplateData extends TemplateData<Package> {
@@ -98,21 +61,14 @@
   @override
   Package get self => package;
   @override
-  String get layoutTitle => _layoutTitle(package.name, kind, false);
+  String get layoutTitle => _layoutTitle(package.name, package.kind, false);
   @override
   String get metaDescription =>
       '${package.name} API docs, for the Dart programming language.';
-  @override
-  Iterable<Subnav> getSubNavItems() {
-    return [new Subnav('Libraries', '${package.href}#libraries')];
-  }
 
   @override
   bool get hasHomepage => package.hasHomepage;
-  @override
   String get homepage => package.homepage;
-  @override
-  String get kind => package.kind;
 
   /// `null` for packages because they are at the root – not needed
   @override
@@ -141,25 +97,6 @@
 
   @override
   List get navLinks => [category.package];
-  @override
-  Iterable<Subnav> getSubNavItems() sync* {
-    if (category.hasPublicClasses)
-      yield new Subnav('Libraries', '${category.href}#libraries');
-    if (category.hasPublicClasses)
-      yield new Subnav('Classes', '${category.href}#classes');
-    if (category.hasPublicConstants)
-      yield new Subnav('Constants', '${category.href}#constants');
-    if (category.hasPublicProperties)
-      yield new Subnav('Properties', '${category.href}#properties');
-    if (category.hasPublicFunctions)
-      yield new Subnav('Functions', '${category.href}#functions');
-    if (category.hasPublicEnums)
-      yield new Subnav('Enums', '${category.href}#enums');
-    if (category.hasPublicTypedefs)
-      yield new Subnav('Typedefs', '${category.href}#typedefs');
-    if (category.hasPublicExceptions)
-      yield new Subnav('Exceptions', '${category.href}#exceptions');
-  }
 
   @override
   Category get self => category;
@@ -175,31 +112,12 @@
   @override
   String get title => '${library.name} library - Dart API';
   @override
-  String get documentation => library.documentation;
-  @override
   String get htmlBase => '..';
   @override
   String get metaDescription =>
       '${library.name} library API docs, for the Dart programming language.';
   @override
   List get navLinks => [packageGraph.defaultPackage];
-  @override
-  Iterable<Subnav> getSubNavItems() sync* {
-    if (library.hasPublicClasses)
-      yield new Subnav('Classes', '${library.href}#classes');
-    if (library.hasPublicConstants)
-      yield new Subnav('Constants', '${library.href}#constants');
-    if (library.hasPublicProperties)
-      yield new Subnav('Properties', '${library.href}#properties');
-    if (library.hasPublicFunctions)
-      yield new Subnav('Functions', '${library.href}#functions');
-    if (library.hasPublicEnums)
-      yield new Subnav('Enums', '${library.href}#enums');
-    if (library.hasPublicTypedefs)
-      yield new Subnav('Typedefs', '${library.href}#typedefs');
-    if (library.hasPublicExceptions)
-      yield new Subnav('Exceptions', '${library.href}#exceptions');
-  }
 
   @override
   String get layoutTitle =>
@@ -250,23 +168,6 @@
   List get navLinks => [packageGraph.defaultPackage, library];
   @override
   String get htmlBase => '..';
-  @override
-  Iterable<Subnav> getSubNavItems() sync* {
-    if (clazz.hasPublicConstructors)
-      yield new Subnav('Constructors', '${clazz.href}#constructors');
-    if (clazz.hasPublicProperties)
-      yield new Subnav('Properties', '${clazz.href}#instance-properties');
-    if (clazz.hasPublicMethods)
-      yield new Subnav('Methods', '${clazz.href}#instance-methods');
-    if (clazz.hasPublicOperators)
-      yield new Subnav('Operators', '${clazz.href}#operators');
-    if (clazz.hasPublicStaticProperties)
-      yield new Subnav('Static Properties', '${clazz.href}#static-properties');
-    if (clazz.hasPublicStaticMethods)
-      yield new Subnav('Static Methods', '${clazz.href}#static-methods');
-    if (clazz.hasPublicConstants)
-      yield new Subnav('Constants', '${clazz.href}#constants');
-  }
 
   Class get objectType {
     if (_objectType != null) {
@@ -303,7 +204,6 @@
   @override
   List get navLinksWithGenerics => [clazz];
   @override
-  Iterable<Subnav> getSubNavItems() => _gatherSubnavForInvokable(constructor);
   @override
   String get htmlBase => '../..';
   @override
@@ -324,13 +224,6 @@
   Enum get eNum => clazz;
   @override
   Enum get self => eNum;
-  @override
-  Iterable<Subnav> getSubNavItems() => [
-        new Subnav('Constants', '${eNum.href}#constants'),
-        new Subnav('Properties', '${eNum.href}#instance-properties'),
-        new Subnav('Methods', '${eNum.href}#instance-methods'),
-        new Subnav('Operators', '${eNum.href}#operators')
-      ];
 }
 
 class FunctionTemplateData extends TemplateData<ModelFunction> {
@@ -356,8 +249,6 @@
   @override
   List get navLinks => [packageGraph.defaultPackage, library];
   @override
-  Iterable<Subnav> getSubNavItems() => _gatherSubnavForInvokable(function);
-  @override
   String get htmlBase => '..';
 }
 
@@ -387,8 +278,6 @@
   @override
   List get navLinksWithGenerics => [clazz];
   @override
-  Iterable<Subnav> getSubNavItems() => _gatherSubnavForInvokable(method);
-  @override
   String get htmlBase => '../..';
 }
 
@@ -458,8 +347,6 @@
   List get navLinks => [packageGraph.defaultPackage, library];
   @override
   String get htmlBase => '..';
-  @override
-  Iterable<Subnav> getSubNavItems() => _gatherSubnavForInvokable(typeDef);
 }
 
 class TopLevelPropertyTemplateData extends TemplateData<TopLevelVariable> {
diff --git a/lib/src/line_number_cache.dart b/lib/src/line_number_cache.dart
index 966d77a..3000238 100644
--- a/lib/src/line_number_cache.dart
+++ b/lib/src/line_number_cache.dart
@@ -42,27 +42,12 @@
   final Map<String, SplayTreeMap<int, int>> _lineNumbers =
       <String, SplayTreeMap<int, int>>{};
 
-  int lineNumber(String file, int offset) {
-    if (offset == 0) {
-      return 0;
-    } else {
-      var lineMap = _lineNumbers.putIfAbsent(
-          file, () => _createLineNumbersMap(_fileContents(file)));
-      var lastKey = lineMap.lastKeyBefore(offset);
-      return lineMap[lastKey];
-    }
-  }
-
   Tuple2<int, int> lineAndColumn(String file, int offset) {
-    if (offset == 0) {
-      return new Tuple2(0, 0);
-    } else {
-      var lineMap = _lineNumbers.putIfAbsent(
-          file, () => _createLineNumbersMap(_fileContents(file)));
-      var lastKey = lineMap.lastKeyBefore(offset);
-      if (lastKey != null) {
-        return new Tuple2(lineMap[lastKey] + 1, offset - lastKey);
-      }
+    var lineMap = _lineNumbers.putIfAbsent(
+        file, () => _createLineNumbersMap(_fileContents(file)));
+    var lastKey = lineMap.lastKeyBefore(offset);
+    if (lastKey != null) {
+      return new Tuple2(lineMap[lastKey] + 1, offset - lastKey);
     }
     return null;
   }
diff --git a/lib/src/model.dart b/lib/src/model.dart
index 9983a49..8c8cf4d 100644
--- a/lib/src/model.dart
+++ b/lib/src/model.dart
@@ -426,13 +426,6 @@
     return _enclosingCombo;
   }
 
-  /// Call exactly once to set the enclosing combo for this Accessor.
-  set enclosingCombo(GetterSetterCombo combo) {
-    assert(_enclosingCombo == null || combo == _enclosingCombo);
-    assert(combo != null);
-    _enclosingCombo = combo;
-  }
-
   bool get isSynthetic => element.isSynthetic;
 
   @override
@@ -710,8 +703,6 @@
   /// See [Inheritable.canonicalEnclosingElement].
   bool contains(Element element) => allElements.containsKey(element);
 
-  ModelElement findModelElement(Element element) => allElements[element];
-
   Map<String, List<ModelElement>> _membersByName;
 
   /// Given a ModelElement that is a member of some other class, return
@@ -935,18 +926,6 @@
   Iterable<DefinedElementType> get publicInterfaces =>
       filterNonPublic(interfaces);
 
-  List<DefinedElementType> _interfaceChain;
-  List<DefinedElementType> get interfaceChain {
-    if (_interfaceChain == null) {
-      _interfaceChain = [];
-      for (DefinedElementType interface in interfaces) {
-        _interfaceChain.add(interface);
-        _interfaceChain.addAll((interface.element as Class).interfaceChain);
-      }
-    }
-    return _interfaceChain;
-  }
-
   bool get isAbstract => _cls.isAbstract;
 
   @override
@@ -1063,7 +1042,6 @@
     return typeChain;
   }
 
-  Iterable<DefinedElementType> get superChainReversed => superChain.reversed;
   Iterable<DefinedElementType> get publicSuperChain =>
       filterNonPublic(superChain);
   Iterable<DefinedElementType> get publicSuperChainReversed =>
@@ -1712,8 +1690,8 @@
       this.getter, this.setter)
       : super(element, library, packageGraph, null) {
     assert(getter != null || setter != null);
-    if (getter != null) getter.enclosingCombo = this;
-    if (setter != null) setter.enclosingCombo = this;
+    if (getter != null) getter._enclosingCombo = this;
+    if (setter != null) setter._enclosingCombo = this;
     _setModelType();
   }
 
@@ -1788,8 +1766,6 @@
   @override
   String get kind => isConst ? 'constant' : 'property';
 
-  String get typeName => kind;
-
   @override
   List<String> get annotations {
     List<String> all_annotations = new List<String>();
@@ -1942,15 +1918,6 @@
   String get constantValueBase =>
       _constantValueBase ??= _buildConstantValueBase();
 
-  /// Returns true if both accessors are synthetic.
-  bool get hasSyntheticAccessors {
-    if ((hasPublicGetter && getter.isSynthetic) ||
-        (hasPublicSetter && setter.isSynthetic)) {
-      return true;
-    }
-    return false;
-  }
-
   bool get hasPublicGetter => hasGetter && getter.isPublic;
   bool get hasPublicSetter => hasSetter && setter.isPublic;
 
@@ -2619,12 +2586,6 @@
     return name;
   }
 
-  static PackageMeta getPackageMeta(Element element) {
-    String sourcePath = element.source.fullName;
-    return new PackageMeta.fromDir(
-        new File(pathLib.canonicalize(sourcePath)).parent);
-  }
-
   static String getLibraryName(LibraryElement element) {
     var source = element.source;
 
@@ -2719,47 +2680,6 @@
     return (_allCanonicalModelElements ??=
         allModelElements.where((e) => e.isCanonical).toList());
   }
-
-  final Map<Library, bool> _isReexportedBy = {};
-
-  /// Heuristic that tries to guess if this library is actually largely
-  /// reexported by some other library.  We guess this by comparing the elements
-  /// inside each of allModelElements for both libraries.  Don't use this
-  /// except as a last-resort for canonicalization as it is a pretty fuzzy
-  /// definition.
-  ///
-  /// If most of the elements from this library appear in the other, but not
-  /// the reverse, then the other library is considered to be a reexporter of
-  /// this one.
-  ///
-  /// If not, then the situation is either ambiguous, or the reverse is true.
-  /// Computing this is expensive, so cache it.
-  bool isReexportedBy(Library library) {
-    assert(packageGraph.allLibrariesAdded);
-    if (_isReexportedBy.containsKey(library)) return _isReexportedBy[library];
-    Set<Element> otherElements = new Set()
-      ..addAll(library.allModelElements.map((l) => l.element));
-    Set<Element> ourElements = new Set()
-      ..addAll(allModelElements.map((l) => l.element));
-    if (ourElements.difference(otherElements).length <=
-        ourElements.length / 2) {
-      // Less than half of our elements are unique to us.
-      if (otherElements.difference(ourElements).length <=
-          otherElements.length / 2) {
-        // ... but the same is true for the other library.  Reexporting
-        // is ambiguous.
-        _isReexportedBy[library] = false;
-      } else {
-        _isReexportedBy[library] = true;
-      }
-    } else {
-      // We have a lot of unique elements, we're probably not reexported by
-      // the other libraries.
-      _isReexportedBy[library] = false;
-    }
-
-    return _isReexportedBy[library];
-  }
 }
 
 class Method extends ModelElement
@@ -2849,8 +2769,6 @@
     return null;
   }
 
-  String get typeName => 'method';
-
   MethodElement get _method => (element as MethodElement);
 
   /// Methods can not be covariant; always returns false.
@@ -3106,15 +3024,9 @@
                 originalMember: originalMember);
         }
         if (e is TopLevelVariableElement) {
-          if (getter == null && setter == null) {
-            List<TopLevelVariable> allVariables = []
-              ..addAll(library.properties)
-              ..addAll(library.constants);
-            newModelElement = allVariables.firstWhere((v) => v.element == e);
-          } else {
-            newModelElement =
-                new TopLevelVariable(e, library, packageGraph, getter, setter);
-          }
+          assert(getter != null || setter != null);
+          newModelElement =
+              new TopLevelVariable(e, library, packageGraph, getter, setter);
         }
         if (e is PropertyAccessorElement) {
           // TODO(jcollins-g): why test for ClassElement in enclosingElement?
@@ -4729,9 +4641,6 @@
   String get name {
     return 'operator ${super.name}';
   }
-
-  @override
-  String get typeName => 'operator';
 }
 
 class PackageGraph {
@@ -6311,12 +6220,10 @@
       PackageGraph packageGraph, this.getter, this.setter)
       : super(element, library, packageGraph, null) {
     if (getter != null) {
-      getter.enclosingCombo = this;
-      assert(getter.enclosingCombo != null);
+      getter._enclosingCombo = this;
     }
     if (setter != null) {
-      setter.enclosingCombo = this;
-      assert(setter.enclosingCombo != null);
+      setter._enclosingCombo = this;
     }
   }
 
diff --git a/lib/src/model_utils.dart b/lib/src/model_utils.dart
index 984180b..28ccce0 100644
--- a/lib/src/model_utils.dart
+++ b/lib/src/model_utils.dart
@@ -62,24 +62,6 @@
   return _fileContents[location];
 }
 
-Iterable<LibraryElement> getRequiredSdkLibraries(
-    DartSdk sdk, AnalysisContext context) {
-  var requiredLibs = sdk.sdkLibraries
-      .where((sdkLib) => sdkLib.shortName == 'dart:_interceptors');
-  final Set<LibraryElement> allLibraryElements = new Set();
-  for (var sdkLib in requiredLibs) {
-    Source source = sdk.mapDartUri(sdkLib.shortName);
-    allLibraryElements.add(context.computeLibraryElement(source));
-  }
-  return allLibraryElements;
-}
-
-bool isInExportedLibraries(
-    List<LibraryElement> libraries, LibraryElement library) {
-  return libraries
-      .any((lib) => lib == library || lib.exportedLibraries.contains(library));
-}
-
 final RegExp slashes = new RegExp('[\/]');
 bool hasPrivateName(Element e) {
   if (e.name == null) return false;
diff --git a/test/resource_loader_test.dart b/test/resource_loader_test.dart
index db4f9e5..7fc5c3b 100644
--- a/test/resource_loader_test.dart
+++ b/test/resource_loader_test.dart
@@ -14,5 +14,9 @@
           await loader.loadAsString('package:dartdoc/templates/index.html');
       expect(contents, isNotNull);
     });
+
+    test('throws if non-package', () async {
+      expect(loader.loadAsString('wefoij:something'), throwsArgumentError);
+    });
   });
 }