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

Side by Side Diff: pkg/analyzer/lib/src/task/html.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, 1 month 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 unified diff | Download patch
« no previous file with comments | « pkg/analyzer/lib/src/generated/java_engine.dart ('k') | pkg/analyzer/lib/src/task/options.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 analyzer.src.task.html; 5 library analyzer.src.task.html;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analyzer/src/context/cache.dart'; 9 import 'package:analyzer/src/context/cache.dart';
10 import 'package:analyzer/src/generated/engine.dart' hide AnalysisTask; 10 import 'package:analyzer/src/generated/engine.dart' hide AnalysisTask;
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 */ 353 */
354 static ParseHtmlTask createTask( 354 static ParseHtmlTask createTask(
355 AnalysisContext context, AnalysisTarget target) { 355 AnalysisContext context, AnalysisTarget target) {
356 return new ParseHtmlTask(context, target); 356 return new ParseHtmlTask(context, target);
357 } 357 }
358 358
359 /** 359 /**
360 * Compute [LineInfo] for the given [content]. 360 * Compute [LineInfo] for the given [content].
361 */ 361 */
362 static LineInfo _computeLineInfo(String content) { 362 static LineInfo _computeLineInfo(String content) {
363 List<int> lineStarts = <int>[0]; 363 List<int> lineStarts = StringUtilities.computeLineStarts(content);
364 for (int index = 0; index < content.length; index++) {
365 if (content.codeUnitAt(index) == 0x0A) {
366 lineStarts.add(index + 1);
367 }
368 }
369 return new LineInfo(lineStarts); 364 return new LineInfo(lineStarts);
370 } 365 }
371 } 366 }
372 367
373 /** 368 /**
374 * A fragment of a [DartScript]. 369 * A fragment of a [DartScript].
375 */ 370 */
376 class ScriptFragment { 371 class ScriptFragment {
377 /** 372 /**
378 * The offset of the first character of the fragment, relative to the start of 373 * The offset of the first character of the fragment, relative to the start of
(...skipping 16 matching lines...) Expand all
395 * The content of the fragment. 390 * The content of the fragment.
396 */ 391 */
397 final String content; 392 final String content;
398 393
399 /** 394 /**
400 * Initialize a newly created script fragment to have the given [offset] and 395 * Initialize a newly created script fragment to have the given [offset] and
401 * [content]. 396 * [content].
402 */ 397 */
403 ScriptFragment(this.offset, this.line, this.column, this.content); 398 ScriptFragment(this.offset, this.line, this.column, this.content);
404 } 399 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/java_engine.dart ('k') | pkg/analyzer/lib/src/task/options.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698