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; |
11 import 'package:analyzer/src/generated/error.dart'; | 11 import 'package:analyzer/src/generated/error.dart'; |
12 import 'package:analyzer/src/generated/java_engine.dart'; | 12 import 'package:analyzer/src/generated/java_engine.dart'; |
13 import 'package:analyzer/src/generated/scanner.dart'; | 13 import 'package:analyzer/src/generated/scanner.dart'; |
14 import 'package:analyzer/src/generated/source.dart'; | 14 import 'package:analyzer/src/generated/source.dart'; |
| 15 import 'package:analyzer/src/generated/utilities_string.dart'; |
15 import 'package:analyzer/src/plugin/engine_plugin.dart'; | 16 import 'package:analyzer/src/plugin/engine_plugin.dart'; |
16 import 'package:analyzer/src/task/general.dart'; | 17 import 'package:analyzer/src/task/general.dart'; |
17 import 'package:analyzer/task/dart.dart'; | 18 import 'package:analyzer/task/dart.dart'; |
18 import 'package:analyzer/task/general.dart'; | 19 import 'package:analyzer/task/general.dart'; |
19 import 'package:analyzer/task/html.dart'; | 20 import 'package:analyzer/task/html.dart'; |
20 import 'package:analyzer/task/model.dart'; | 21 import 'package:analyzer/task/model.dart'; |
21 import 'package:html/dom.dart'; | 22 import 'package:html/dom.dart'; |
22 import 'package:html/parser.dart'; | 23 import 'package:html/parser.dart'; |
23 import 'package:source_span/source_span.dart'; | 24 import 'package:source_span/source_span.dart'; |
24 | 25 |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 */ | 354 */ |
354 static ParseHtmlTask createTask( | 355 static ParseHtmlTask createTask( |
355 AnalysisContext context, AnalysisTarget target) { | 356 AnalysisContext context, AnalysisTarget target) { |
356 return new ParseHtmlTask(context, target); | 357 return new ParseHtmlTask(context, target); |
357 } | 358 } |
358 | 359 |
359 /** | 360 /** |
360 * Compute [LineInfo] for the given [content]. | 361 * Compute [LineInfo] for the given [content]. |
361 */ | 362 */ |
362 static LineInfo _computeLineInfo(String content) { | 363 static LineInfo _computeLineInfo(String content) { |
363 List<int> lineStarts = <int>[0]; | 364 List<int> lineStarts = 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); | 365 return new LineInfo(lineStarts); |
370 } | 366 } |
371 } | 367 } |
372 | 368 |
373 /** | 369 /** |
374 * A fragment of a [DartScript]. | 370 * A fragment of a [DartScript]. |
375 */ | 371 */ |
376 class ScriptFragment { | 372 class ScriptFragment { |
377 /** | 373 /** |
378 * The offset of the first character of the fragment, relative to the start of | 374 * 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. | 391 * The content of the fragment. |
396 */ | 392 */ |
397 final String content; | 393 final String content; |
398 | 394 |
399 /** | 395 /** |
400 * Initialize a newly created script fragment to have the given [offset] and | 396 * Initialize a newly created script fragment to have the given [offset] and |
401 * [content]. | 397 * [content]. |
402 */ | 398 */ |
403 ScriptFragment(this.offset, this.line, this.column, this.content); | 399 ScriptFragment(this.offset, this.line, this.column, this.content); |
404 } | 400 } |
OLD | NEW |