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

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

Issue 1902123005: Use MODIFICATION_TIME in ScanDartTask and ParseHtmlTask. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 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/dart.dart ('k') | pkg/analyzer/test/src/task/html_test.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/dart/scanner/scanner.dart'; 10 import 'package:analyzer/src/dart/scanner/scanner.dart';
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 /** 262 /**
263 * A task that scans the content of a file, producing a set of Dart tokens. 263 * A task that scans the content of a file, producing a set of Dart tokens.
264 */ 264 */
265 class ParseHtmlTask extends SourceBasedAnalysisTask { 265 class ParseHtmlTask extends SourceBasedAnalysisTask {
266 /** 266 /**
267 * The name of the input whose value is the content of the file. 267 * The name of the input whose value is the content of the file.
268 */ 268 */
269 static const String CONTENT_INPUT_NAME = 'CONTENT_INPUT_NAME'; 269 static const String CONTENT_INPUT_NAME = 'CONTENT_INPUT_NAME';
270 270
271 /** 271 /**
272 * The name of the input whose value is the modification time of the file.
273 */
274 static const String MODIFICATION_TIME_INPUT = 'MODIFICATION_TIME_INPUT';
275
276 /**
272 * The task descriptor describing this kind of task. 277 * The task descriptor describing this kind of task.
273 */ 278 */
274 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( 279 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor(
275 'ParseHtmlTask', 280 'ParseHtmlTask',
276 createTask, 281 createTask,
277 buildInputs, 282 buildInputs,
278 <ResultDescriptor>[HTML_DOCUMENT, HTML_DOCUMENT_ERRORS, LINE_INFO], 283 <ResultDescriptor>[HTML_DOCUMENT, HTML_DOCUMENT_ERRORS, LINE_INFO],
279 suitabilityFor: suitabilityFor); 284 suitabilityFor: suitabilityFor);
280 285
281 /** 286 /**
282 * Initialize a newly created task to access the content of the source 287 * Initialize a newly created task to access the content of the source
283 * associated with the given [target] in the given [context]. 288 * associated with the given [target] in the given [context].
284 */ 289 */
285 ParseHtmlTask(InternalAnalysisContext context, AnalysisTarget target) 290 ParseHtmlTask(InternalAnalysisContext context, AnalysisTarget target)
286 : super(context, target); 291 : super(context, target);
287 292
288 @override 293 @override
289 TaskDescriptor get descriptor => DESCRIPTOR; 294 TaskDescriptor get descriptor => DESCRIPTOR;
290 295
291 @override 296 @override
292 void internalPerform() { 297 void internalPerform() {
293 String content = getRequiredInput(CONTENT_INPUT_NAME); 298 String content = getRequiredInput(CONTENT_INPUT_NAME);
294 299
295 if (context.getModificationStamp(target.source) < 0) { 300 int modificationTime = getRequiredInput(MODIFICATION_TIME_INPUT);
301 if (modificationTime < 0) {
296 String message = 'Content could not be read'; 302 String message = 'Content could not be read';
297 if (context is InternalAnalysisContext) { 303 if (context is InternalAnalysisContext) {
298 CacheEntry entry = 304 CacheEntry entry =
299 (context as InternalAnalysisContext).getCacheEntry(target); 305 (context as InternalAnalysisContext).getCacheEntry(target);
300 CaughtException exception = entry.exception; 306 CaughtException exception = entry.exception;
301 if (exception != null) { 307 if (exception != null) {
302 message = exception.toString(); 308 message = exception.toString();
303 } 309 }
304 } 310 }
305 311
(...skipping 30 matching lines...) Expand all
336 outputs[LINE_INFO] = _computeLineInfo(content); 342 outputs[LINE_INFO] = _computeLineInfo(content);
337 } 343 }
338 } 344 }
339 345
340 /** 346 /**
341 * Return a map from the names of the inputs of this kind of task to the task 347 * Return a map from the names of the inputs of this kind of task to the task
342 * input descriptors describing those inputs for a task with the given 348 * input descriptors describing those inputs for a task with the given
343 * [source]. 349 * [source].
344 */ 350 */
345 static Map<String, TaskInput> buildInputs(AnalysisTarget source) { 351 static Map<String, TaskInput> buildInputs(AnalysisTarget source) {
346 return <String, TaskInput>{CONTENT_INPUT_NAME: CONTENT.of(source)}; 352 return <String, TaskInput>{
353 CONTENT_INPUT_NAME: CONTENT.of(source),
354 MODIFICATION_TIME_INPUT: MODIFICATION_TIME.of(source)
355 };
347 } 356 }
348 357
349 /** 358 /**
350 * Create a [ParseHtmlTask] based on the given [target] in the given [context] . 359 * Create a [ParseHtmlTask] based on the given [target] in the given [context] .
351 */ 360 */
352 static ParseHtmlTask createTask( 361 static ParseHtmlTask createTask(
353 AnalysisContext context, AnalysisTarget target) { 362 AnalysisContext context, AnalysisTarget target) {
354 return new ParseHtmlTask(context, target); 363 return new ParseHtmlTask(context, target);
355 } 364 }
356 365
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 * The content of the fragment. 411 * The content of the fragment.
403 */ 412 */
404 final String content; 413 final String content;
405 414
406 /** 415 /**
407 * Initialize a newly created script fragment to have the given [offset] and 416 * Initialize a newly created script fragment to have the given [offset] and
408 * [content]. 417 * [content].
409 */ 418 */
410 ScriptFragment(this.offset, this.line, this.column, this.content); 419 ScriptFragment(this.offset, this.line, this.column, this.content);
411 } 420 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/task/dart.dart ('k') | pkg/analyzer/test/src/task/html_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698