LCOV - code coverage report
Current view: top level - source_span-1.8.1/lib/src - location_mixin.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 0 23 0.0 %
Date: 2021-11-28 14:37:50 Functions: 0 0 -

          Line data    Source code
       1             : // Copyright (c) 2015, the Dart project authors.  Please see the AUTHORS file
       2             : // for details. All rights reserved. Use of this source code is governed by a
       3             : // BSD-style license that can be found in the LICENSE file.
       4             : 
       5             : import 'location.dart';
       6             : import 'span.dart';
       7             : 
       8             : // Note: this class duplicates a lot of functionality of [SourceLocation]. This
       9             : // is because in order for SourceLocation to use SourceLocationMixin,
      10             : // SourceLocationMixin couldn't implement SourceLocation. In SourceSpan we
      11             : // handle this by making the class itself non-extensible, but that would be a
      12             : // breaking change for SourceLocation. So until we want to endure the pain of
      13             : // cutting a release with breaking changes, we duplicate the code here.
      14             : 
      15             : /// A mixin for easily implementing [SourceLocation].
      16             : abstract class SourceLocationMixin implements SourceLocation {
      17           0 :   @override
      18             :   String get toolString {
      19           0 :     final source = sourceUrl ?? 'unknown source';
      20           0 :     return '$source:${line + 1}:${column + 1}';
      21             :   }
      22             : 
      23           0 :   @override
      24             :   int distance(SourceLocation other) {
      25           0 :     if (sourceUrl != other.sourceUrl) {
      26           0 :       throw ArgumentError('Source URLs \"$sourceUrl\" and '
      27           0 :           "\"${other.sourceUrl}\" don't match.");
      28             :     }
      29           0 :     return (offset - other.offset).abs();
      30             :   }
      31             : 
      32           0 :   @override
      33           0 :   SourceSpan pointSpan() => SourceSpan(this, this, '');
      34             : 
      35           0 :   @override
      36             :   int compareTo(SourceLocation other) {
      37           0 :     if (sourceUrl != other.sourceUrl) {
      38           0 :       throw ArgumentError('Source URLs \"$sourceUrl\" and '
      39           0 :           "\"${other.sourceUrl}\" don't match.");
      40             :     }
      41           0 :     return offset - other.offset;
      42             :   }
      43             : 
      44           0 :   @override
      45             :   bool operator ==(other) =>
      46           0 :       other is SourceLocation &&
      47           0 :       sourceUrl == other.sourceUrl &&
      48           0 :       offset == other.offset;
      49             : 
      50           0 :   @override
      51           0 :   int get hashCode => (sourceUrl?.hashCode ?? 0) + offset;
      52             : 
      53           0 :   @override
      54           0 :   String toString() => '<$runtimeType: $offset $toolString>';
      55             : }

Generated by: LCOV version 1.14