Index: pkg/analyzer/lib/src/task/options.dart |
diff --git a/pkg/analyzer/lib/src/task/options.dart b/pkg/analyzer/lib/src/task/options.dart |
index 80ac44f714593cafc19bd5acfeb3558165b3b79b..9f22f7f647aec59ebd23f567d3067a99073e2c09 100644 |
--- a/pkg/analyzer/lib/src/task/options.dart |
+++ b/pkg/analyzer/lib/src/task/options.dart |
@@ -48,7 +48,7 @@ class GenerateOptionsErrorsTask extends SourceBasedAnalysisTask { |
'GenerateOptionsErrorsTask', |
createTask, |
buildInputs, |
- <ResultDescriptor>[ANALYSIS_OPTIONS_ERRORS]); |
+ <ResultDescriptor>[ANALYSIS_OPTIONS_ERRORS, LINE_INFO]); |
final AnalysisOptionsProvider optionsProvider = new AnalysisOptionsProvider(); |
@@ -81,6 +81,7 @@ class GenerateOptionsErrorsTask extends SourceBasedAnalysisTask { |
// Record outputs. |
// |
outputs[ANALYSIS_OPTIONS_ERRORS] = errors; |
+ outputs[LINE_INFO] = _computeLineInfo(content); |
} |
List<AnalysisError> _validate(Map<String, YamlNode> options) => |
@@ -96,6 +97,17 @@ class GenerateOptionsErrorsTask extends SourceBasedAnalysisTask { |
static GenerateOptionsErrorsTask createTask( |
AnalysisContext context, AnalysisTarget target) => |
new GenerateOptionsErrorsTask(context, target); |
+ |
+ /// Compute [LineInfo] for the given [content]. |
+ static LineInfo _computeLineInfo(String content) { |
+ List<int> lineStarts = <int>[0]; |
+ for (int index = 0; index < content.length; index++) { |
+ if (content.codeUnitAt(index) == 0x0A) { |
Brian Wilkerson
2015/10/27 13:18:29
For Dart files we accept either CR, CR/LF, or LF a
pquitslund
2015/10/27 15:31:44
I was folllowing HTML's suit but this is not a bad
Brian Wilkerson
2015/10/27 15:59:44
We compute line info while scanning, as part of th
|
+ lineStarts.add(index + 1); |
+ } |
+ } |
+ return new LineInfo(lineStarts); |
+ } |
} |
/// Validates `linter` top-level options. |