| // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file |
| // for details. All rights reserved. Use of this source code is governed by a |
| // BSD-style license that can be found in the LICENSE file. |
| |
| import 'package:front_end/src/api_unstable/dart2js.dart' as ir; |
| import '../common.dart'; |
| |
| DiagnosticMessage _createDiagnosticMessage( |
| DiagnosticReporter reporter, ir.LocatedMessage message) { |
| SourceSpan sourceSpan = SourceSpan( |
| message.uri!, message.charOffset, message.charOffset + message.length); |
| return reporter.createMessage( |
| sourceSpan, MessageKind.GENERIC, {'text': message.problemMessage}); |
| } |
| |
| void reportLocatedMessage(DiagnosticReporter reporter, |
| ir.LocatedMessage message, List<ir.LocatedMessage>? context) { |
| DiagnosticMessage diagnosticMessage = |
| _createDiagnosticMessage(reporter, message); |
| List<DiagnosticMessage> infos = []; |
| for (ir.LocatedMessage message in context ?? const []) { |
| infos.add(_createDiagnosticMessage(reporter, message)); |
| } |
| reporter.reportError(diagnosticMessage, infos); |
| } |