Turn off implicit-casts, fix corresponding issues (#608)

* Turn off implicit-casts, fix corresponding issues

Would have caught the issue behind #605. Looks like mostly just lots of
places that were 'dynamic' before that didn't need to be.
diff --git a/angular_analyzer_plugin/analysis_options.yaml b/angular_analyzer_plugin/analysis_options.yaml
index b306593..c01b1e2 100644
--- a/angular_analyzer_plugin/analysis_options.yaml
+++ b/angular_analyzer_plugin/analysis_options.yaml
@@ -3,6 +3,8 @@
     # TODO(devoncarew): We should remove this blanket exclusion as it could hide
     # other issues.
     - lib/src/summary/format.dart
+  strong-mode:
+    implicit-casts: false
 
 linter:
   rules:
diff --git a/angular_analyzer_plugin/lib/ast.dart b/angular_analyzer_plugin/lib/ast.dart
index 9498409..b8c8e02 100644
--- a/angular_analyzer_plugin/lib/ast.dart
+++ b/angular_analyzer_plugin/lib/ast.dart
@@ -3,6 +3,7 @@
 import 'package:analyzer/dart/ast/ast.dart';
 import 'package:analyzer/src/generated/source.dart';
 import 'package:angular_analyzer_plugin/src/model.dart';
+import 'package:analyzer/dart/element/element.dart';
 import 'package:analyzer/src/dart/element/element.dart';
 import 'package:meta/meta.dart';
 
@@ -466,7 +467,7 @@
 
 /// A variable defined by a [AbstractDirective].
 class LocalVariable extends AngularElementImpl {
-  final LocalVariableElementImpl dartVariable;
+  final LocalVariableElement dartVariable;
 
   LocalVariable(String name, int nameOffset, int nameLength, Source source,
       this.dartVariable)
diff --git a/angular_analyzer_plugin/lib/src/angular_driver.dart b/angular_analyzer_plugin/lib/src/angular_driver.dart
index 33339ed..b9c0054 100644
--- a/angular_analyzer_plugin/lib/src/angular_driver.dart
+++ b/angular_analyzer_plugin/lib/src/angular_driver.dart
@@ -358,8 +358,9 @@
           attributes,
           standardEvents,
           customEvents,
-          result.libraryElement.exportNamespace.get('Element'),
-          result.libraryElement.exportNamespace.get('HtmlElement'));
+          result.libraryElement.exportNamespace.get('Element') as ClassElement,
+          result.libraryElement.exportNamespace.get('HtmlElement')
+              as ClassElement);
     }
 
     return standardHtml;
@@ -442,7 +443,7 @@
 
   String getFileContent(String path) =>
       contentOverlay[path] ??
-      ((source) =>
+      ((Source source) => // ignore: avoid_types_on_closure_parameters
           source.exists() ? source.contents.data : "")(getSource(path));
 
   Future<DirectivesResult> _resolveHtml(
@@ -779,7 +780,7 @@
           htmlViews.add(view.templateUriSource.fullName);
         }
 
-        for (final subDirective in (view?.directives ?? [])) {
+        for (final subDirective in (view?.directives ?? <Null>[])) {
           usesDart.add(subDirective.source.fullName);
         }
       }
@@ -949,7 +950,7 @@
       final exportAsOffset = directive?.exportAs?.nameOffset;
       final exports = <SummarizedExportedIdentifierBuilder>[];
       if (directive is Component) {
-        for (final export in directive?.view?.exports ?? []) {
+        for (final export in directive?.view?.exports ?? <Null>[]) {
           exports.add(new SummarizedExportedIdentifierBuilder()
             ..name = export.identifier
             ..prefix = export.prefix
diff --git a/angular_analyzer_plugin/lib/src/completion.dart b/angular_analyzer_plugin/lib/src/completion.dart
index 875c30d..1fb28b6 100644
--- a/angular_analyzer_plugin/lib/src/completion.dart
+++ b/angular_analyzer_plugin/lib/src/completion.dart
@@ -464,7 +464,7 @@
         export,
         relevance,
         typeName,
-        _createExportFunctionElement(export.element, elemKind, typeName)
+        _createExportFunctionElement(element, elemKind, typeName)
           ..returnType = typeName.toString(),
         withPrefix: withPrefix)
       ..returnType = element.returnType.toString()
@@ -636,6 +636,7 @@
         }
       }
     } else if (target is AttributeInfo && target.parent is TemplateAttribute) {
+      final templateAttr = target.parent as TemplateAttribute;
       // `let foo`. Nothing to suggest.
       if (target is TextAttribute && target.name.startsWith("let-")) {
         return;
@@ -643,9 +644,9 @@
 
       if (offsetContained(request.offset, target.originalNameOffset,
           target.originalName.length)) {
-        suggestInputsInTemplate(target.parent, collector, currentAttr: target);
+        suggestInputsInTemplate(templateAttr, collector, currentAttr: target);
       } else {
-        suggestInputsInTemplate(target.parent, collector);
+        suggestInputsInTemplate(templateAttr, collector);
       }
     } else if (target is ExpressionBoundAttribute &&
         offsetContained(request.offset, target.originalNameOffset,
@@ -936,10 +937,11 @@
           .where((b) => b.attribute != currentAttr)
           .map((b) => b.boundOutput)).toSet();
 
-      final availableInputs = new HashSet.from(directive.boundDirective.inputs)
-          .difference(usedInputs);
+      final availableInputs =
+          new HashSet<InputElement>.from(directive.boundDirective.inputs)
+              .difference(usedInputs);
       final availableOutputs =
-          new HashSet.from(directive.boundDirective.outputs)
+          new HashSet<OutputElement>.from(directive.boundDirective.outputs)
               .difference(usedOutputs);
       for (final input in availableInputs) {
         final inputName = input.name;
diff --git a/angular_analyzer_plugin/lib/src/completion_request.dart b/angular_analyzer_plugin/lib/src/completion_request.dart
index 7bc19c4..1e55f3e 100644
--- a/angular_analyzer_plugin/lib/src/completion_request.dart
+++ b/angular_analyzer_plugin/lib/src/completion_request.dart
@@ -73,7 +73,7 @@
           _dartSnippet = astFactory.parenthesizedExpression(
               new SyntheticBeginToken(TokenType.OPEN_PAREN, _dartSnippet.offset)
                 ..next = _dartSnippet.beginToken,
-              _dartSnippet,
+              _dartSnippet as Expression, // requires cast because reassigned
               new SyntheticToken(TokenType.CLOSE_PAREN, _dartSnippet.end));
         }
         _completionTarget = new CompletionTarget.forOffset(null, offset,
diff --git a/angular_analyzer_plugin/lib/src/converter.dart b/angular_analyzer_plugin/lib/src/converter.dart
index 509c552..ef7b17b 100644
--- a/angular_analyzer_plugin/lib/src/converter.dart
+++ b/angular_analyzer_plugin/lib/src/converter.dart
@@ -336,7 +336,7 @@
     String origName;
     int origNameOffset;
 
-    var virtualAttributes = [];
+    var virtualAttributes = <AttributeInfo>[];
 
     if (ast is ParsedStarAst) {
       value = ast.value;
diff --git a/angular_analyzer_plugin/lib/src/directive_extraction.dart b/angular_analyzer_plugin/lib/src/directive_extraction.dart
index 1c9cd32..e4b8611 100644
--- a/angular_analyzer_plugin/lib/src/directive_extraction.dart
+++ b/angular_analyzer_plugin/lib/src/directive_extraction.dart
@@ -128,7 +128,7 @@
   /// Returns `null` if not an Angular annotation.
   FunctionalDirective _getFunctionalDirective(
       ast.FunctionDeclaration functionDeclaration) {
-    final functionElement = functionDeclaration.element;
+    final functionElement = functionDeclaration.element as FunctionElement;
     final annotationNode = functionDeclaration.metadata.firstWhere(
         (ann) => isAngularAnnotation(ann, 'Directive'),
         orElse: () => null);
@@ -234,7 +234,7 @@
     // ignore: omit_local_variable_types
     final Tuple4<String, SourceRange, String, SourceRange> nameValueAndRanges =
         _parseHeaderNameValueSourceRanges(expression);
-    if (nameValueAndRanges != null) {
+    if (nameValueAndRanges != null && expression is ast.SimpleStringLiteral) {
       final boundName = nameValueAndRanges.item1;
       final boundRange = nameValueAndRanges.item2;
       final name = nameValueAndRanges.item3;
@@ -263,7 +263,7 @@
     // ignore: omit_local_variable_types
     final Tuple4<String, SourceRange, String, SourceRange> nameValueAndRanges =
         _parseHeaderNameValueSourceRanges(expression);
-    if (nameValueAndRanges != null) {
+    if (nameValueAndRanges != null && expression is ast.SimpleStringLiteral) {
       final boundName = nameValueAndRanges.item1;
       final boundRange = nameValueAndRanges.item2;
       final name = nameValueAndRanges.item3;
@@ -343,9 +343,9 @@
       property = isInput ? fieldElement.setter : fieldElement.getter;
     } else if (node is ast.MethodDeclaration) {
       if (isInput && node.isSetter) {
-        property = node.element;
+        property = node.element as PropertyAccessorElement;
       } else if (isOutput && node.isGetter) {
-        property = node.element;
+        property = node.element as PropertyAccessorElement;
       }
     }
 
@@ -506,7 +506,7 @@
       return null;
     }
 
-    final selectorStr = constantEvaluation.value;
+    final selectorStr = constantEvaluation.value as String;
     final selectorOffset = expression.offset;
     // Parse the selector text.
     try {
diff --git a/angular_analyzer_plugin/lib/src/directive_linking.dart b/angular_analyzer_plugin/lib/src/directive_linking.dart
index 5f1f33a..349d4a0 100644
--- a/angular_analyzer_plugin/lib/src/directive_linking.dart
+++ b/angular_analyzer_plugin/lib/src/directive_linking.dart
@@ -600,7 +600,8 @@
     final fileDirectives = await _fileDirectiveProvider
         .getUnlinkedAngularTopLevels(element.source.fullName);
     final options = fileDirectives
-        .where((d) => d is AbstractDirective && d.name == element.name);
+        .whereType<AbstractDirective>()
+        .where((d) => d.name == element.name);
 
     if (options.length == 1) {
       return options.first;
diff --git a/angular_analyzer_plugin/lib/src/facade/exports_import_element.dart b/angular_analyzer_plugin/lib/src/facade/exports_import_element.dart
index 2b08656..2579241 100644
--- a/angular_analyzer_plugin/lib/src/facade/exports_import_element.dart
+++ b/angular_analyzer_plugin/lib/src/facade/exports_import_element.dart
@@ -136,7 +136,7 @@
       .computeDocumentationComment(); // ignore: deprecated_member_use
 
   @override
-  CompilationUnit computeNode() => _wrappedImport.computeNode();
+  AstNode computeNode() => _wrappedImport.computeNode();
 
   @override
   E getAncestor<E extends Element>(Predicate<Element> predicate) =>
diff --git a/angular_analyzer_plugin/lib/src/file_tracker.dart b/angular_analyzer_plugin/lib/src/file_tracker.dart
index e581a99..13ae6d1 100644
--- a/angular_analyzer_plugin/lib/src/file_tracker.dart
+++ b/angular_analyzer_plugin/lib/src/file_tracker.dart
@@ -65,15 +65,15 @@
   List<String> getHtmlPathsReferencingHtml(String htmlPath) => _dartToHtml
       .getFilesReferencingFile(htmlPath)
       .map(_dartToDart.getFilesReferencingFile)
-      .fold(<String>[], (list, acc) => list..addAll(acc))
+      .fold<List<String>>(<String>[], (list, acc) => list..addAll(acc))
       .map(_dartToHtml.getFilesReferencedBy)
-      .fold(<String>[], (list, acc) => list..addAll(acc))
+      .fold<List<String>>(<String>[], (list, acc) => list..addAll(acc))
       .toList();
 
   List<String> getDartPathsAffectedByHtml(String htmlPath) => _dartToHtml
       .getFilesReferencingFile(htmlPath)
       .map(_dartToDart.getFilesReferencingFile)
-      .fold(<String>[], (list, acc) => list..addAll(acc))
+      .fold<List<String>>(<String>[], (list, acc) => list..addAll(acc))
       .where(_dartFilesWithDartTemplates.contains)
       .toList();
 
@@ -88,7 +88,8 @@
   List<String> getHtmlPathsAffectingDartContext(String dartPath) => _dartToDart
       .getFilesReferencedBy(dartPath)
       .map(_dartToHtml.getFilesReferencedBy)
-      .fold(<String>[], (list, acc) => list..addAll(acc)).toList();
+      .fold<List<String>>(
+          <String>[], (list, acc) => list..addAll(acc)).toList();
 
   ApiSignature getDartSignature(String dartPath) {
     final signature = new ApiSignature()
diff --git a/angular_analyzer_plugin/lib/src/model.dart b/angular_analyzer_plugin/lib/src/model.dart
index 0f6ac4b..9623342 100644
--- a/angular_analyzer_plugin/lib/src/model.dart
+++ b/angular_analyzer_plugin/lib/src/model.dart
@@ -466,7 +466,7 @@
   /// For example: source -> 'className', but prefer 'class'.
   /// In this case, name = 'class' and originalName = 'originalName'.
   /// This should be null if there is no alternative name.
-  final originalName;
+  final String originalName;
 
   /// Native inputs vulnerable to XSS (such as a.href and *.innerHTML) may have
   /// a security context. The secure type of that context should be assignable
diff --git a/angular_analyzer_plugin/lib/src/navigation.dart b/angular_analyzer_plugin/lib/src/navigation.dart
index 136b826..e371da4 100644
--- a/angular_analyzer_plugin/lib/src/navigation.dart
+++ b/angular_analyzer_plugin/lib/src/navigation.dart
@@ -16,7 +16,7 @@
   @override
   void computeNavigation(
       NavigationRequest baseRequest, NavigationCollector collector,
-      {templatesOnly: false}) {
+      {bool templatesOnly: false}) {
     // cast this
     final AngularNavigationRequest request = baseRequest;
     final length = request.length;
diff --git a/angular_analyzer_plugin/lib/src/options.dart b/angular_analyzer_plugin/lib/src/options.dart
index 44ad8fa..77ab35f 100644
--- a/angular_analyzer_plugin/lib/src/options.dart
+++ b/angular_analyzer_plugin/lib/src/options.dart
@@ -79,14 +79,16 @@
 
   void resolve() {
     customTagNames = new List<String>.from(
-        getOption('custom_tag_names', isListOfStrings) ?? []);
-    getOption('custom_events', isMapOfObjects)
+        getOption<List>('custom_tag_names', isListOfStrings) ?? []);
+    getOption<YamlMap>('custom_events', isMapOfObjects)
         ?.nodes
-        ?.forEach((nameNode, props) {
-      final name = (nameNode as YamlScalar).value as String;
+        ?.forEach((nameNodeKey, props) {
+      final nameNode = nameNodeKey as YamlScalar;
+      final name = nameNode.value as String;
       final offset = nameNode.span.start.offset;
-      customEvents[nameNode.value] = props is YamlMap
-          ? new CustomEvent(name, props['type'], props['path'], offset)
+      customEvents[name] = props is YamlMap
+          ? new CustomEvent(
+              name, props['type'] as String, props['path'] as String, offset)
           // Handle `event:` with no value, a shortcut for dynamic.
           : new CustomEvent(name, null, null, offset);
     });
@@ -137,16 +139,16 @@
     }
 
     // Outdated edge case, support a map of options under `plugins: x: ...`.
-    final specified = pluginsSection.containsKey(key);
+    final specified = (pluginsSection as Map).containsKey(key);
     if (specified) {
       angularOptions = pluginsSection[key];
     }
     return specified;
   }
 
-  dynamic getOption(String key, bool validator(input)) {
+  T getOption<T>(String key, bool validator(input)) {
     if (angularOptions != null && validator(angularOptions[key])) {
-      return angularOptions[key];
+      return angularOptions[key] as T;
     }
     return null;
   }
diff --git a/angular_analyzer_plugin/lib/src/standard_components.dart b/angular_analyzer_plugin/lib/src/standard_components.dart
index ec67c89..d3d5695 100644
--- a/angular_analyzer_plugin/lib/src/standard_components.dart
+++ b/angular_analyzer_plugin/lib/src/standard_components.dart
@@ -66,11 +66,11 @@
             sanitizationAvailable: false));
 
     return new StandardAngular(
-        queryList: ng.get("QueryList"),
-        elementRef: ng.get("ElementRef"),
-        templateRef: ng.get("TemplateRef"),
-        pipeTransform: ng.get("PipeTransform"),
-        component: ng.get("Component"),
+        queryList: ng.get("QueryList") as ClassElement,
+        elementRef: ng.get("ElementRef") as ClassElement,
+        templateRef: ng.get("TemplateRef") as ClassElement,
+        pipeTransform: ng.get("PipeTransform") as ClassElement,
+        component: ng.get("Component") as ClassElement,
         securitySchema: securitySchema);
   }
 }
diff --git a/angular_analyzer_plugin/lib/src/view_extraction.dart b/angular_analyzer_plugin/lib/src/view_extraction.dart
index 546f444..42c751f 100644
--- a/angular_analyzer_plugin/lib/src/view_extraction.dart
+++ b/angular_analyzer_plugin/lib/src/view_extraction.dart
@@ -105,7 +105,7 @@
             constantEvaluation.value is! String) {
           templateText = '';
         } else {
-          templateText = constantEvaluation.value;
+          templateText = constantEvaluation.value as String;
         }
       }
     }
@@ -281,7 +281,7 @@
         AngularWarningCode.UNOPENED_MUSTACHE,
   };
 
-  List<ng_ast.TemplateAst> rawAst;
+  List<ng_ast.StandaloneTemplateAst> rawAst;
   final parseErrors = <AnalysisError>[];
 
   void parse(String content, Source source, {int offset = 0}) {
@@ -296,7 +296,7 @@
       desugar: false,
       parseExpressions: false,
       exceptionHandler: exceptionHandler,
-    );
+    ) as List<ng_ast.StandaloneTemplateAst>;
 
     for (final e in exceptionHandler.exceptions) {
       if (e.errorCode is ng_ast.NgParserWarningCode) {
diff --git a/angular_analyzer_plugin/test/abstract_angular.dart b/angular_analyzer_plugin/test/abstract_angular.dart
index 2db7de4..be3fc88 100644
--- a/angular_analyzer_plugin/test/abstract_angular.dart
+++ b/angular_analyzer_plugin/test/abstract_angular.dart
@@ -57,7 +57,7 @@
 }
 
 Component getComponentByName(List<AbstractDirective> directives, String name) =>
-    getDirectiveByName(directives, name);
+    getDirectiveByName(directives, name) as Component;
 
 AbstractDirective getDirectiveByName(
         List<AbstractDirective> directives, String name) =>
@@ -410,7 +410,7 @@
     List<Tuple4<String, int, ErrorCode, List<Object>>> expectedErrors,
   ) {
     final realErrors = errorListener.errors;
-    for (Tuple4 expectedError in expectedErrors) {
+    for (final expectedError in expectedErrors) {
       final offset = code.indexOf(expectedError.item1);
       assert(offset != -1);
       final currentExpectedError = new AnalysisError(
diff --git a/angular_analyzer_plugin/test/angular_driver_test.dart b/angular_analyzer_plugin/test/angular_driver_test.dart
index 4dc29e3..3df47e5 100644
--- a/angular_analyzer_plugin/test/angular_driver_test.dart
+++ b/angular_analyzer_plugin/test/angular_driver_test.dart
@@ -708,7 +708,7 @@
   List<Pipe> pipes;
   List<AnalysisError> errors;
 
-  Future getDirectives(final source) async {
+  Future getDirectives(final Source source) async {
     final dartResult = await dartDriver.getResult(source.fullName);
     fillErrorListener(dartResult.errors);
     final result = await angularDriver.getAngularTopLevels(source.fullName);
@@ -2366,7 +2366,7 @@
   List<View> views;
   List<AnalysisError> errors;
 
-  Future getViews(final source) async {
+  Future getViews(final Source source) async {
     final dartResult = await dartDriver.getResult(source.fullName);
     fillErrorListener(dartResult.errors);
     final result = await angularDriver.getAngularTopLevels(source.fullName);
@@ -4019,7 +4019,7 @@
   List<Template> templates;
   List<AnalysisError> errors;
 
-  Future getDirectives(final source) async {
+  Future getDirectives(final Source source) async {
     final dartResult = await dartDriver.getResult(source.fullName);
     fillErrorListener(dartResult.errors);
     final ngResult = await angularDriver.requestDartResult(source.fullName);
@@ -4483,7 +4483,7 @@
   List<Template> templates;
   List<AnalysisError> errors;
 
-  Future getDirectives(final source) async {
+  Future getDirectives(final Source source) async {
     final dartResult = await dartDriver.getResult(source.fullName);
     fillErrorListener(dartResult.errors);
     final ngResult = await angularDriver.requestDartResult(source.fullName);
diff --git a/angular_analyzer_plugin/test/completion_contributor_test_util.dart b/angular_analyzer_plugin/test/completion_contributor_test_util.dart
index ad5ec1e..f903716 100644
--- a/angular_analyzer_plugin/test/completion_contributor_test_util.dart
+++ b/angular_analyzer_plugin/test/completion_contributor_test_util.dart
@@ -588,7 +588,7 @@
       {String completion,
       CompletionSuggestionKind csKind,
       protocol.ElementKind elemKind}) {
-    var cs;
+    CompletionSuggestion cs;
     if (suggestions != null) {
       suggestions.forEach((s) {
         if (completion != null && completion != s.completion) {
diff --git a/angular_analyzer_plugin/test/element_assert.dart b/angular_analyzer_plugin/test/element_assert.dart
index 1c42873..4aa1d60 100644
--- a/angular_analyzer_plugin/test/element_assert.dart
+++ b/angular_analyzer_plugin/test/element_assert.dart
@@ -107,7 +107,7 @@
   LocalVariableAssert get local {
     expect(element, const isInstanceOf<LocalVariable>());
     return new LocalVariableAssert(
-        element, _referenceOffset, _htmlSource, _htmlCode);
+        element as LocalVariable, _referenceOffset, _htmlSource, _htmlCode);
   }
 
   AngularElementAssert get selector {
diff --git a/angular_analyzer_plugin/test/navigation_test.dart b/angular_analyzer_plugin/test/navigation_test.dart
index 5d76cc5..ea1c891 100644
--- a/angular_analyzer_plugin/test/navigation_test.dart
+++ b/angular_analyzer_plugin/test/navigation_test.dart
@@ -62,8 +62,10 @@
         .thenAnswer((invocation) {
       final offset = invocation.positionalArguments[0] as int;
       final length = invocation.positionalArguments[1] as int;
-      final targetKind = invocation.positionalArguments[2];
-      final targetLocation = invocation.positionalArguments[3];
+      final targetKind =
+          invocation.positionalArguments[2] as protocol.ElementKind;
+      final targetLocation =
+          invocation.positionalArguments[3] as protocol.Location;
       regions.add(new _RecordedNavigationRegion(
           offset, length, targetKind, targetLocation));
     });
@@ -391,7 +393,8 @@
     fail('Unable to find a region at ($offset, $length) in $regionsString');
   }
 
-  void _findRegionString(String str, String suffix, {final codeOverride}) {
+  void _findRegionString(String str, String suffix,
+      {final String codeOverride}) {
     final code = codeOverride != null ? codeOverride : this.code;
     final search = '$str$suffix';
     final offset = code.indexOf(search);
diff --git a/angular_analyzer_plugin/test/resolver_test.dart b/angular_analyzer_plugin/test/resolver_test.dart
index 0991256..639c27b 100644
--- a/angular_analyzer_plugin/test/resolver_test.dart
+++ b/angular_analyzer_plugin/test/resolver_test.dart
@@ -5377,7 +5377,7 @@
     dartSource = newSource('/test_panel.dart', dartCode);
   }
 
-  void _addHtmlSource(final code) {
+  void _addHtmlSource(final String code) {
     htmlCode = code;
     htmlSource = newSource('/test_panel.html', htmlCode);
   }
diff --git a/angular_analyzer_plugin/test/selector_test.dart b/angular_analyzer_plugin/test/selector_test.dart
index 592ebd5..5f8891b 100644
--- a/angular_analyzer_plugin/test/selector_test.dart
+++ b/angular_analyzer_plugin/test/selector_test.dart
@@ -1469,8 +1469,8 @@
     // TODO(mfairhurst): remove `as dynamic`. See https://github.com/dart-lang/sdk/issues/33934
     when(template.addRange(typed(any), typed(any)) as dynamic)
         .thenAnswer((invocation) {
-      final range = invocation.positionalArguments[0];
-      final element = invocation.positionalArguments[1];
+      final range = invocation.positionalArguments[0] as SourceRange;
+      final element = invocation.positionalArguments[1] as AngularElement;
       resolvedRanges.add(new ResolvedRange(range, element));
     });
   }