| 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.dart; | 5 library analyzer.src.task.dart; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 import 'dart:math' as math; | 8 import 'dart:math' as math; |
| 9 | 9 |
| 10 import 'package:analyzer/src/context/cache.dart'; | 10 import 'package:analyzer/src/context/cache.dart'; |
| (...skipping 2561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2572 * A task that parses the content of a Dart file, producing an AST structure. | 2572 * A task that parses the content of a Dart file, producing an AST structure. |
| 2573 */ | 2573 */ |
| 2574 class ParseDartTask extends SourceBasedAnalysisTask { | 2574 class ParseDartTask extends SourceBasedAnalysisTask { |
| 2575 /** | 2575 /** |
| 2576 * The name of the input whose value is the line information produced for the | 2576 * The name of the input whose value is the line information produced for the |
| 2577 * file. | 2577 * file. |
| 2578 */ | 2578 */ |
| 2579 static const String LINE_INFO_INPUT_NAME = 'LINE_INFO_INPUT_NAME'; | 2579 static const String LINE_INFO_INPUT_NAME = 'LINE_INFO_INPUT_NAME'; |
| 2580 | 2580 |
| 2581 /** | 2581 /** |
| 2582 * The name of the input whose value is the modification time of the file. |
| 2583 */ |
| 2584 static const String MODIFICATION_TIME_INPUT_NAME = |
| 2585 'MODIFICATION_TIME_INPUT_NAME'; |
| 2586 |
| 2587 /** |
| 2582 * The name of the input whose value is the token stream produced for the file
. | 2588 * The name of the input whose value is the token stream produced for the file
. |
| 2583 */ | 2589 */ |
| 2584 static const String TOKEN_STREAM_INPUT_NAME = 'TOKEN_STREAM_INPUT_NAME'; | 2590 static const String TOKEN_STREAM_INPUT_NAME = 'TOKEN_STREAM_INPUT_NAME'; |
| 2585 | 2591 |
| 2586 /** | 2592 /** |
| 2587 * The task descriptor describing this kind of task. | 2593 * The task descriptor describing this kind of task. |
| 2588 */ | 2594 */ |
| 2589 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor('ParseDartTask', | 2595 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor('ParseDartTask', |
| 2590 createTask, buildInputs, <ResultDescriptor>[ | 2596 createTask, buildInputs, <ResultDescriptor>[ |
| 2591 EXPLICITLY_IMPORTED_LIBRARIES, | 2597 EXPLICITLY_IMPORTED_LIBRARIES, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2605 ParseDartTask(InternalAnalysisContext context, AnalysisTarget target) | 2611 ParseDartTask(InternalAnalysisContext context, AnalysisTarget target) |
| 2606 : super(context, target); | 2612 : super(context, target); |
| 2607 | 2613 |
| 2608 @override | 2614 @override |
| 2609 TaskDescriptor get descriptor => DESCRIPTOR; | 2615 TaskDescriptor get descriptor => DESCRIPTOR; |
| 2610 | 2616 |
| 2611 @override | 2617 @override |
| 2612 void internalPerform() { | 2618 void internalPerform() { |
| 2613 Source source = getRequiredSource(); | 2619 Source source = getRequiredSource(); |
| 2614 LineInfo lineInfo = getRequiredInput(LINE_INFO_INPUT_NAME); | 2620 LineInfo lineInfo = getRequiredInput(LINE_INFO_INPUT_NAME); |
| 2621 int modificationTime = getRequiredInput(MODIFICATION_TIME_INPUT_NAME); |
| 2615 Token tokenStream = getRequiredInput(TOKEN_STREAM_INPUT_NAME); | 2622 Token tokenStream = getRequiredInput(TOKEN_STREAM_INPUT_NAME); |
| 2616 | 2623 |
| 2617 RecordingErrorListener errorListener = new RecordingErrorListener(); | 2624 RecordingErrorListener errorListener = new RecordingErrorListener(); |
| 2618 Parser parser = new Parser(source, errorListener); | 2625 Parser parser = new Parser(source, errorListener); |
| 2619 AnalysisOptions options = context.analysisOptions; | 2626 AnalysisOptions options = context.analysisOptions; |
| 2620 parser.parseFunctionBodies = options.analyzeFunctionBodiesPredicate(source); | 2627 parser.parseFunctionBodies = options.analyzeFunctionBodiesPredicate(source); |
| 2621 CompilationUnit unit = parser.parseCompilationUnit(tokenStream); | 2628 CompilationUnit unit = parser.parseCompilationUnit(tokenStream); |
| 2622 unit.lineInfo = lineInfo; | 2629 unit.lineInfo = lineInfo; |
| 2623 | 2630 |
| 2624 bool hasNonPartOfDirective = false; | 2631 bool hasNonPartOfDirective = false; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 2655 // Always include "dart:core" source. | 2662 // Always include "dart:core" source. |
| 2656 // | 2663 // |
| 2657 HashSet<Source> importedSourceSet = | 2664 HashSet<Source> importedSourceSet = |
| 2658 new HashSet.from(explicitlyImportedSourceSet); | 2665 new HashSet.from(explicitlyImportedSourceSet); |
| 2659 Source coreLibrarySource = context.sourceFactory.forUri(DartSdk.DART_CORE); | 2666 Source coreLibrarySource = context.sourceFactory.forUri(DartSdk.DART_CORE); |
| 2660 importedSourceSet.add(coreLibrarySource); | 2667 importedSourceSet.add(coreLibrarySource); |
| 2661 // | 2668 // |
| 2662 // Compute kind. | 2669 // Compute kind. |
| 2663 // | 2670 // |
| 2664 SourceKind sourceKind = SourceKind.LIBRARY; | 2671 SourceKind sourceKind = SourceKind.LIBRARY; |
| 2665 if (!hasNonPartOfDirective && hasPartOfDirective) { | 2672 if (modificationTime == -1) { |
| 2673 sourceKind = SourceKind.UNKNOWN; |
| 2674 } else if (!hasNonPartOfDirective && hasPartOfDirective) { |
| 2666 sourceKind = SourceKind.PART; | 2675 sourceKind = SourceKind.PART; |
| 2667 } | 2676 } |
| 2668 // | 2677 // |
| 2669 // Record outputs. | 2678 // Record outputs. |
| 2670 // | 2679 // |
| 2671 List<Source> explicitlyImportedSources = | 2680 List<Source> explicitlyImportedSources = |
| 2672 explicitlyImportedSourceSet.toList(); | 2681 explicitlyImportedSourceSet.toList(); |
| 2673 List<Source> exportedSources = exportedSourceSet.toList(); | 2682 List<Source> exportedSources = exportedSourceSet.toList(); |
| 2674 List<Source> importedSources = importedSourceSet.toList(); | 2683 List<Source> importedSources = importedSourceSet.toList(); |
| 2675 List<Source> includedSources = includedSourceSet.toList(); | 2684 List<Source> includedSources = includedSourceSet.toList(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 2686 } | 2695 } |
| 2687 | 2696 |
| 2688 /** | 2697 /** |
| 2689 * Return a map from the names of the inputs of this kind of task to the task | 2698 * Return a map from the names of the inputs of this kind of task to the task |
| 2690 * input descriptors describing those inputs for a task with the given | 2699 * input descriptors describing those inputs for a task with the given |
| 2691 * [source]. | 2700 * [source]. |
| 2692 */ | 2701 */ |
| 2693 static Map<String, TaskInput> buildInputs(Source source) { | 2702 static Map<String, TaskInput> buildInputs(Source source) { |
| 2694 return <String, TaskInput>{ | 2703 return <String, TaskInput>{ |
| 2695 LINE_INFO_INPUT_NAME: LINE_INFO.of(source), | 2704 LINE_INFO_INPUT_NAME: LINE_INFO.of(source), |
| 2705 MODIFICATION_TIME_INPUT_NAME: MODIFICATION_TIME.of(source), |
| 2696 TOKEN_STREAM_INPUT_NAME: TOKEN_STREAM.of(source) | 2706 TOKEN_STREAM_INPUT_NAME: TOKEN_STREAM.of(source) |
| 2697 }; | 2707 }; |
| 2698 } | 2708 } |
| 2699 | 2709 |
| 2700 /** | 2710 /** |
| 2701 * Create a [ParseDartTask] based on the given [target] in the given | 2711 * Create a [ParseDartTask] based on the given [target] in the given |
| 2702 * [context]. | 2712 * [context]. |
| 2703 */ | 2713 */ |
| 2704 static ParseDartTask createTask( | 2714 static ParseDartTask createTask( |
| 2705 AnalysisContext context, AnalysisTarget target) { | 2715 AnalysisContext context, AnalysisTarget target) { |
| (...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3364 @override | 3374 @override |
| 3365 bool moveNext() { | 3375 bool moveNext() { |
| 3366 if (_newSources.isEmpty) { | 3376 if (_newSources.isEmpty) { |
| 3367 return false; | 3377 return false; |
| 3368 } | 3378 } |
| 3369 currentTarget = _newSources.first; | 3379 currentTarget = _newSources.first; |
| 3370 _newSources.remove(currentTarget); | 3380 _newSources.remove(currentTarget); |
| 3371 return true; | 3381 return true; |
| 3372 } | 3382 } |
| 3373 } | 3383 } |
| OLD | NEW |