| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |