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

Unified Diff: pkg/analysis_server/lib/src/computer/error.dart

Issue 486003003: Start using code-generated protocol classes in analysis server. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 4 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
« no previous file with comments | « pkg/analysis_server/lib/src/analysis_server.dart ('k') | pkg/analysis_server/lib/src/domain_analysis.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/lib/src/computer/error.dart
diff --git a/pkg/analysis_server/lib/src/computer/error.dart b/pkg/analysis_server/lib/src/computer/error.dart
index 5a457c5b114fe91836380cf46f4d392857960899..8fcf6d26dab37f1940c1f4ec763a82ffd2a755a1 100644
--- a/pkg/analysis_server/lib/src/computer/error.dart
+++ b/pkg/analysis_server/lib/src/computer/error.dart
@@ -4,9 +4,7 @@
library computer.error;
-import 'package:analysis_server/src/computer/element.dart';
-import 'package:analysis_server/src/constants.dart';
-import 'package:analysis_server/src/services/json.dart';
+import 'package:analysis_server/src/protocol2.dart';
import 'package:analyzer/src/generated/engine.dart' as engine;
import 'package:analyzer/src/generated/error.dart' as engine;
import 'package:analyzer/src/generated/source.dart' as engine;
@@ -26,79 +24,36 @@ List<Map<String, Object>> engineErrorInfoToJson(engine.AnalysisErrorInfo info) {
List<Map<String, Object>> engineErrorsToJson(engine.LineInfo lineInfo,
List<engine.AnalysisError> errors) {
return errors.map((engine.AnalysisError error) {
- return new AnalysisError.fromEngine(lineInfo, error).toJson();
+ return analysisErrorFromEngine(lineInfo, error).toJson();
}).toList();
}
-/**
- * An indication of an error, warning, or hint that was produced by the
- * analysis. 
- */
-class AnalysisError implements HasToJson {
- final String severity;
- final String type;
- final Location location;
- final String message;
- final String correction;
-
- AnalysisError(this.severity, this.type, this.location, this.message,
- this.correction);
-
- factory AnalysisError.fromEngine(engine.LineInfo lineInfo,
- engine.AnalysisError error) {
- engine.ErrorCode errorCode = error.errorCode;
- // prepare location
- Location location;
- {
- String file = error.source.fullName;
- int offset = error.offset;
- int length = error.length;
- int startLine = -1;
- int startColumn = -1;
- if (lineInfo != null) {
- engine.LineInfo_Location lineLocation = lineInfo.getLocation(offset);
- if (lineLocation != null) {
- startLine = lineLocation.lineNumber;
- startColumn = lineLocation.columnNumber;
- }
+AnalysisError analysisErrorFromEngine(engine.LineInfo lineInfo,
+ engine.AnalysisError error) {
+ engine.ErrorCode errorCode = error.errorCode;
+ // prepare location
+ Location location;
+ {
+ String file = error.source.fullName;
+ int offset = error.offset;
+ int length = error.length;
+ int startLine = -1;
+ int startColumn = -1;
+ if (lineInfo != null) {
+ engine.LineInfo_Location lineLocation = lineInfo.getLocation(offset);
+ if (lineLocation != null) {
+ startLine = lineLocation.lineNumber;
+ startColumn = lineLocation.columnNumber;
}
- location = new Location(file, offset, length, startLine, startColumn);
}
- // done
- String severity = errorCode.errorSeverity.toString();
- String type = errorCode.type.toString();
- String message = error.message;
- String correction = error.correction;
- return new AnalysisError(severity, type, location, message, correction);
- }
-
- @override
- Map<String, Object> toJson() {
- Map<String, Object> json = {
- SEVERITY: severity,
- TYPE: type,
- LOCATION: location.toJson(),
- MESSAGE: message
- };
- if (correction != null) {
- json[CORRECTION] = correction;
- }
- return json;
- }
-
- @override
- String toString() {
- return 'AnalysisError(location=$location message=$message; '
- 'severity=$severity; type=$type; correction=$correction';
- }
-
- static AnalysisError fromJson(Map<String, Object> json) {
- return new AnalysisError(
- json[SEVERITY],
- json[TYPE],
- new Location.fromJson(json[LOCATION]),
- json[MESSAGE],
- json[CORRECTION]);
+ location = new Location(file, offset, length, startLine, startColumn);
}
+ // done
+ var severity = new ErrorSeverity(errorCode.errorSeverity.name);
+ var type = new ErrorType(errorCode.type.name);
+ String message = error.message;
+ String correction = error.correction;
+ return new AnalysisError(severity, type, location, message,
+ correction: correction);
}
« no previous file with comments | « pkg/analysis_server/lib/src/analysis_server.dart ('k') | pkg/analysis_server/lib/src/domain_analysis.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698