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

Side by Side Diff: pkg/analyzer/lib/src/task/html.dart

Issue 1645643002: Replace isAppropriateFor with suitabilityFor and start using it (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 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 unified diff | Download patch
« no previous file with comments | « pkg/analyzer/lib/src/task/driver.dart ('k') | pkg/analyzer/lib/src/task/manager.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'; 10 import 'package:analyzer/src/generated/engine.dart';
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 */ 272 */
273 static const String CONTENT_INPUT_NAME = 'CONTENT_INPUT_NAME'; 273 static const String CONTENT_INPUT_NAME = 'CONTENT_INPUT_NAME';
274 274
275 /** 275 /**
276 * The task descriptor describing this kind of task. 276 * The task descriptor describing this kind of task.
277 */ 277 */
278 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( 278 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor(
279 'ParseHtmlTask', 279 'ParseHtmlTask',
280 createTask, 280 createTask,
281 buildInputs, 281 buildInputs,
282 <ResultDescriptor>[HTML_DOCUMENT, HTML_DOCUMENT_ERRORS, LINE_INFO]); 282 <ResultDescriptor>[HTML_DOCUMENT, HTML_DOCUMENT_ERRORS, LINE_INFO],
283 suitabilityFor: suitabilityFor);
283 284
284 /** 285 /**
285 * Initialize a newly created task to access the content of the source 286 * Initialize a newly created task to access the content of the source
286 * associated with the given [target] in the given [context]. 287 * associated with the given [target] in the given [context].
287 */ 288 */
288 ParseHtmlTask(InternalAnalysisContext context, AnalysisTarget target) 289 ParseHtmlTask(InternalAnalysisContext context, AnalysisTarget target)
289 : super(context, target); 290 : super(context, target);
290 291
291 @override 292 @override
292 TaskDescriptor get descriptor => DESCRIPTOR; 293 TaskDescriptor get descriptor => DESCRIPTOR;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 352
352 /** 353 /**
353 * Create a [ParseHtmlTask] based on the given [target] in the given [context] . 354 * Create a [ParseHtmlTask] based on the given [target] in the given [context] .
354 */ 355 */
355 static ParseHtmlTask createTask( 356 static ParseHtmlTask createTask(
356 AnalysisContext context, AnalysisTarget target) { 357 AnalysisContext context, AnalysisTarget target) {
357 return new ParseHtmlTask(context, target); 358 return new ParseHtmlTask(context, target);
358 } 359 }
359 360
360 /** 361 /**
362 * Return an indication of how suitable this task is for the given [target].
363 */
364 static TaskSuitability suitabilityFor(AnalysisTarget target) {
365 if (target is Source) {
366 String name = target.shortName;
367 if (name.endsWith(AnalysisEngine.SUFFIX_HTML) ||
368 name.endsWith(AnalysisEngine.SUFFIX_HTM)) {
369 return TaskSuitability.HIGHEST;
370 }
371 }
372 return TaskSuitability.NONE;
373 }
374
375 /**
361 * Compute [LineInfo] for the given [content]. 376 * Compute [LineInfo] for the given [content].
362 */ 377 */
363 static LineInfo _computeLineInfo(String content) { 378 static LineInfo _computeLineInfo(String content) {
364 List<int> lineStarts = StringUtilities.computeLineStarts(content); 379 List<int> lineStarts = StringUtilities.computeLineStarts(content);
365 return new LineInfo(lineStarts); 380 return new LineInfo(lineStarts);
366 } 381 }
367 } 382 }
368 383
369 /** 384 /**
370 * A fragment of a [DartScript]. 385 * A fragment of a [DartScript].
(...skipping 20 matching lines...) Expand all
391 * The content of the fragment. 406 * The content of the fragment.
392 */ 407 */
393 final String content; 408 final String content;
394 409
395 /** 410 /**
396 * Initialize a newly created script fragment to have the given [offset] and 411 * Initialize a newly created script fragment to have the given [offset] and
397 * [content]. 412 * [content].
398 */ 413 */
399 ScriptFragment(this.offset, this.line, this.column, this.content); 414 ScriptFragment(this.offset, this.line, this.column, this.content);
400 } 415 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/task/driver.dart ('k') | pkg/analyzer/lib/src/task/manager.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698