remove uses of runtimeType
diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c49079..d24cf61 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md
@@ -1,7 +1,10 @@ +# 1.9.2 + +* Remove the use of `runtimeType` from toString methods (#85). + # 1.9.1 * Properly handle multi-line labels for multi-span highlights. - * Populate the pubspec `repository` field. # 1.9.0
diff --git a/analysis_options.yaml b/analysis_options.yaml index 97c0552..18a9332 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml
@@ -45,6 +45,7 @@ - list_remove_unrelated_type - no_adjacent_strings_in_list - no_duplicate_case_values + - no_runtimeType_toString - non_constant_identifier_names - null_closures - omit_local_variable_types
diff --git a/lib/src/location.dart b/lib/src/location.dart index 634863b..5eef45b 100644 --- a/lib/src/location.dart +++ b/lib/src/location.dart
@@ -92,7 +92,7 @@ int get hashCode => (sourceUrl?.hashCode ?? 0) + offset; @override - String toString() => '<$runtimeType: $offset $toolString>'; + String toString() => '<SourceLocation: $offset $toolString>'; } /// A base class for source locations with [offset], [line], and [column] known
diff --git a/lib/src/location_mixin.dart b/lib/src/location_mixin.dart index bae38be..8650097 100644 --- a/lib/src/location_mixin.dart +++ b/lib/src/location_mixin.dart
@@ -51,5 +51,5 @@ int get hashCode => (sourceUrl?.hashCode ?? 0) + offset; @override - String toString() => '<$runtimeType: $offset $toolString>'; + String toString() => '<SourceLocation: $offset $toolString>'; }
diff --git a/lib/src/span_mixin.dart b/lib/src/span_mixin.dart index 4d7bab4..6d8e7ae 100644 --- a/lib/src/span_mixin.dart +++ b/lib/src/span_mixin.dart
@@ -80,5 +80,5 @@ int get hashCode => Object.hash(start, end); @override - String toString() => '<$runtimeType: from $start to $end "$text">'; + String toString() => '<SourceSpan: from $start to $end "$text">'; }
diff --git a/pubspec.yaml b/pubspec.yaml index 8bde1c2..916e8ea 100644 --- a/pubspec.yaml +++ b/pubspec.yaml
@@ -1,5 +1,5 @@ name: source_span -version: 1.9.1 +version: 1.9.2 description: A library for identifying source spans and locations. repository: https://github.com/dart-lang/source_span
diff --git a/test/location_test.dart b/test/location_test.dart index bbe259b..2910990 100644 --- a/test/location_test.dart +++ b/test/location_test.dart
@@ -53,6 +53,11 @@ }); }); + test('toString contains the class type', () { + final location = SourceLocation(15, line: 2, column: 6); + expect(location.toString(), startsWith('<SourceLocation')); + }); + test('distance returns the absolute distance between locations', () { final other = SourceLocation(10, sourceUrl: 'foo.dart'); expect(location.distance(other), equals(5));
diff --git a/test/span_test.dart b/test/span_test.dart index 22c498e..5e2034e 100644 --- a/test/span_test.dart +++ b/test/span_test.dart
@@ -378,6 +378,11 @@ }); }); + test('toString contains the class type', () { + final span = SourceSpan(SourceLocation(5), SourceLocation(5), ''); + expect(span.toString(), startsWith('<SourceSpan')); + }); + group('compareTo()', () { test('sorts by start location first', () { final other = SourceSpan(SourceLocation(6, sourceUrl: 'foo.dart'),