| Index: pkg/dev_compiler/lib/src/compiler/error_helpers.dart
|
| diff --git a/pkg/dev_compiler/lib/src/compiler/error_helpers.dart b/pkg/dev_compiler/lib/src/compiler/error_helpers.dart
|
| index ec730d341858c2d3aa99a3943894c3468b55998d..1d72e567fff38eb0f232c402063142c08bbbe805 100644
|
| --- a/pkg/dev_compiler/lib/src/compiler/error_helpers.dart
|
| +++ b/pkg/dev_compiler/lib/src/compiler/error_helpers.dart
|
| @@ -4,18 +4,19 @@
|
|
|
| import 'package:analyzer/analyzer.dart' show AnalysisError, ErrorSeverity;
|
| import 'package:analyzer/source/error_processor.dart' show ErrorProcessor;
|
| -import 'package:analyzer/src/generated/engine.dart' show AnalysisContext;
|
| +import 'package:analyzer/src/generated/engine.dart' show AnalysisOptions;
|
| +import 'package:analyzer/src/generated/source.dart';
|
| import 'package:path/path.dart' as path;
|
|
|
| -// TODO(jmesserly): this code was taken from analyzer_cli.
|
| -// It really should be in some common place so we can share it.
|
| -// TODO(jmesserly): this shouldn't depend on `context` but we need it to compute
|
| -// `errorSeverity` due to some APIs that need fixing.
|
| -void sortErrors(AnalysisContext context, List<AnalysisError> errors) {
|
| +/// TODO(jmesserly): this code was taken from analyzer_cli.
|
| +/// It really should be in some common place so we can share it.
|
| +/// TODO(jmesserly): this shouldn't depend on `context` but we need it to compute
|
| +/// `errorSeverity` due to some APIs that need fixing.
|
| +void sortErrors(AnalysisOptions analysisOptions, List<AnalysisError> errors) {
|
| errors.sort((AnalysisError error1, AnalysisError error2) {
|
| // severity
|
| - var severity1 = errorSeverity(context, error1);
|
| - var severity2 = errorSeverity(context, error2);
|
| + var severity1 = errorSeverity(analysisOptions, error1);
|
| + var severity2 = errorSeverity(analysisOptions, error2);
|
| int compare = severity2.compareTo(severity1);
|
| if (compare != 0) return compare;
|
|
|
| @@ -33,13 +34,13 @@ void sortErrors(AnalysisContext context, List<AnalysisError> errors) {
|
| });
|
| }
|
|
|
| -// TODO(jmesserly): this was from analyzer_cli, we should factor it differently.
|
| -String formatError(AnalysisContext context, AnalysisError error) {
|
| - var severity = errorSeverity(context, error);
|
| +/// TODO(jmesserly): this was from analyzer_cli, we should factor it differently.
|
| +String formatError(
|
| + AnalysisOptions analysisOptions, LineInfo lineInfo, AnalysisError error) {
|
| + var severity = errorSeverity(analysisOptions, error);
|
| // Skip hints, some like TODOs are not useful.
|
| if (severity.ordinal <= ErrorSeverity.INFO.ordinal) return null;
|
|
|
| - var lineInfo = context.computeLineInfo(error.source);
|
| var location = lineInfo.getLocation(error.offset);
|
|
|
| // [warning] 'foo' is not a... (/Users/.../tmp/foo.dart, line 1, col 2)
|
| @@ -51,7 +52,8 @@ String formatError(AnalysisContext context, AnalysisError error) {
|
| .toString();
|
| }
|
|
|
| -ErrorSeverity errorSeverity(AnalysisContext context, AnalysisError error) {
|
| +ErrorSeverity errorSeverity(
|
| + AnalysisOptions analysisOptions, AnalysisError error) {
|
| // TODO(jmesserly): this Analyzer API totally bonkers, but it's what
|
| // analyzer_cli and server use.
|
| //
|
| @@ -59,9 +61,6 @@ ErrorSeverity errorSeverity(AnalysisContext context, AnalysisError error) {
|
| // * it needs to be called per-error, so it's a performance trap.
|
| // * it can return null
|
| // * using AnalysisError directly is now suspect, it's a correctness trap
|
| - // * it requires an AnalysisContext
|
| - return ErrorProcessor
|
| - .getProcessor(context.analysisOptions, error)
|
| - ?.severity ??
|
| + return ErrorProcessor.getProcessor(analysisOptions, error)?.severity ??
|
| error.errorCode.errorSeverity;
|
| }
|
|
|