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

Unified Diff: pkg/analyzer/lib/src/task/options.dart

Issue 1411253007: Extract 'computeLineStarts' utility. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Move into StringUtilities. Created 5 years, 2 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/analyzer/lib/src/task/html.dart ('k') | pkg/analyzer/test/generated/utilities_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 5f8946efcfa074658218c01a7e31c2146f703319..51a8f9bd53d1daa9d5eaad51bc8528387d22fa9e 100644
--- a/pkg/analyzer/lib/src/task/options.dart
+++ b/pkg/analyzer/lib/src/task/options.dart
@@ -8,6 +8,7 @@ import 'package:analyzer/analyzer.dart';
import 'package:analyzer/plugin/options.dart';
import 'package:analyzer/source/analysis_options_provider.dart';
import 'package:analyzer/src/generated/engine.dart';
+import 'package:analyzer/src/generated/java_engine.dart';
import 'package:analyzer/src/generated/source.dart';
import 'package:analyzer/src/task/general.dart';
import 'package:analyzer/task/general.dart';
@@ -95,25 +96,7 @@ class GenerateOptionsErrorsTask extends SourceBasedAnalysisTask {
/// Compute [LineInfo] for the given [content].
static LineInfo computeLineInfo(String content) {
- List<int> lineStarts = <int>[0];
- int length = content.length;
- int unit;
- for (int index = 0; index < length; index++) {
- unit = content.codeUnitAt(index);
- // Special-case \r\n.
- if (unit == 0x0D /* \r */) {
- // Peek ahead to detect a following \n.
- if ((index + 1 < length) && content.codeUnitAt(index + 1) == 0x0A) {
- // Line start will get registered at next index at the \n.
- } else {
- lineStarts.add(index + 1);
- }
- }
-
- if (unit == 0x0A) {
- lineStarts.add(index + 1);
- }
- }
+ List<int> lineStarts = StringUtilities.computeLineStarts(content);
return new LineInfo(lineStarts);
}
« no previous file with comments | « pkg/analyzer/lib/src/task/html.dart ('k') | pkg/analyzer/test/generated/utilities_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698