@@ -30,6 +30,7 @@ import 'package:analyzer/src/generated/utilities_collection.dart';
30
30
import 'package:analyzer/src/generated/utilities_dart.dart' ;
31
31
import 'package:analyzer/src/task/dart.dart' ;
32
32
import 'package:path/path.dart' ;
33
+ import 'package:source_span/source_span.dart' ;
33
34
import 'package:unittest/unittest.dart' ;
34
35
35
36
import '../reflective_tests.dart' ;
@@ -7334,6 +7335,27 @@ class ErrorReporterTest extends EngineTestCase {
7334
7335
expect (error.offset, element.nameOffset);
7335
7336
}
7336
7337
7338
+ void test_reportErrorForSpan () {
7339
+ GatheringErrorListener listener = new GatheringErrorListener ();
7340
+ ErrorReporter reporter = new ErrorReporter (listener, new TestSource ());
7341
+
7342
+ var src = '''
7343
+ foo: bar
7344
+ zap: baz
7345
+ ''' ;
7346
+
7347
+ int offset = src.indexOf ('baz' );
7348
+ int length = 'baz' .length;
7349
+
7350
+ SourceSpan span = new SourceFile (src).span (offset, offset + length);
7351
+
7352
+ reporter.reportErrorForSpan (
7353
+ AnalysisOptionsWarningCode .UNSUPPORTED_OPTION , span, ['test' , 'zap' ]);
7354
+ expect (listener.errors, hasLength (1 ));
7355
+ expect (listener.errors.first.offset, offset);
7356
+ expect (listener.errors.first.length, length);
7357
+ }
7358
+
7337
7359
void test_reportTypeErrorForNode_differentNames () {
7338
7360
DartType firstType = createType ("/test1.dart" , "A" );
7339
7361
DartType secondType = createType ("/test2.dart" , "B" );
0 commit comments