| Index: pkg/front_end/lib/src/base/processed_options.dart
|
| diff --git a/pkg/front_end/lib/src/base/processed_options.dart b/pkg/front_end/lib/src/base/processed_options.dart
|
| index d525d15ed294e48cb269033c4a57ef3ae2fa9fc4..ebca33cc89a31ea5b6a34df4f445ac04169fa01a 100644
|
| --- a/pkg/front_end/lib/src/base/processed_options.dart
|
| +++ b/pkg/front_end/lib/src/base/processed_options.dart
|
| @@ -8,6 +8,7 @@ import 'package:front_end/compilation_error.dart';
|
| import 'package:front_end/compiler_options.dart';
|
| import 'package:front_end/file_system.dart';
|
| import 'package:front_end/src/base/performace_logger.dart';
|
| +import 'package:front_end/src/fasta/fasta_codes.dart';
|
| import 'package:front_end/src/fasta/ticker.dart';
|
| import 'package:front_end/src/fasta/translate_uri.dart';
|
| import 'package:front_end/src/incremental/byte_store.dart';
|
| @@ -17,7 +18,7 @@ import 'package:kernel/kernel.dart'
|
| import 'package:kernel/target/targets.dart';
|
| import 'package:kernel/target/vm_fasta.dart';
|
| import 'package:package_config/packages_file.dart' as package_config;
|
| -import 'package:source_span/source_span.dart' show SourceSpan;
|
| +import 'package:source_span/source_span.dart' show SourceSpan, SourceLocation;
|
|
|
| /// All options needed for the front end implementation.
|
| ///
|
| @@ -108,38 +109,41 @@ class ProcessedOptions {
|
| return _raw.byteStore;
|
| }
|
|
|
| - // TODO(sigmund): delete. We should use messages with error codes directly
|
| - // instead.
|
| - void reportError(String message) {
|
| - _raw.onError(new _CompilationError(message));
|
| + void reportMessage(LocatedMessage message) {
|
| + _raw.onError(new _CompilationMessage(message));
|
| }
|
|
|
| + void reportMessageNoLocation(Message message) =>
|
| + reportMessage(message.withLocation(null, -1));
|
| +
|
| /// Runs various validations checks on the input options. For instance,
|
| /// if an option is a path to a file, it checks that the file exists.
|
| Future<bool> validateOptions() async {
|
| for (var source in inputs) {
|
| if (source.scheme == 'file' &&
|
| !await fileSystem.entityForUri(source).exists()) {
|
| - reportError("Entry-point file not found: $source");
|
| + reportMessageNoLocation(
|
| + templateMissingInputFile.withArguments('$source'));
|
| return false;
|
| }
|
| }
|
|
|
| if (_raw.sdkRoot != null &&
|
| !await fileSystem.entityForUri(sdkRoot).exists()) {
|
| - reportError("SDK root directory not found: ${sdkRoot}");
|
| + reportMessageNoLocation(templateMissingSdkRoot.withArguments('$sdkRoot'));
|
| return false;
|
| }
|
|
|
| var summary = sdkSummary;
|
| if (summary != null && !await fileSystem.entityForUri(summary).exists()) {
|
| - reportError("SDK summary not found: ${summary}");
|
| + reportMessageNoLocation(
|
| + templateMissingSdkSummary.withArguments('$summary'));
|
| return false;
|
| }
|
|
|
| if (compileSdk && summary != null) {
|
| - reportError(
|
| - "The compileSdk and sdkSummary options are mutually exclusive");
|
| + reportMessageNoLocation(templateUnsupported.withArguments(
|
| + "The compileSdk and sdkSummary options are mutually exclusive"));
|
| return false;
|
| }
|
| return true;
|
| @@ -343,12 +347,19 @@ class HermeticAccessException extends FileSystemException {
|
| String toString() => message;
|
| }
|
|
|
| -/// An error that only contains a message and no error location.
|
| -class _CompilationError implements CompilationError {
|
| - String get correction => null;
|
| - SourceSpan get span => null;
|
| - final String message;
|
| - _CompilationError(this.message);
|
| +/// Wraps a [LocatedMessage] to implement the public [CompilationError] API.
|
| +class _CompilationMessage implements CompilationError {
|
| + final LocatedMessage original;
|
| +
|
| + String get message => original.message;
|
| +
|
| + String get tip => original.tip;
|
| +
|
| + SourceSpan get span =>
|
| + new SourceLocation(original.charOffset, sourceUrl: original.uri)
|
| + .pointSpan();
|
| +
|
| + _CompilationMessage(this.original);
|
|
|
| String toString() => message;
|
| }
|
|
|