Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 import 'package:analyzer/context/declared_variables.dart'; | 5 import 'package:analyzer/context/declared_variables.dart'; |
| 6 import 'package:analyzer/dart/ast/ast.dart'; | 6 import 'package:analyzer/dart/ast/ast.dart'; |
| 7 import 'package:analyzer/dart/ast/visitor.dart'; | 7 import 'package:analyzer/dart/ast/visitor.dart'; |
| 8 import 'package:analyzer/dart/element/element.dart'; | 8 import 'package:analyzer/dart/element/element.dart'; |
| 9 import 'package:analyzer/error/error.dart'; | 9 import 'package:analyzer/error/error.dart'; |
| 10 import 'package:analyzer/error/listener.dart'; | 10 import 'package:analyzer/error/listener.dart'; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 53 final Map<FileState, List<PendingError>> _fileToPendingErrors = {}; | 53 final Map<FileState, List<PendingError>> _fileToPendingErrors = {}; |
| 54 final List<ConstantEvaluationTarget> _constants = []; | 54 final List<ConstantEvaluationTarget> _constants = []; |
| 55 | 55 |
| 56 LibraryAnalyzer(this._analysisOptions, this._declaredVariables, | 56 LibraryAnalyzer(this._analysisOptions, this._declaredVariables, |
| 57 this._sourceFactory, this._fsState, this._store, this._library); | 57 this._sourceFactory, this._fsState, this._store, this._library); |
| 58 | 58 |
| 59 /** | 59 /** |
| 60 * Compute analysis results for all units of the library. | 60 * Compute analysis results for all units of the library. |
| 61 */ | 61 */ |
| 62 Map<FileState, UnitAnalysisResult> analyze() { | 62 Map<FileState, UnitAnalysisResult> analyze() { |
| 63 return PerformanceStatistics.analysis.makeCurrentWhile(() { | |
| 64 return _analyze(); | |
| 65 }); | |
| 66 } | |
| 67 | |
| 68 Map<FileState, UnitAnalysisResult> _analyze() { | |
| 63 Map<FileState, CompilationUnit> units = {}; | 69 Map<FileState, CompilationUnit> units = {}; |
| 64 | 70 |
| 65 // Parse all files. | 71 // Parse all files. |
| 66 units[_library] = _parse(_library); | 72 PerformanceStatistics.parse.makeCurrentWhile(() { |
| 67 for (FileState part in _library.partedFiles) { | 73 units[_library] = _parse(_library); |
|
scheglov
2017/06/04 00:30:44
Most of the work of _parse() is in FileState.parse
devoncarew
2017/06/04 01:45:52
I moved the instrumentation there.
| |
| 68 units[part] = _parse(part); | 74 for (FileState part in _library.partedFiles) { |
| 69 } | 75 units[part] = _parse(part); |
| 76 } | |
| 77 }); | |
| 70 | 78 |
| 71 // Resolve URIs in directives to corresponding sources. | 79 // Resolve URIs in directives to corresponding sources. |
| 72 units.forEach((file, unit) { | 80 units.forEach((file, unit) { |
| 73 _resolveUriBasedDirectives(file, unit); | 81 _resolveUriBasedDirectives(file, unit); |
| 74 }); | 82 }); |
| 75 | 83 |
| 76 _createAnalysisContext(); | 84 _createAnalysisContext(); |
| 77 | 85 |
| 78 try { | 86 try { |
| 79 _resynthesizer = new StoreBasedSummaryResynthesizer( | 87 _resynthesizer = new StoreBasedSummaryResynthesizer( |
| 80 _context, _sourceFactory, _analysisOptions.strongMode, _store); | 88 _context, _sourceFactory, _analysisOptions.strongMode, _store); |
| 81 _typeProvider = _resynthesizer.typeProvider; | 89 _typeProvider = _resynthesizer.typeProvider; |
| 82 _context.typeProvider = _typeProvider; | 90 _context.typeProvider = _typeProvider; |
| 83 | 91 |
| 84 _libraryElement = _resynthesizer.getLibraryElement(_library.uriStr); | 92 _libraryElement = _resynthesizer.getLibraryElement(_library.uriStr); |
| 85 | 93 |
| 86 _resolveDirectives(units); | 94 _resolveDirectives(units); |
| 87 | 95 |
| 88 units.forEach((file, unit) { | 96 units.forEach((file, unit) { |
| 89 _resolveFile(file, unit); | 97 _resolveFile(file, unit); |
| 90 _computePendingMissingRequiredParameters(file, unit); | 98 _computePendingMissingRequiredParameters(file, unit); |
| 91 }); | 99 }); |
| 92 | 100 |
| 93 _computeConstants(); | 101 _computeConstants(); |
| 94 | 102 |
| 95 units.forEach((file, unit) { | 103 PerformanceStatistics.errors.makeCurrentWhile(() { |
| 96 _computeVerifyErrors(file, unit); | 104 units.forEach((file, unit) { |
| 105 _computeVerifyErrors(file, unit); | |
| 106 }); | |
| 97 }); | 107 }); |
| 98 | 108 |
| 99 if (_analysisOptions.hint) { | 109 if (_analysisOptions.hint) { |
| 100 units.forEach((file, unit) { | 110 PerformanceStatistics.hints.makeCurrentWhile(() { |
| 101 { | 111 units.forEach((file, unit) { |
| 102 var visitor = new GatherUsedLocalElementsVisitor(_libraryElement); | 112 { |
| 103 unit.accept(visitor); | 113 var visitor = new GatherUsedLocalElementsVisitor(_libraryElement); |
| 104 _usedLocalElementsList.add(visitor.usedElements); | 114 unit.accept(visitor); |
| 105 } | 115 _usedLocalElementsList.add(visitor.usedElements); |
| 106 { | 116 } |
| 107 var visitor = | 117 { |
| 108 new GatherUsedImportedElementsVisitor(_libraryElement); | 118 var visitor = |
| 109 unit.accept(visitor); | 119 new GatherUsedImportedElementsVisitor(_libraryElement); |
| 110 _usedImportedElementsList.add(visitor.usedElements); | 120 unit.accept(visitor); |
| 111 } | 121 _usedImportedElementsList.add(visitor.usedElements); |
| 112 }); | 122 } |
| 113 units.forEach((file, unit) { | 123 }); |
| 114 _computeHints(file, unit); | 124 units.forEach((file, unit) { |
| 125 _computeHints(file, unit); | |
| 126 }); | |
| 115 }); | 127 }); |
| 116 } | 128 } |
| 117 | 129 |
| 118 if (_analysisOptions.lint) { | 130 if (_analysisOptions.lint) { |
| 119 units.forEach((file, unit) { | 131 PerformanceStatistics.lints.makeCurrentWhile(() { |
| 120 _computeLints(file, unit); | 132 units.forEach((file, unit) { |
| 133 _computeLints(file, unit); | |
| 134 }); | |
| 121 }); | 135 }); |
| 122 } | 136 } |
| 123 } finally { | 137 } finally { |
| 124 _context.dispose(); | 138 _context.dispose(); |
| 125 } | 139 } |
| 126 | 140 |
| 127 // Return full results. | 141 // Return full results. |
| 128 Map<FileState, UnitAnalysisResult> results = {}; | 142 Map<FileState, UnitAnalysisResult> results = {}; |
| 129 units.forEach((file, unit) { | 143 units.forEach((file, unit) { |
| 130 List<AnalysisError> errors = _getErrorListener(file).errors; | 144 List<AnalysisError> errors = _getErrorListener(file).errors; |
| (...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 784 } | 798 } |
| 785 | 799 |
| 786 /** | 800 /** |
| 787 * Either the name or the source associated with a part-of directive. | 801 * Either the name or the source associated with a part-of directive. |
| 788 */ | 802 */ |
| 789 class _NameOrSource { | 803 class _NameOrSource { |
| 790 final String name; | 804 final String name; |
| 791 final Source source; | 805 final Source source; |
| 792 _NameOrSource(this.name, this.source); | 806 _NameOrSource(this.name, this.source); |
| 793 } | 807 } |
| OLD | NEW |