| 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.context.context; | 5 library analyzer.src.context.context; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 | 9 |
| 10 import 'package:analyzer/dart/ast/ast.dart'; | 10 import 'package:analyzer/dart/ast/ast.dart'; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 import 'package:analyzer/src/generated/incremental_resolver.dart'; | 23 import 'package:analyzer/src/generated/incremental_resolver.dart'; |
| 24 import 'package:analyzer/src/generated/resolver.dart'; | 24 import 'package:analyzer/src/generated/resolver.dart'; |
| 25 import 'package:analyzer/src/generated/sdk.dart' show DartSdk; | 25 import 'package:analyzer/src/generated/sdk.dart' show DartSdk; |
| 26 import 'package:analyzer/src/generated/source.dart'; | 26 import 'package:analyzer/src/generated/source.dart'; |
| 27 import 'package:analyzer/src/generated/utilities_collection.dart'; | 27 import 'package:analyzer/src/generated/utilities_collection.dart'; |
| 28 import 'package:analyzer/src/task/dart.dart'; | 28 import 'package:analyzer/src/task/dart.dart'; |
| 29 import 'package:analyzer/src/task/dart_work_manager.dart'; | 29 import 'package:analyzer/src/task/dart_work_manager.dart'; |
| 30 import 'package:analyzer/src/task/driver.dart'; | 30 import 'package:analyzer/src/task/driver.dart'; |
| 31 import 'package:analyzer/src/task/incremental_element_builder.dart'; | 31 import 'package:analyzer/src/task/incremental_element_builder.dart'; |
| 32 import 'package:analyzer/src/task/manager.dart'; | 32 import 'package:analyzer/src/task/manager.dart'; |
| 33 import 'package:analyzer/src/task/model.dart'; | |
| 34 import 'package:analyzer/task/dart.dart'; | 33 import 'package:analyzer/task/dart.dart'; |
| 35 import 'package:analyzer/task/general.dart'; | 34 import 'package:analyzer/task/general.dart'; |
| 36 import 'package:analyzer/task/html.dart'; | 35 import 'package:analyzer/task/html.dart'; |
| 37 import 'package:analyzer/task/model.dart'; | 36 import 'package:analyzer/task/model.dart'; |
| 38 import 'package:html/dom.dart' show Document; | 37 import 'package:html/dom.dart' show Document; |
| 39 | 38 |
| 40 /** | 39 /** |
| 41 * The descriptor used to associate exclude patterns with an analysis context in | |
| 42 * configuration data. | |
| 43 */ | |
| 44 final ListResultDescriptor<String> CONTEXT_EXCLUDES = | |
| 45 new ListResultDescriptorImpl('CONTEXT_EXCLUDES', const <String>[]); | |
| 46 | |
| 47 /** | |
| 48 * Type of callback functions used by PendingFuture. Functions of this type | 40 * Type of callback functions used by PendingFuture. Functions of this type |
| 49 * should perform a computation based on the data in [entry] and return it. If | 41 * should perform a computation based on the data in [entry] and return it. If |
| 50 * the computation can't be performed yet because more analysis is needed, | 42 * the computation can't be performed yet because more analysis is needed, |
| 51 * `null` should be returned. | 43 * `null` should be returned. |
| 52 * | 44 * |
| 53 * The function may also throw an exception, in which case the corresponding | 45 * The function may also throw an exception, in which case the corresponding |
| 54 * future will be completed with failure. | 46 * future will be completed with failure. |
| 55 * | 47 * |
| 56 * Because this function is called while the state of analysis is being updated, | 48 * Because this function is called while the state of analysis is being updated, |
| 57 * it should be free of side effects so that it doesn't cause reentrant changes | 49 * it should be free of side effects so that it doesn't cause reentrant changes |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 AnalysisOptions get analysisOptions => _options; | 266 AnalysisOptions get analysisOptions => _options; |
| 275 | 267 |
| 276 @override | 268 @override |
| 277 void set analysisOptions(AnalysisOptions options) { | 269 void set analysisOptions(AnalysisOptions options) { |
| 278 bool needsRecompute = this._options.analyzeFunctionBodiesPredicate != | 270 bool needsRecompute = this._options.analyzeFunctionBodiesPredicate != |
| 279 options.analyzeFunctionBodiesPredicate || | 271 options.analyzeFunctionBodiesPredicate || |
| 280 this._options.generateImplicitErrors != | 272 this._options.generateImplicitErrors != |
| 281 options.generateImplicitErrors || | 273 options.generateImplicitErrors || |
| 282 this._options.generateSdkErrors != options.generateSdkErrors || | 274 this._options.generateSdkErrors != options.generateSdkErrors || |
| 283 this._options.dart2jsHint != options.dart2jsHint || | 275 this._options.dart2jsHint != options.dart2jsHint || |
| 276 _notEqual(this._options.errorProcessors, options.errorProcessors) || |
| 277 _notEqual(this._options.excludePatterns, options.excludePatterns) || |
| 284 (this._options.hint && !options.hint) || | 278 (this._options.hint && !options.hint) || |
| 285 (this._options.lint && !options.lint) || | 279 (this._options.lint && !options.lint) || |
| 280 _notEqual(this._options.lintRules, options.lintRules) || |
| 286 this._options.preserveComments != options.preserveComments || | 281 this._options.preserveComments != options.preserveComments || |
| 287 this._options.strongMode != options.strongMode || | 282 this._options.strongMode != options.strongMode || |
| 288 this._options.enableAssertInitializer != | 283 this._options.enableAssertInitializer != |
| 289 options.enableAssertInitializer || | 284 options.enableAssertInitializer || |
| 290 this._options.enableAssertMessage != options.enableAssertMessage || | 285 this._options.enableAssertMessage != options.enableAssertMessage || |
| 291 this._options.enableInitializingFormalAccess != | 286 this._options.enableInitializingFormalAccess != |
| 292 options.enableInitializingFormalAccess || | 287 options.enableInitializingFormalAccess || |
| 293 this._options.enableLazyAssignmentOperators != | 288 this._options.enableLazyAssignmentOperators != |
| 294 options.enableLazyAssignmentOperators || | 289 options.enableLazyAssignmentOperators || |
| 295 ((options is AnalysisOptionsImpl) | 290 ((options is AnalysisOptionsImpl) |
| (...skipping 19 matching lines...) Expand all Loading... |
| 315 this._options.dart2jsHint = options.dart2jsHint; | 310 this._options.dart2jsHint = options.dart2jsHint; |
| 316 this._options.enableAssertInitializer = options.enableAssertInitializer; | 311 this._options.enableAssertInitializer = options.enableAssertInitializer; |
| 317 this._options.enableAssertMessage = options.enableAssertMessage; | 312 this._options.enableAssertMessage = options.enableAssertMessage; |
| 318 this._options.enableStrictCallChecks = options.enableStrictCallChecks; | 313 this._options.enableStrictCallChecks = options.enableStrictCallChecks; |
| 319 this._options.enableInitializingFormalAccess = | 314 this._options.enableInitializingFormalAccess = |
| 320 options.enableInitializingFormalAccess; | 315 options.enableInitializingFormalAccess; |
| 321 this._options.enableLazyAssignmentOperators = | 316 this._options.enableLazyAssignmentOperators = |
| 322 options.enableLazyAssignmentOperators; | 317 options.enableLazyAssignmentOperators; |
| 323 this._options.enableSuperMixins = options.enableSuperMixins; | 318 this._options.enableSuperMixins = options.enableSuperMixins; |
| 324 this._options.enableTiming = options.enableTiming; | 319 this._options.enableTiming = options.enableTiming; |
| 320 this._options.errorProcessors = options.errorProcessors; |
| 321 this._options.excludePatterns = options.excludePatterns; |
| 325 this._options.hint = options.hint; | 322 this._options.hint = options.hint; |
| 326 this._options.incremental = options.incremental; | 323 this._options.incremental = options.incremental; |
| 327 this._options.incrementalApi = options.incrementalApi; | 324 this._options.incrementalApi = options.incrementalApi; |
| 328 this._options.incrementalValidation = options.incrementalValidation; | 325 this._options.incrementalValidation = options.incrementalValidation; |
| 329 this._options.lint = options.lint; | 326 this._options.lint = options.lint; |
| 327 this._options.lintRules = options.lintRules; |
| 330 this._options.preserveComments = options.preserveComments; | 328 this._options.preserveComments = options.preserveComments; |
| 331 if (this._options.strongMode != options.strongMode) { | 329 if (this._options.strongMode != options.strongMode) { |
| 332 _typeSystem = null; | 330 _typeSystem = null; |
| 333 } | 331 } |
| 334 this._options.strongMode = options.strongMode; | 332 this._options.strongMode = options.strongMode; |
| 335 this._options.trackCacheDependencies = options.trackCacheDependencies; | 333 this._options.trackCacheDependencies = options.trackCacheDependencies; |
| 336 this._options.disableCacheFlushing = options.disableCacheFlushing; | 334 this._options.disableCacheFlushing = options.disableCacheFlushing; |
| 337 this._options.finerGrainedInvalidation = options.finerGrainedInvalidation; | 335 this._options.finerGrainedInvalidation = options.finerGrainedInvalidation; |
| 338 this._options.patchPlatform = options.patchPlatform; | 336 this._options.patchPlatform = options.patchPlatform; |
| 339 if (options is AnalysisOptionsImpl) { | 337 if (options is AnalysisOptionsImpl) { |
| (...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 840 return entry; | 838 return entry; |
| 841 } | 839 } |
| 842 | 840 |
| 843 @override | 841 @override |
| 844 CompilationUnitElement getCompilationUnitElement( | 842 CompilationUnitElement getCompilationUnitElement( |
| 845 Source unitSource, Source librarySource) { | 843 Source unitSource, Source librarySource) { |
| 846 AnalysisTarget target = new LibrarySpecificUnit(librarySource, unitSource); | 844 AnalysisTarget target = new LibrarySpecificUnit(librarySource, unitSource); |
| 847 return getResult(target, COMPILATION_UNIT_ELEMENT); | 845 return getResult(target, COMPILATION_UNIT_ELEMENT); |
| 848 } | 846 } |
| 849 | 847 |
| 848 @deprecated |
| 850 @override | 849 @override |
| 851 Object/*=V*/ getConfigurationData/*<V>*/(ResultDescriptor/*<V>*/ key) => | 850 Object/*=V*/ getConfigurationData/*<V>*/(ResultDescriptor/*<V>*/ key) => |
| 852 (_configurationData[key] ?? key?.defaultValue) as Object/*=V*/; | 851 (_configurationData[key] ?? key?.defaultValue) as Object/*=V*/; |
| 853 | 852 |
| 854 @override | 853 @override |
| 855 TimestampedData<String> getContents(Source source) { | 854 TimestampedData<String> getContents(Source source) { |
| 856 String contents = _contentCache.getContents(source); | 855 String contents = _contentCache.getContents(source); |
| 857 if (contents != null) { | 856 if (contents != null) { |
| 858 return new TimestampedData<String>( | 857 return new TimestampedData<String>( |
| 859 _contentCache.getModificationStamp(source), contents); | 858 _contentCache.getModificationStamp(source), contents); |
| (...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1300 | 1299 |
| 1301 @override | 1300 @override |
| 1302 void setChangedContents(Source source, String contents, int offset, | 1301 void setChangedContents(Source source, String contents, int offset, |
| 1303 int oldLength, int newLength) { | 1302 int oldLength, int newLength) { |
| 1304 if (_contentRangeChanged(source, contents, offset, oldLength, newLength)) { | 1303 if (_contentRangeChanged(source, contents, offset, oldLength, newLength)) { |
| 1305 _onSourcesChangedController.add(new SourcesChangedEvent.changedRange( | 1304 _onSourcesChangedController.add(new SourcesChangedEvent.changedRange( |
| 1306 source, contents, offset, oldLength, newLength)); | 1305 source, contents, offset, oldLength, newLength)); |
| 1307 } | 1306 } |
| 1308 } | 1307 } |
| 1309 | 1308 |
| 1309 @deprecated |
| 1310 @override | 1310 @override |
| 1311 void setConfigurationData(ResultDescriptor key, Object data) { | 1311 void setConfigurationData(ResultDescriptor key, Object data) { |
| 1312 _configurationData[key] = data; | 1312 _configurationData[key] = data; |
| 1313 } | 1313 } |
| 1314 | 1314 |
| 1315 @override | 1315 @override |
| 1316 void setContents(Source source, String contents) { | 1316 void setContents(Source source, String contents) { |
| 1317 _contentsChanged(source, contents, true); | 1317 _contentsChanged(source, contents, true); |
| 1318 } | 1318 } |
| 1319 | 1319 |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1689 } | 1689 } |
| 1690 } | 1690 } |
| 1691 | 1691 |
| 1692 /** | 1692 /** |
| 1693 * Log the given debugging [message]. | 1693 * Log the given debugging [message]. |
| 1694 */ | 1694 */ |
| 1695 void _logInformation(String message) { | 1695 void _logInformation(String message) { |
| 1696 AnalysisEngine.instance.logger.logInformation(message); | 1696 AnalysisEngine.instance.logger.logInformation(message); |
| 1697 } | 1697 } |
| 1698 | 1698 |
| 1699 bool _notEqual/*<T>*/(List/*<T>*/ first, List/*<T>*/ second) { |
| 1700 int length = first.length; |
| 1701 if (length != second.length) { |
| 1702 return true; |
| 1703 } |
| 1704 for (int i = 0; i < length; i++) { |
| 1705 if (first[i] != second[i]) { |
| 1706 return true; |
| 1707 } |
| 1708 } |
| 1709 return false; |
| 1710 } |
| 1711 |
| 1699 /** | 1712 /** |
| 1700 * Notify all of the analysis listeners that the errors associated with the | 1713 * Notify all of the analysis listeners that the errors associated with the |
| 1701 * given [source] has been updated to the given [errors]. | 1714 * given [source] has been updated to the given [errors]. |
| 1702 */ | 1715 */ |
| 1703 void _notifyErrors( | 1716 void _notifyErrors( |
| 1704 Source source, List<AnalysisError> errors, LineInfo lineInfo) { | 1717 Source source, List<AnalysisError> errors, LineInfo lineInfo) { |
| 1705 int count = _listeners.length; | 1718 int count = _listeners.length; |
| 1706 for (int i = 0; i < count; i++) { | 1719 for (int i = 0; i < count; i++) { |
| 1707 _listeners[i].computedErrors(this, source, errors, lineInfo); | 1720 _listeners[i].computedErrors(this, source, errors, lineInfo); |
| 1708 } | 1721 } |
| (...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2235 } | 2248 } |
| 2236 DartSdk sdk = factory.dartSdk; | 2249 DartSdk sdk = factory.dartSdk; |
| 2237 if (sdk == null) { | 2250 if (sdk == null) { |
| 2238 throw new ArgumentError( | 2251 throw new ArgumentError( |
| 2239 "The source factory for an SDK analysis context must have a DartUriRes
olver"); | 2252 "The source factory for an SDK analysis context must have a DartUriRes
olver"); |
| 2240 } | 2253 } |
| 2241 return new AnalysisCache( | 2254 return new AnalysisCache( |
| 2242 <CachePartition>[AnalysisEngine.instance.partitionManager.forSdk(sdk)]); | 2255 <CachePartition>[AnalysisEngine.instance.partitionManager.forSdk(sdk)]); |
| 2243 } | 2256 } |
| 2244 } | 2257 } |
| OLD | NEW |