| 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 'package:analyzer/src/generated/engine.dart' hide AnalysisTask; | 7 import 'package:analyzer/src/generated/engine.dart' hide AnalysisTask; |
| 8 import 'package:analyzer/src/generated/source.dart'; | 8 import 'package:analyzer/src/generated/source.dart'; |
| 9 import 'package:analyzer/src/task/general.dart'; | 9 import 'package:analyzer/src/task/general.dart'; |
| 10 import 'package:analyzer/task/general.dart'; | 10 import 'package:analyzer/task/general.dart'; |
| 11 import 'package:analyzer/task/html.dart'; | 11 import 'package:analyzer/task/html.dart'; |
| 12 import 'package:analyzer/task/model.dart'; | 12 import 'package:analyzer/task/model.dart'; |
| 13 import 'package:html/dom.dart'; | 13 //import 'package:html/dom.dart'; |
| 14 import 'package:html/parser.dart'; | 14 //import 'package:html/parser.dart'; |
| 15 | 15 |
| 16 /** | 16 /** |
| 17 * A task that scans the content of a file, producing a set of Dart tokens. | 17 * A task that scans the content of a file, producing a set of Dart tokens. |
| 18 */ | 18 */ |
| 19 class ParseHtmlTask extends SourceBasedAnalysisTask { | 19 class ParseHtmlTask extends SourceBasedAnalysisTask { |
| 20 /** | 20 /** |
| 21 * The name of the input whose value is the content of the file. | 21 * The name of the input whose value is the content of the file. |
| 22 */ | 22 */ |
| 23 static const String CONTENT_INPUT_NAME = 'CONTENT_INPUT_NAME'; | 23 static const String CONTENT_INPUT_NAME = 'CONTENT_INPUT_NAME'; |
| 24 | 24 |
| 25 /** | 25 /** |
| 26 * The task descriptor describing this kind of task. | 26 * The task descriptor describing this kind of task. |
| 27 */ | 27 */ |
| 28 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor('ParseHtmlTask', | 28 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor('ParseHtmlTask', |
| 29 createTask, buildInputs, <ResultDescriptor>[DOCUMENT, DOCUMENT_ERRORS]); | 29 createTask, buildInputs, |
| 30 <ResultDescriptor>[/*DOCUMENT, DOCUMENT_ERRORS*/]); |
| 30 | 31 |
| 31 /** | 32 /** |
| 32 * Initialize a newly created task to access the content of the source | 33 * Initialize a newly created task to access the content of the source |
| 33 * associated with the given [target] in the given [context]. | 34 * associated with the given [target] in the given [context]. |
| 34 */ | 35 */ |
| 35 ParseHtmlTask(InternalAnalysisContext context, AnalysisTarget target) | 36 ParseHtmlTask(InternalAnalysisContext context, AnalysisTarget target) |
| 36 : super(context, target); | 37 : super(context, target); |
| 37 | 38 |
| 38 @override | 39 @override |
| 39 TaskDescriptor get descriptor => DESCRIPTOR; | 40 TaskDescriptor get descriptor => DESCRIPTOR; |
| 40 | 41 |
| 41 @override | 42 @override |
| 42 void internalPerform() { | 43 void internalPerform() { |
| 43 String content = getRequiredInput(CONTENT_INPUT_NAME); | 44 // String content = getRequiredInput(CONTENT_INPUT_NAME); |
| 44 | 45 // |
| 45 HtmlParser parser = new HtmlParser(content); | 46 // HtmlParser parser = new HtmlParser(content); |
| 46 Document document = parser.parse(); | 47 // Document document = parser.parse(); |
| 47 List<ParseError> errors = parser.errors; | 48 // List<ParseError> errors = parser.errors; |
| 48 | 49 // |
| 49 outputs[DOCUMENT] = document; | 50 // outputs[DOCUMENT] = document; |
| 50 outputs[DOCUMENT_ERRORS] = errors; | 51 // outputs[DOCUMENT_ERRORS] = errors; |
| 51 } | 52 } |
| 52 | 53 |
| 53 /** | 54 /** |
| 54 * Return a map from the names of the inputs of this kind of task to the task | 55 * Return a map from the names of the inputs of this kind of task to the task |
| 55 * input descriptors describing those inputs for a task with the given | 56 * input descriptors describing those inputs for a task with the given |
| 56 * [source]. | 57 * [source]. |
| 57 */ | 58 */ |
| 58 static Map<String, TaskInput> buildInputs(Source source) { | 59 static Map<String, TaskInput> buildInputs(Source source) { |
| 59 return <String, TaskInput>{CONTENT_INPUT_NAME: CONTENT.of(source)}; | 60 return <String, TaskInput>{CONTENT_INPUT_NAME: CONTENT.of(source)}; |
| 60 } | 61 } |
| 61 | 62 |
| 62 /** | 63 /** |
| 63 * Create a [ParseHtmlTask] based on the given [target] in the given [context]
. | 64 * Create a [ParseHtmlTask] based on the given [target] in the given [context]
. |
| 64 */ | 65 */ |
| 65 static ParseHtmlTask createTask( | 66 static ParseHtmlTask createTask( |
| 66 AnalysisContext context, AnalysisTarget target) { | 67 AnalysisContext context, AnalysisTarget target) { |
| 67 return new ParseHtmlTask(context, target); | 68 return new ParseHtmlTask(context, target); |
| 68 } | 69 } |
| 69 } | 70 } |
| OLD | NEW |