Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(108)

Unified Diff: pkg/dev_compiler/lib/src/compiler/error_helpers.dart

Issue 2757753002: Migrate DDC to the new analysis driver.
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..83fd38df3b653367c8fc845704a80106da7c0fe9 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.
//
@@ -60,8 +62,6 @@ ErrorSeverity errorSeverity(AnalysisContext context, AnalysisError error) {
// * 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;
}

Powered by Google App Engine
This is Rietveld 408576698