| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library protocol.server; | 5 library protocol.server; |
| 6 | 6 |
| 7 import 'package:analysis_server/plugin/protocol/protocol.dart'; | 7 import 'package:analysis_server/plugin/protocol/protocol.dart'; |
| 8 import 'package:analysis_server/plugin/protocol/protocol_dart.dart'; | 8 import 'package:analysis_server/plugin/protocol/protocol_dart.dart'; |
| 9 import 'package:analysis_server/src/services/correction/fix.dart'; | 9 import 'package:analysis_server/src/services/correction/fix.dart'; |
| 10 import 'package:analysis_server/src/services/search/search_engine.dart' | 10 import 'package:analysis_server/src/services/search/search_engine.dart' |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 if (lineInfo != null) { | 104 if (lineInfo != null) { |
| 105 engine.LineInfo_Location lineLocation = lineInfo.getLocation(offset); | 105 engine.LineInfo_Location lineLocation = lineInfo.getLocation(offset); |
| 106 if (lineLocation != null) { | 106 if (lineLocation != null) { |
| 107 startLine = lineLocation.lineNumber; | 107 startLine = lineLocation.lineNumber; |
| 108 startColumn = lineLocation.columnNumber; | 108 startColumn = lineLocation.columnNumber; |
| 109 } | 109 } |
| 110 } | 110 } |
| 111 location = new Location(file, offset, length, startLine, startColumn); | 111 location = new Location(file, offset, length, startLine, startColumn); |
| 112 } | 112 } |
| 113 | 113 |
| 114 // Deafult to the error's severity if none is specified. | 114 // Default to the error's severity if none is specified. |
| 115 errorSeverity ??= errorCode.errorSeverity; | 115 errorSeverity ??= errorCode.errorSeverity; |
| 116 | 116 |
| 117 // done | 117 // done |
| 118 var severity = new AnalysisErrorSeverity(errorSeverity.name); | 118 var severity = new AnalysisErrorSeverity(errorSeverity.name); |
| 119 var type = new AnalysisErrorType(errorCode.type.name); | 119 var type = new AnalysisErrorType(errorCode.type.name); |
| 120 String message = error.message; | 120 String message = error.message; |
| 121 String code = errorCode.name.toLowerCase(); |
| 121 String correction = error.correction; | 122 String correction = error.correction; |
| 122 bool fix = hasFix(error.errorCode); | 123 bool fix = hasFix(error.errorCode); |
| 123 return new AnalysisError(severity, type, location, message, | 124 return new AnalysisError(severity, type, location, message, code, |
| 124 correction: correction, hasFix: fix); | 125 correction: correction, hasFix: fix); |
| 125 } | 126 } |
| 126 | 127 |
| 127 /** | 128 /** |
| 128 * Create a Location based on an [engine.Element]. | 129 * Create a Location based on an [engine.Element]. |
| 129 */ | 130 */ |
| 130 Location newLocation_fromElement(engine.Element element) { | 131 Location newLocation_fromElement(engine.Element element) { |
| 131 engine.AnalysisContext context = element.context; | 132 engine.AnalysisContext context = element.context; |
| 132 engine.Source source = element.source; | 133 engine.Source source = element.source; |
| 133 if (context == null || source == null) { | 134 if (context == null || source == null) { |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 if (lineInfo != null) { | 257 if (lineInfo != null) { |
| 257 engine.LineInfo_Location offsetLocation = | 258 engine.LineInfo_Location offsetLocation = |
| 258 lineInfo.getLocation(range.offset); | 259 lineInfo.getLocation(range.offset); |
| 259 startLine = offsetLocation.lineNumber; | 260 startLine = offsetLocation.lineNumber; |
| 260 startColumn = offsetLocation.columnNumber; | 261 startColumn = offsetLocation.columnNumber; |
| 261 } | 262 } |
| 262 } | 263 } |
| 263 return new Location( | 264 return new Location( |
| 264 source.fullName, range.offset, range.length, startLine, startColumn); | 265 source.fullName, range.offset, range.length, startLine, startColumn); |
| 265 } | 266 } |
| OLD | NEW |