| 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/instrumentation/instrumentation.dart'; | 10 import 'package:analyzer/instrumentation/instrumentation.dart'; |
| 11 import 'package:analyzer/plugin/task.dart'; |
| 11 import 'package:analyzer/src/cancelable_future.dart'; | 12 import 'package:analyzer/src/cancelable_future.dart'; |
| 12 import 'package:analyzer/src/context/cache.dart'; | 13 import 'package:analyzer/src/context/cache.dart'; |
| 13 import 'package:analyzer/src/generated/ast.dart'; | 14 import 'package:analyzer/src/generated/ast.dart'; |
| 14 import 'package:analyzer/src/generated/constant.dart'; | 15 import 'package:analyzer/src/generated/constant.dart'; |
| 15 import 'package:analyzer/src/generated/element.dart'; | 16 import 'package:analyzer/src/generated/element.dart'; |
| 16 import 'package:analyzer/src/generated/engine.dart' | 17 import 'package:analyzer/src/generated/engine.dart' |
| 17 hide | 18 hide |
| 18 AnalysisCache, | 19 AnalysisCache, |
| 19 CachePartition, | 20 CachePartition, |
| 20 SdkCachePartition, | 21 SdkCachePartition, |
| 21 UniversalCachePartition, | 22 UniversalCachePartition, |
| 22 WorkManager; | 23 WorkManager; |
| 23 import 'package:analyzer/src/generated/error.dart'; | 24 import 'package:analyzer/src/generated/error.dart'; |
| 24 import 'package:analyzer/src/generated/html.dart' as ht show HtmlUnit; | 25 import 'package:analyzer/src/generated/html.dart' as ht show HtmlUnit; |
| 25 import 'package:analyzer/src/generated/incremental_resolver.dart'; | 26 import 'package:analyzer/src/generated/incremental_resolver.dart'; |
| 26 import 'package:analyzer/src/generated/java_core.dart'; | 27 import 'package:analyzer/src/generated/java_core.dart'; |
| 27 import 'package:analyzer/src/generated/java_engine.dart'; | 28 import 'package:analyzer/src/generated/java_engine.dart'; |
| 28 import 'package:analyzer/src/generated/resolver.dart'; | 29 import 'package:analyzer/src/generated/resolver.dart'; |
| 29 import 'package:analyzer/src/generated/scanner.dart'; | |
| 30 import 'package:analyzer/src/generated/sdk.dart' show DartSdk; | 30 import 'package:analyzer/src/generated/sdk.dart' show DartSdk; |
| 31 import 'package:analyzer/src/generated/source.dart'; | 31 import 'package:analyzer/src/generated/source.dart'; |
| 32 import 'package:analyzer/src/generated/utilities_collection.dart'; | 32 import 'package:analyzer/src/generated/utilities_collection.dart'; |
| 33 import 'package:analyzer/src/task/dart.dart'; | 33 import 'package:analyzer/src/task/dart.dart'; |
| 34 import 'package:analyzer/src/task/dart_work_manager.dart'; | 34 import 'package:analyzer/src/task/dart_work_manager.dart'; |
| 35 import 'package:analyzer/src/task/driver.dart'; | 35 import 'package:analyzer/src/task/driver.dart'; |
| 36 import 'package:analyzer/src/task/html.dart'; | |
| 37 import 'package:analyzer/src/task/html_work_manager.dart'; | |
| 38 import 'package:analyzer/src/task/incremental_element_builder.dart'; | 36 import 'package:analyzer/src/task/incremental_element_builder.dart'; |
| 39 import 'package:analyzer/src/task/manager.dart'; | 37 import 'package:analyzer/src/task/manager.dart'; |
| 40 import 'package:analyzer/task/dart.dart'; | 38 import 'package:analyzer/task/dart.dart'; |
| 41 import 'package:analyzer/task/general.dart'; | 39 import 'package:analyzer/task/general.dart'; |
| 42 import 'package:analyzer/task/html.dart'; | 40 import 'package:analyzer/task/html.dart'; |
| 43 import 'package:analyzer/task/model.dart'; | 41 import 'package:analyzer/task/model.dart'; |
| 44 import 'package:html/dom.dart' show Document; | 42 import 'package:html/dom.dart' show Document; |
| 45 | 43 |
| 46 /** | 44 /** |
| 47 * Type of callback functions used by PendingFuture. Functions of this type | 45 * Type of callback functions used by PendingFuture. Functions of this type |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 * are stored. | 113 * are stored. |
| 116 */ | 114 */ |
| 117 AnalysisCache _cache; | 115 AnalysisCache _cache; |
| 118 | 116 |
| 119 /** | 117 /** |
| 120 * The task manager used to manage the tasks used to analyze code. | 118 * The task manager used to manage the tasks used to analyze code. |
| 121 */ | 119 */ |
| 122 TaskManager _taskManager; | 120 TaskManager _taskManager; |
| 123 | 121 |
| 124 /** | 122 /** |
| 123 * A list of all [WorkManager]s used by this context. |
| 124 */ |
| 125 final List<WorkManager> workManagers = <WorkManager>[]; |
| 126 |
| 127 /** |
| 125 * The [DartWorkManager] instance that performs Dart specific scheduling. | 128 * The [DartWorkManager] instance that performs Dart specific scheduling. |
| 126 */ | 129 */ |
| 127 DartWorkManager dartWorkManager; | 130 DartWorkManager dartWorkManager; |
| 128 | 131 |
| 129 /** | 132 /** |
| 130 * The work manager that performs HTML specific scheduling. | |
| 131 */ | |
| 132 HtmlWorkManager htmlWorkManager; | |
| 133 | |
| 134 /** | |
| 135 * The analysis driver used to perform analysis. | 133 * The analysis driver used to perform analysis. |
| 136 */ | 134 */ |
| 137 AnalysisDriver driver; | 135 AnalysisDriver driver; |
| 138 | 136 |
| 139 /** | 137 /** |
| 140 * A list containing sources for which data should not be flushed. | 138 * A list containing sources for which data should not be flushed. |
| 141 */ | 139 */ |
| 142 List<Source> _priorityOrder = <Source>[]; | 140 List<Source> _priorityOrder = <Source>[]; |
| 143 | 141 |
| 144 /** | 142 /** |
| (...skipping 10 matching lines...) Expand all Loading... |
| 155 */ | 153 */ |
| 156 HashMap<Source, ChangeNoticeImpl> _pendingNotices = | 154 HashMap<Source, ChangeNoticeImpl> _pendingNotices = |
| 157 new HashMap<Source, ChangeNoticeImpl>(); | 155 new HashMap<Source, ChangeNoticeImpl>(); |
| 158 | 156 |
| 159 /** | 157 /** |
| 160 * The [TypeProvider] for this context, `null` if not yet created. | 158 * The [TypeProvider] for this context, `null` if not yet created. |
| 161 */ | 159 */ |
| 162 TypeProvider _typeProvider; | 160 TypeProvider _typeProvider; |
| 163 | 161 |
| 164 /** | 162 /** |
| 163 * The [TypeSystem] for this context, `null` if not yet created. |
| 164 */ |
| 165 TypeSystem _typeSystem; |
| 166 |
| 167 /** |
| 165 * The controller for sending [SourcesChangedEvent]s. | 168 * The controller for sending [SourcesChangedEvent]s. |
| 166 */ | 169 */ |
| 167 StreamController<SourcesChangedEvent> _onSourcesChangedController; | 170 StreamController<SourcesChangedEvent> _onSourcesChangedController; |
| 168 | 171 |
| 169 /** | 172 /** |
| 173 * A subscription for a stream of events indicating when files are (and are |
| 174 * not) being implicitly analyzed. |
| 175 */ |
| 176 StreamController<ImplicitAnalysisEvent> _implicitAnalysisEventsController; |
| 177 |
| 178 /** |
| 170 * The listeners that are to be notified when various analysis results are | 179 * The listeners that are to be notified when various analysis results are |
| 171 * produced in this context. | 180 * produced in this context. |
| 172 */ | 181 */ |
| 173 List<AnalysisListener> _listeners = new List<AnalysisListener>(); | 182 List<AnalysisListener> _listeners = new List<AnalysisListener>(); |
| 174 | 183 |
| 175 /** | 184 /** |
| 176 * The most recently incrementally resolved source, or `null` when it was | 185 * The most recently incrementally resolved source, or `null` when it was |
| 177 * already validated, or the most recent change was not incrementally resolved
. | 186 * already validated, or the most recent change was not incrementally resolved
. |
| 178 */ | 187 */ |
| 179 Source incrementalResolutionValidation_lastUnitSource; | 188 Source incrementalResolutionValidation_lastUnitSource; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 206 */ | 215 */ |
| 207 LibraryResolverFactory libraryResolverFactory; | 216 LibraryResolverFactory libraryResolverFactory; |
| 208 | 217 |
| 209 /** | 218 /** |
| 210 * Initialize a newly created analysis context. | 219 * Initialize a newly created analysis context. |
| 211 */ | 220 */ |
| 212 AnalysisContextImpl() { | 221 AnalysisContextImpl() { |
| 213 _privatePartition = new UniversalCachePartition(this); | 222 _privatePartition = new UniversalCachePartition(this); |
| 214 _cache = createCacheFromSourceFactory(null); | 223 _cache = createCacheFromSourceFactory(null); |
| 215 _taskManager = AnalysisEngine.instance.taskManager; | 224 _taskManager = AnalysisEngine.instance.taskManager; |
| 216 // TODO(scheglov) Get WorkManager(Factory)(s) from plugins. | 225 for (WorkManagerFactory factory |
| 217 dartWorkManager = new DartWorkManager(this); | 226 in AnalysisEngine.instance.enginePlugin.workManagerFactories) { |
| 218 htmlWorkManager = new HtmlWorkManager(this); | 227 WorkManager workManager = factory(this); |
| 219 driver = new AnalysisDriver( | 228 if (workManager != null) { |
| 220 _taskManager, <WorkManager>[dartWorkManager, htmlWorkManager], this); | 229 workManagers.add(workManager); |
| 230 if (workManager is DartWorkManager) { |
| 231 dartWorkManager = workManager; |
| 232 } |
| 233 } |
| 234 } |
| 235 driver = new AnalysisDriver(_taskManager, workManagers, this); |
| 221 _onSourcesChangedController = | 236 _onSourcesChangedController = |
| 222 new StreamController<SourcesChangedEvent>.broadcast(); | 237 new StreamController<SourcesChangedEvent>.broadcast(); |
| 238 _implicitAnalysisEventsController = |
| 239 new StreamController<ImplicitAnalysisEvent>.broadcast(); |
| 223 } | 240 } |
| 224 | 241 |
| 225 @override | 242 @override |
| 226 AnalysisCache get analysisCache => _cache; | 243 AnalysisCache get analysisCache => _cache; |
| 227 | 244 |
| 228 @override | 245 @override |
| 229 AnalysisOptions get analysisOptions => _options; | 246 AnalysisOptions get analysisOptions => _options; |
| 230 | 247 |
| 231 @override | 248 @override |
| 232 void set analysisOptions(AnalysisOptions options) { | 249 void set analysisOptions(AnalysisOptions options) { |
| 233 bool needsRecompute = this._options.analyzeFunctionBodiesPredicate != | 250 bool needsRecompute = this._options.analyzeFunctionBodiesPredicate != |
| 234 options.analyzeFunctionBodiesPredicate || | 251 options.analyzeFunctionBodiesPredicate || |
| 235 this._options.generateImplicitErrors != | 252 this._options.generateImplicitErrors != |
| 236 options.generateImplicitErrors || | 253 options.generateImplicitErrors || |
| 237 this._options.generateSdkErrors != options.generateSdkErrors || | 254 this._options.generateSdkErrors != options.generateSdkErrors || |
| 238 this._options.dart2jsHint != options.dart2jsHint || | 255 this._options.dart2jsHint != options.dart2jsHint || |
| 239 (this._options.hint && !options.hint) || | 256 (this._options.hint && !options.hint) || |
| 240 (this._options.lint && !options.lint) || | 257 (this._options.lint && !options.lint) || |
| 241 this._options.preserveComments != options.preserveComments || | 258 this._options.preserveComments != options.preserveComments || |
| 242 this._options.enableStrictCallChecks != options.enableStrictCallChecks; | 259 this._options.strongMode != options.strongMode || |
| 260 this._options.enableStrictCallChecks != |
| 261 options.enableStrictCallChecks || |
| 262 this._options.enableSuperMixins != options.enableSuperMixins; |
| 243 int cacheSize = options.cacheSize; | 263 int cacheSize = options.cacheSize; |
| 244 if (this._options.cacheSize != cacheSize) { | 264 if (this._options.cacheSize != cacheSize) { |
| 245 this._options.cacheSize = cacheSize; | 265 this._options.cacheSize = cacheSize; |
| 246 } | 266 } |
| 247 this._options.analyzeFunctionBodiesPredicate = | 267 this._options.analyzeFunctionBodiesPredicate = |
| 248 options.analyzeFunctionBodiesPredicate; | 268 options.analyzeFunctionBodiesPredicate; |
| 249 this._options.generateImplicitErrors = options.generateImplicitErrors; | 269 this._options.generateImplicitErrors = options.generateImplicitErrors; |
| 250 this._options.generateSdkErrors = options.generateSdkErrors; | 270 this._options.generateSdkErrors = options.generateSdkErrors; |
| 251 this._options.dart2jsHint = options.dart2jsHint; | 271 this._options.dart2jsHint = options.dart2jsHint; |
| 252 this._options.enableStrictCallChecks = options.enableStrictCallChecks; | 272 this._options.enableStrictCallChecks = options.enableStrictCallChecks; |
| 273 this._options.enableSuperMixins = options.enableSuperMixins; |
| 253 this._options.hint = options.hint; | 274 this._options.hint = options.hint; |
| 254 this._options.incremental = options.incremental; | 275 this._options.incremental = options.incremental; |
| 255 this._options.incrementalApi = options.incrementalApi; | 276 this._options.incrementalApi = options.incrementalApi; |
| 256 this._options.incrementalValidation = options.incrementalValidation; | 277 this._options.incrementalValidation = options.incrementalValidation; |
| 257 this._options.lint = options.lint; | 278 this._options.lint = options.lint; |
| 258 this._options.preserveComments = options.preserveComments; | 279 this._options.preserveComments = options.preserveComments; |
| 280 this._options.strongMode = options.strongMode; |
| 259 if (needsRecompute) { | 281 if (needsRecompute) { |
| 260 dartWorkManager.onAnalysisOptionsChanged(); | 282 for (WorkManager workManager in workManagers) { |
| 261 htmlWorkManager.onAnalysisOptionsChanged(); | 283 workManager.onAnalysisOptionsChanged(); |
| 284 } |
| 262 } | 285 } |
| 263 } | 286 } |
| 264 | 287 |
| 265 @override | 288 @override |
| 266 void set analysisPriorityOrder(List<Source> sources) { | 289 void set analysisPriorityOrder(List<Source> sources) { |
| 267 if (sources == null || sources.isEmpty) { | 290 if (sources == null || sources.isEmpty) { |
| 268 _priorityOrder = Source.EMPTY_LIST; | 291 _priorityOrder = Source.EMPTY_LIST; |
| 269 } else { | 292 } else { |
| 270 while (sources.remove(null)) { | 293 while (sources.remove(null)) { |
| 271 // Nothing else to do. | 294 // Nothing else to do. |
| 272 } | 295 } |
| 273 if (sources.isEmpty) { | 296 if (sources.isEmpty) { |
| 274 _priorityOrder = Source.EMPTY_LIST; | 297 _priorityOrder = Source.EMPTY_LIST; |
| 275 } else { | 298 } else { |
| 276 _priorityOrder = sources; | 299 _priorityOrder = sources; |
| 277 } | 300 } |
| 278 } | 301 } |
| 279 dartWorkManager.applyPriorityTargets(_priorityOrder); | 302 for (WorkManager workManager in workManagers) { |
| 280 htmlWorkManager.applyPriorityTargets(_priorityOrder); | 303 workManager.applyPriorityTargets(_priorityOrder); |
| 304 } |
| 305 driver.reset(); |
| 281 } | 306 } |
| 282 | 307 |
| 283 @override | 308 @override |
| 284 set contentCache(ContentCache value) { | 309 set contentCache(ContentCache value) { |
| 285 _contentCache = value; | 310 _contentCache = value; |
| 286 } | 311 } |
| 287 | 312 |
| 288 @override | 313 @override |
| 289 DeclaredVariables get declaredVariables => _declaredVariables; | 314 DeclaredVariables get declaredVariables => _declaredVariables; |
| 290 | 315 |
| 291 @override | 316 @override |
| 292 List<AnalysisTarget> get explicitTargets { | 317 List<AnalysisTarget> get explicitTargets { |
| 293 List<AnalysisTarget> targets = <AnalysisTarget>[]; | 318 List<AnalysisTarget> targets = <AnalysisTarget>[]; |
| 294 MapIterator<AnalysisTarget, CacheEntry> iterator = _cache.iterator(); | 319 MapIterator<AnalysisTarget, CacheEntry> iterator = _cache.iterator(); |
| 295 while (iterator.moveNext()) { | 320 while (iterator.moveNext()) { |
| 296 if (iterator.value.explicitlyAdded) { | 321 if (iterator.value.explicitlyAdded) { |
| 297 targets.add(iterator.key); | 322 targets.add(iterator.key); |
| 298 } | 323 } |
| 299 } | 324 } |
| 300 return targets; | 325 return targets; |
| 301 } | 326 } |
| 302 | 327 |
| 303 @override | 328 @override |
| 304 List<Source> get htmlSources => _getSources(SourceKind.HTML); | 329 List<Source> get htmlSources => _getSources(SourceKind.HTML); |
| 305 | 330 |
| 306 @override | 331 @override |
| 332 Stream<ImplicitAnalysisEvent> get implicitAnalysisEvents => |
| 333 _implicitAnalysisEventsController.stream; |
| 334 |
| 335 @override |
| 307 bool get isDisposed => _disposed; | 336 bool get isDisposed => _disposed; |
| 308 | 337 |
| 309 @override | 338 @override |
| 310 List<Source> get launchableClientLibrarySources { | 339 List<Source> get launchableClientLibrarySources { |
| 311 List<Source> sources = <Source>[]; | 340 List<Source> sources = <Source>[]; |
| 312 for (Source source in _cache.sources) { | 341 for (Source source in _cache.sources) { |
| 313 CacheEntry entry = _cache.get(source); | 342 CacheEntry entry = _cache.get(source); |
| 314 if (entry.getValue(SOURCE_KIND) == SourceKind.LIBRARY && | 343 if (entry.getValue(SOURCE_KIND) == SourceKind.LIBRARY && |
| 315 !source.isInSystemLibrary && | 344 !source.isInSystemLibrary && |
| 316 isClientLibrary(source)) { | 345 isClientLibrary(source)) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 338 @override | 367 @override |
| 339 List<Source> get librarySources => _getSources(SourceKind.LIBRARY); | 368 List<Source> get librarySources => _getSources(SourceKind.LIBRARY); |
| 340 | 369 |
| 341 @override | 370 @override |
| 342 Stream<SourcesChangedEvent> get onSourcesChanged => | 371 Stream<SourcesChangedEvent> get onSourcesChanged => |
| 343 _onSourcesChangedController.stream; | 372 _onSourcesChangedController.stream; |
| 344 | 373 |
| 345 /** | 374 /** |
| 346 * Make _pendingFutureSources available to unit tests. | 375 * Make _pendingFutureSources available to unit tests. |
| 347 */ | 376 */ |
| 348 HashMap<AnalysisTarget, List<PendingFuture>> get pendingFutureSources_forTesti
ng => | 377 HashMap<AnalysisTarget, |
| 378 List<PendingFuture>> get pendingFutureSources_forTesting => |
| 349 _pendingFutureTargets; | 379 _pendingFutureTargets; |
| 350 | 380 |
| 351 @override | 381 @override |
| 352 List<Source> get prioritySources => _priorityOrder; | 382 List<Source> get prioritySources => _priorityOrder; |
| 353 | 383 |
| 354 @override | 384 @override |
| 355 List<AnalysisTarget> get priorityTargets => prioritySources; | 385 List<AnalysisTarget> get priorityTargets => prioritySources; |
| 356 | 386 |
| 357 @override | 387 @override |
| 358 CachePartition get privateAnalysisCachePartition => _privatePartition; | 388 CachePartition get privateAnalysisCachePartition => _privatePartition; |
| 359 | 389 |
| 360 @override | 390 @override |
| 361 SourceFactory get sourceFactory => _sourceFactory; | 391 SourceFactory get sourceFactory => _sourceFactory; |
| 362 | 392 |
| 363 @override | 393 @override |
| 364 void set sourceFactory(SourceFactory factory) { | 394 void set sourceFactory(SourceFactory factory) { |
| 365 if (identical(_sourceFactory, factory)) { | 395 if (identical(_sourceFactory, factory)) { |
| 366 return; | 396 return; |
| 367 } else if (factory.context != null) { | 397 } else if (factory.context != null) { |
| 368 throw new IllegalStateException( | 398 throw new IllegalStateException( |
| 369 "Source factories cannot be shared between contexts"); | 399 "Source factories cannot be shared between contexts"); |
| 370 } | 400 } |
| 371 if (_sourceFactory != null) { | 401 if (_sourceFactory != null) { |
| 372 _sourceFactory.context = null; | 402 _sourceFactory.context = null; |
| 373 } | 403 } |
| 374 factory.context = this; | 404 factory.context = this; |
| 375 _sourceFactory = factory; | 405 _sourceFactory = factory; |
| 376 _cache = createCacheFromSourceFactory(factory); | 406 _cache = createCacheFromSourceFactory(factory); |
| 377 dartWorkManager.onSourceFactoryChanged(); | 407 for (WorkManager workManager in workManagers) { |
| 378 htmlWorkManager.onSourceFactoryChanged(); | 408 workManager.onSourceFactoryChanged(); |
| 409 } |
| 379 } | 410 } |
| 380 | 411 |
| 381 @override | 412 @override |
| 382 List<Source> get sources { | 413 List<Source> get sources { |
| 383 return _cache.sources.toList(); | 414 return _cache.sources.toList(); |
| 384 } | 415 } |
| 385 | 416 |
| 386 /** | 417 /** |
| 387 * Return a list of the sources that would be processed by | 418 * Return a list of the sources that would be processed by |
| 388 * [performAnalysisTask]. This method duplicates, and must therefore be kept | 419 * [performAnalysisTask]. This method duplicates, and must therefore be kept |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 } | 479 } |
| 449 | 480 |
| 450 /** | 481 /** |
| 451 * Sets the [TypeProvider] for this context. | 482 * Sets the [TypeProvider] for this context. |
| 452 */ | 483 */ |
| 453 void set typeProvider(TypeProvider typeProvider) { | 484 void set typeProvider(TypeProvider typeProvider) { |
| 454 _typeProvider = typeProvider; | 485 _typeProvider = typeProvider; |
| 455 } | 486 } |
| 456 | 487 |
| 457 @override | 488 @override |
| 489 TypeSystem get typeSystem { |
| 490 if (_typeSystem == null) { |
| 491 _typeSystem = TypeSystem.create(this); |
| 492 } |
| 493 return _typeSystem; |
| 494 } |
| 495 |
| 496 @override |
| 458 void addListener(AnalysisListener listener) { | 497 void addListener(AnalysisListener listener) { |
| 459 if (!_listeners.contains(listener)) { | 498 if (!_listeners.contains(listener)) { |
| 460 _listeners.add(listener); | 499 _listeners.add(listener); |
| 461 } | 500 } |
| 462 } | 501 } |
| 463 | 502 |
| 464 @override | 503 @override |
| 465 void applyAnalysisDelta(AnalysisDelta delta) { | 504 void applyAnalysisDelta(AnalysisDelta delta) { |
| 466 ChangeSet changeSet = new ChangeSet(); | 505 ChangeSet changeSet = new ChangeSet(); |
| 467 delta.analysisLevels.forEach((Source source, AnalysisLevel level) { | 506 delta.analysisLevels.forEach((Source source, AnalysisLevel level) { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 .forEach((Source source, ChangeSet_ContentChange change) { | 548 .forEach((Source source, ChangeSet_ContentChange change) { |
| 510 _contentRangeChanged(source, change.contents, change.offset, | 549 _contentRangeChanged(source, change.contents, change.offset, |
| 511 change.oldLength, change.newLength); | 550 change.oldLength, change.newLength); |
| 512 }); | 551 }); |
| 513 for (Source source in changeSet.deletedSources) { | 552 for (Source source in changeSet.deletedSources) { |
| 514 _sourceDeleted(source); | 553 _sourceDeleted(source); |
| 515 } | 554 } |
| 516 for (Source source in removedSources) { | 555 for (Source source in removedSources) { |
| 517 _sourceRemoved(source); | 556 _sourceRemoved(source); |
| 518 } | 557 } |
| 519 dartWorkManager.applyChange( | 558 for (WorkManager workManager in workManagers) { |
| 520 changeSet.addedSources, changeSet.changedSources, removedSources); | 559 workManager.applyChange( |
| 521 htmlWorkManager.applyChange( | 560 changeSet.addedSources, changeSet.changedSources, removedSources); |
| 522 changeSet.addedSources, changeSet.changedSources, removedSources); | 561 } |
| 523 _onSourcesChangedController.add(new SourcesChangedEvent(changeSet)); | 562 _onSourcesChangedController.add(new SourcesChangedEvent(changeSet)); |
| 524 } | 563 } |
| 525 | 564 |
| 526 @override | 565 @override |
| 527 String computeDocumentationComment(Element element) { | 566 String computeDocumentationComment(Element element) { |
| 528 if (element == null) { | 567 if (element == null) { |
| 529 return null; | 568 return null; |
| 530 } | 569 } |
| 531 Source source = element.source; | 570 Source source = element.source; |
| 532 if (source == null) { | 571 if (source == null) { |
| 533 return null; | 572 return null; |
| 534 } | 573 } |
| 535 CompilationUnit unit = parseCompilationUnit(source); | 574 SourceRange docRange = element.docRange; |
| 536 if (unit == null) { | 575 if (docRange == null) { |
| 537 return null; | 576 return null; |
| 538 } | 577 } |
| 539 NodeLocator locator = new NodeLocator(element.nameOffset); | 578 String code = getContents(source).data; |
| 540 AstNode nameNode = locator.searchWithin(unit); | 579 String comment = code.substring(docRange.offset, docRange.end); |
| 541 while (nameNode != null) { | 580 return comment.replaceAll('\r\n', '\n'); |
| 542 if (nameNode is AnnotatedNode) { | |
| 543 Comment comment = nameNode.documentationComment; | |
| 544 if (comment == null) { | |
| 545 return null; | |
| 546 } | |
| 547 StringBuffer buffer = new StringBuffer(); | |
| 548 List<Token> tokens = comment.tokens; | |
| 549 for (int i = 0; i < tokens.length; i++) { | |
| 550 if (i > 0) { | |
| 551 buffer.write("\n"); | |
| 552 } | |
| 553 buffer.write(tokens[i].lexeme); | |
| 554 } | |
| 555 return buffer.toString(); | |
| 556 } | |
| 557 nameNode = nameNode.parent; | |
| 558 } | |
| 559 return null; | |
| 560 } | 581 } |
| 561 | 582 |
| 562 @override | 583 @override |
| 563 List<AnalysisError> computeErrors(Source source) { | 584 List<AnalysisError> computeErrors(Source source) { |
| 564 String name = source.shortName; | 585 String name = source.shortName; |
| 565 if (AnalysisEngine.isDartFileName(name)) { | 586 if (AnalysisEngine.isDartFileName(name)) { |
| 566 return computeResult(source, DART_ERRORS); | 587 return computeResult(source, DART_ERRORS); |
| 567 } else if (AnalysisEngine.isHtmlFileName(name)) { | 588 } else if (AnalysisEngine.isHtmlFileName(name)) { |
| 568 return computeResult(source, HTML_ERRORS); | 589 return computeResult(source, HTML_ERRORS); |
| 569 } | 590 } |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 613 } | 634 } |
| 614 | 635 |
| 615 @override | 636 @override |
| 616 CancelableFuture<CompilationUnit> computeResolvedCompilationUnitAsync( | 637 CancelableFuture<CompilationUnit> computeResolvedCompilationUnitAsync( |
| 617 Source unitSource, Source librarySource) { | 638 Source unitSource, Source librarySource) { |
| 618 if (!AnalysisEngine.isDartFileName(unitSource.shortName) || | 639 if (!AnalysisEngine.isDartFileName(unitSource.shortName) || |
| 619 !AnalysisEngine.isDartFileName(librarySource.shortName)) { | 640 !AnalysisEngine.isDartFileName(librarySource.shortName)) { |
| 620 return new CancelableFuture.error(new AnalysisNotScheduledError()); | 641 return new CancelableFuture.error(new AnalysisNotScheduledError()); |
| 621 } | 642 } |
| 622 var unitTarget = new LibrarySpecificUnit(librarySource, unitSource); | 643 var unitTarget = new LibrarySpecificUnit(librarySource, unitSource); |
| 623 return new _AnalysisFutureHelper<CompilationUnit>(this).computeAsync( | 644 return new _AnalysisFutureHelper<CompilationUnit>(this) |
| 624 unitTarget, (CacheEntry entry) { | 645 .computeAsync(unitTarget, (CacheEntry entry) { |
| 625 CacheState state = entry.getState(RESOLVED_UNIT); | 646 CacheState state = entry.getState(RESOLVED_UNIT); |
| 626 if (state == CacheState.ERROR) { | 647 if (state == CacheState.ERROR) { |
| 627 throw entry.exception; | 648 throw entry.exception; |
| 628 } else if (state == CacheState.INVALID) { | 649 } else if (state == CacheState.INVALID) { |
| 629 return null; | 650 return null; |
| 630 } | 651 } |
| 631 return entry.getValue(RESOLVED_UNIT); | 652 return entry.getValue(RESOLVED_UNIT); |
| 632 }, () { | 653 }, () { |
| 633 dartWorkManager.addPriorityResult(unitTarget, RESOLVED_UNIT); | 654 dartWorkManager.addPriorityResult(unitTarget, RESOLVED_UNIT); |
| 634 }); | 655 }); |
| 635 } | 656 } |
| 636 | 657 |
| 658 @override |
| 637 Object /*V*/ computeResult( | 659 Object /*V*/ computeResult( |
| 638 AnalysisTarget target, ResultDescriptor /*<V>*/ descriptor) { | 660 AnalysisTarget target, ResultDescriptor /*<V>*/ descriptor) { |
| 639 CacheEntry entry = getCacheEntry(target); | 661 CacheEntry entry = getCacheEntry(target); |
| 640 CacheState state = entry.getState(descriptor); | 662 CacheState state = entry.getState(descriptor); |
| 641 if (state == CacheState.FLUSHED || state == CacheState.INVALID) { | 663 if (state == CacheState.FLUSHED || state == CacheState.INVALID) { |
| 642 driver.computeResult(target, descriptor); | 664 driver.computeResult(target, descriptor); |
| 643 } | 665 } |
| 644 state = entry.getState(descriptor); | 666 state = entry.getState(descriptor); |
| 645 if (state == CacheState.ERROR) { | 667 if (state == CacheState.ERROR) { |
| 646 throw new AnalysisException( | 668 throw new AnalysisException( |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 } | 701 } |
| 680 | 702 |
| 681 @override | 703 @override |
| 682 List<CompilationUnit> ensureResolvedDartUnits(Source unitSource) { | 704 List<CompilationUnit> ensureResolvedDartUnits(Source unitSource) { |
| 683 // Check every library. | 705 // Check every library. |
| 684 List<CompilationUnit> units = <CompilationUnit>[]; | 706 List<CompilationUnit> units = <CompilationUnit>[]; |
| 685 List<Source> containingLibraries = getLibrariesContaining(unitSource); | 707 List<Source> containingLibraries = getLibrariesContaining(unitSource); |
| 686 for (Source librarySource in containingLibraries) { | 708 for (Source librarySource in containingLibraries) { |
| 687 LibrarySpecificUnit target = | 709 LibrarySpecificUnit target = |
| 688 new LibrarySpecificUnit(librarySource, unitSource); | 710 new LibrarySpecificUnit(librarySource, unitSource); |
| 689 CompilationUnit unit = _cache.getValue(target, RESOLVED_UNIT); | 711 CompilationUnit unit = getResult(target, RESOLVED_UNIT); |
| 690 if (unit == null) { | 712 if (unit == null) { |
| 691 units = null; | 713 units = null; |
| 692 break; | 714 break; |
| 693 } | 715 } |
| 694 units.add(unit); | 716 units.add(unit); |
| 695 } | 717 } |
| 696 // If we have results, then we're done. | 718 // If we have results, then we're done. |
| 697 if (units != null) { | 719 if (units != null) { |
| 698 return units; | 720 return units; |
| 699 } | 721 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 721 | 743 |
| 722 @override | 744 @override |
| 723 CacheEntry getCacheEntry(AnalysisTarget target) { | 745 CacheEntry getCacheEntry(AnalysisTarget target) { |
| 724 CacheEntry entry = _cache.get(target); | 746 CacheEntry entry = _cache.get(target); |
| 725 if (entry == null) { | 747 if (entry == null) { |
| 726 entry = new CacheEntry(target); | 748 entry = new CacheEntry(target); |
| 727 if (target is Source) { | 749 if (target is Source) { |
| 728 entry.modificationTime = getModificationStamp(target); | 750 entry.modificationTime = getModificationStamp(target); |
| 729 } | 751 } |
| 730 _cache.put(entry); | 752 _cache.put(entry); |
| 753 if (target is Source) { |
| 754 _implicitAnalysisEventsController |
| 755 .add(new ImplicitAnalysisEvent(target, true)); |
| 756 } |
| 731 } | 757 } |
| 732 return entry; | 758 return entry; |
| 733 } | 759 } |
| 734 | 760 |
| 735 @override | 761 @override |
| 736 CompilationUnitElement getCompilationUnitElement( | 762 CompilationUnitElement getCompilationUnitElement( |
| 737 Source unitSource, Source librarySource) { | 763 Source unitSource, Source librarySource) { |
| 738 AnalysisTarget target = new LibrarySpecificUnit(librarySource, unitSource); | 764 AnalysisTarget target = new LibrarySpecificUnit(librarySource, unitSource); |
| 739 return _cache.getValue(target, COMPILATION_UNIT_ELEMENT); | 765 return getResult(target, COMPILATION_UNIT_ELEMENT); |
| 740 } | 766 } |
| 741 | 767 |
| 742 @override | 768 @override |
| 743 TimestampedData<String> getContents(Source source) { | 769 TimestampedData<String> getContents(Source source) { |
| 744 String contents = _contentCache.getContents(source); | 770 String contents = _contentCache.getContents(source); |
| 745 if (contents != null) { | 771 if (contents != null) { |
| 746 return new TimestampedData<String>( | 772 return new TimestampedData<String>( |
| 747 _contentCache.getModificationStamp(source), contents); | 773 _contentCache.getModificationStamp(source), contents); |
| 748 } | 774 } |
| 749 return source.contents; | 775 return source.contents; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 775 } catch (exception) { | 801 } catch (exception) { |
| 776 // If the location cannot be decoded for some reason then the underlying | 802 // If the location cannot be decoded for some reason then the underlying |
| 777 // cause should have been logged already and we can fall though to return | 803 // cause should have been logged already and we can fall though to return |
| 778 // null. | 804 // null. |
| 779 } | 805 } |
| 780 return null; | 806 return null; |
| 781 } | 807 } |
| 782 | 808 |
| 783 @override | 809 @override |
| 784 AnalysisErrorInfo getErrors(Source source) { | 810 AnalysisErrorInfo getErrors(Source source) { |
| 785 String name = source.shortName; | 811 List<AnalysisError> allErrors = <AnalysisError>[]; |
| 786 if (AnalysisEngine.isDartFileName(name) || source is DartScript) { | 812 for (WorkManager workManager in workManagers) { |
| 787 return dartWorkManager.getErrors(source); | 813 List<AnalysisError> errors = workManager.getErrors(source); |
| 788 } else if (AnalysisEngine.isHtmlFileName(name)) { | 814 allErrors.addAll(errors); |
| 789 return htmlWorkManager.getErrors(source); | |
| 790 } | 815 } |
| 791 return new AnalysisErrorInfoImpl(AnalysisError.NO_ERRORS, null); | 816 LineInfo lineInfo = getLineInfo(source); |
| 817 return new AnalysisErrorInfoImpl(allErrors, lineInfo); |
| 792 } | 818 } |
| 793 | 819 |
| 794 @override | 820 @override |
| 795 @deprecated | 821 @deprecated |
| 796 HtmlElement getHtmlElement(Source source) { | 822 HtmlElement getHtmlElement(Source source) { |
| 797 // TODO(brianwilkerson) Remove this method after switching to the new task | 823 // TODO(brianwilkerson) Remove this method after switching to the new task |
| 798 // model. | 824 // model. |
| 799 throw new UnimplementedError('Not supported in the new task model'); | 825 throw new UnimplementedError('Not supported in the new task model'); |
| 800 } | 826 } |
| 801 | 827 |
| 802 @override | 828 @override |
| 803 List<Source> getHtmlFilesReferencing(Source source) { | 829 List<Source> getHtmlFilesReferencing(Source source) { |
| 804 if (!AnalysisEngine.isDartFileName(source.shortName)) { | 830 if (!AnalysisEngine.isDartFileName(source.shortName)) { |
| 805 return Source.EMPTY_LIST; | 831 return Source.EMPTY_LIST; |
| 806 } | 832 } |
| 807 List<Source> htmlSources = <Source>[]; | 833 List<Source> htmlSources = <Source>[]; |
| 808 List<Source> librarySources = getLibrariesContaining(source); | 834 List<Source> librarySources = getLibrariesContaining(source); |
| 809 for (Source source in _cache.sources) { | 835 for (Source source in _cache.sources) { |
| 810 if (AnalysisEngine.isHtmlFileName(source.shortName)) { | 836 if (AnalysisEngine.isHtmlFileName(source.shortName)) { |
| 811 List<Source> referencedLibraries = | 837 List<Source> referencedLibraries = |
| 812 analysisCache.getValue(source, REFERENCED_LIBRARIES); | 838 getResult(source, REFERENCED_LIBRARIES); |
| 813 if (_containsAny(referencedLibraries, librarySources)) { | 839 if (_containsAny(referencedLibraries, librarySources)) { |
| 814 htmlSources.add(source); | 840 htmlSources.add(source); |
| 815 } | 841 } |
| 816 } | 842 } |
| 817 } | 843 } |
| 818 if (htmlSources.isEmpty) { | 844 if (htmlSources.isEmpty) { |
| 819 return Source.EMPTY_LIST; | 845 return Source.EMPTY_LIST; |
| 820 } | 846 } |
| 821 return htmlSources; | 847 return htmlSources; |
| 822 } | 848 } |
| 823 | 849 |
| 824 @override | 850 @override |
| 825 SourceKind getKindOf(Source source) { | 851 SourceKind getKindOf(Source source) { |
| 826 String name = source.shortName; | 852 String name = source.shortName; |
| 827 if (AnalysisEngine.isDartFileName(name)) { | 853 if (AnalysisEngine.isDartFileName(name)) { |
| 828 return _cache.getValue(source, SOURCE_KIND); | 854 return getResult(source, SOURCE_KIND); |
| 829 } else if (AnalysisEngine.isHtmlFileName(name)) { | 855 } else if (AnalysisEngine.isHtmlFileName(name)) { |
| 830 return SourceKind.HTML; | 856 return SourceKind.HTML; |
| 831 } | 857 } |
| 832 return SourceKind.UNKNOWN; | 858 return SourceKind.UNKNOWN; |
| 833 } | 859 } |
| 834 | 860 |
| 835 @override | 861 @override |
| 836 List<Source> getLibrariesContaining(Source source) { | 862 List<Source> getLibrariesContaining(Source source) { |
| 837 SourceKind kind = getKindOf(source); | 863 SourceKind kind = getKindOf(source); |
| 838 if (kind == SourceKind.LIBRARY) { | 864 if (kind == SourceKind.LIBRARY) { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 865 List<Source> getLibrariesReferencedFromHtml(Source htmlSource) { | 891 List<Source> getLibrariesReferencedFromHtml(Source htmlSource) { |
| 866 CacheEntry entry = _cache.get(htmlSource); | 892 CacheEntry entry = _cache.get(htmlSource); |
| 867 if (entry != null) { | 893 if (entry != null) { |
| 868 return entry.getValue(REFERENCED_LIBRARIES); | 894 return entry.getValue(REFERENCED_LIBRARIES); |
| 869 } | 895 } |
| 870 return Source.EMPTY_LIST; | 896 return Source.EMPTY_LIST; |
| 871 } | 897 } |
| 872 | 898 |
| 873 @override | 899 @override |
| 874 LibraryElement getLibraryElement(Source source) => | 900 LibraryElement getLibraryElement(Source source) => |
| 875 _cache.getValue(source, LIBRARY_ELEMENT); | 901 getResult(source, LIBRARY_ELEMENT); |
| 876 | 902 |
| 877 @override | 903 @override |
| 878 LineInfo getLineInfo(Source source) => _cache.getValue(source, LINE_INFO); | 904 LineInfo getLineInfo(Source source) => getResult(source, LINE_INFO); |
| 879 | 905 |
| 880 @override | 906 @override |
| 881 int getModificationStamp(Source source) { | 907 int getModificationStamp(Source source) { |
| 882 int stamp = _contentCache.getModificationStamp(source); | 908 int stamp = _contentCache.getModificationStamp(source); |
| 883 if (stamp != null) { | 909 if (stamp != null) { |
| 884 return stamp; | 910 return stamp; |
| 885 } | 911 } |
| 886 return source.modificationStamp; | 912 return source.modificationStamp; |
| 887 } | 913 } |
| 888 | 914 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 919 return getResolvedCompilationUnit2(unitSource, library.source); | 945 return getResolvedCompilationUnit2(unitSource, library.source); |
| 920 } | 946 } |
| 921 | 947 |
| 922 @override | 948 @override |
| 923 CompilationUnit getResolvedCompilationUnit2( | 949 CompilationUnit getResolvedCompilationUnit2( |
| 924 Source unitSource, Source librarySource) { | 950 Source unitSource, Source librarySource) { |
| 925 if (!AnalysisEngine.isDartFileName(unitSource.shortName) || | 951 if (!AnalysisEngine.isDartFileName(unitSource.shortName) || |
| 926 !AnalysisEngine.isDartFileName(librarySource.shortName)) { | 952 !AnalysisEngine.isDartFileName(librarySource.shortName)) { |
| 927 return null; | 953 return null; |
| 928 } | 954 } |
| 929 return _cache.getValue( | 955 return getResult( |
| 930 new LibrarySpecificUnit(librarySource, unitSource), RESOLVED_UNIT); | 956 new LibrarySpecificUnit(librarySource, unitSource), RESOLVED_UNIT); |
| 931 } | 957 } |
| 932 | 958 |
| 933 @override | 959 @override |
| 934 @deprecated | 960 @deprecated |
| 935 ht.HtmlUnit getResolvedHtmlUnit(Source htmlSource) { | 961 ht.HtmlUnit getResolvedHtmlUnit(Source htmlSource) { |
| 936 // TODO(brianwilkerson) Remove this method after switching to the new task | 962 // TODO(brianwilkerson) Remove this method after switching to the new task |
| 937 // model. | 963 // model. |
| 938 throw new UnimplementedError('Not supported in the new task model'); | 964 throw new UnimplementedError('Not supported in the new task model'); |
| 939 } | 965 } |
| 940 | 966 |
| 941 @override | 967 @override |
| 968 Object getResult(AnalysisTarget target, ResultDescriptor result) { |
| 969 return _cache.getValue(target, result); |
| 970 } |
| 971 |
| 972 @override |
| 942 List<Source> getSourcesWithFullName(String path) { | 973 List<Source> getSourcesWithFullName(String path) { |
| 943 return analysisCache.getSourcesWithFullName(path); | 974 return analysisCache.getSourcesWithFullName(path); |
| 944 } | 975 } |
| 945 | 976 |
| 946 @override | 977 @override |
| 947 bool handleContentsChanged( | 978 bool handleContentsChanged( |
| 948 Source source, String originalContents, String newContents, bool notify) { | 979 Source source, String originalContents, String newContents, bool notify) { |
| 949 CacheEntry entry = _cache.get(source); | 980 CacheEntry entry = _cache.get(source); |
| 950 if (entry == null) { | 981 if (entry == null) { |
| 951 return false; | 982 return false; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 985 } | 1016 } |
| 986 if (notify && changed) { | 1017 if (notify && changed) { |
| 987 _onSourcesChangedController | 1018 _onSourcesChangedController |
| 988 .add(new SourcesChangedEvent.changedContent(source, newContents)); | 1019 .add(new SourcesChangedEvent.changedContent(source, newContents)); |
| 989 } | 1020 } |
| 990 return changed; | 1021 return changed; |
| 991 } | 1022 } |
| 992 | 1023 |
| 993 @override | 1024 @override |
| 994 void invalidateLibraryHints(Source librarySource) { | 1025 void invalidateLibraryHints(Source librarySource) { |
| 995 List<Source> sources = _cache.getValue(librarySource, UNITS); | 1026 List<Source> sources = getResult(librarySource, UNITS); |
| 996 if (sources != null) { | 1027 if (sources != null) { |
| 997 for (Source source in sources) { | 1028 for (Source source in sources) { |
| 998 getCacheEntry(source).setState(HINTS, CacheState.INVALID); | 1029 getCacheEntry(source).setState(HINTS, CacheState.INVALID); |
| 999 } | 1030 } |
| 1000 } | 1031 } |
| 1001 } | 1032 } |
| 1002 | 1033 |
| 1003 @override | 1034 @override |
| 1004 bool isClientLibrary(Source librarySource) { | 1035 bool isClientLibrary(Source librarySource) { |
| 1005 CacheEntry entry = _cache.get(librarySource); | 1036 CacheEntry entry = _cache.get(librarySource); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1100 entry.setState(RESOLVE_TYPE_NAMES_ERRORS, CacheState.FLUSHED); | 1131 entry.setState(RESOLVE_TYPE_NAMES_ERRORS, CacheState.FLUSHED); |
| 1101 setValue(SCAN_ERRORS, AnalysisError.NO_ERRORS); | 1132 setValue(SCAN_ERRORS, AnalysisError.NO_ERRORS); |
| 1102 setValue(SOURCE_KIND, SourceKind.LIBRARY); | 1133 setValue(SOURCE_KIND, SourceKind.LIBRARY); |
| 1103 entry.setState(TOKEN_STREAM, CacheState.FLUSHED); | 1134 entry.setState(TOKEN_STREAM, CacheState.FLUSHED); |
| 1104 setValue(UNITS, <Source>[librarySource]); | 1135 setValue(UNITS, <Source>[librarySource]); |
| 1105 | 1136 |
| 1106 LibrarySpecificUnit unit = | 1137 LibrarySpecificUnit unit = |
| 1107 new LibrarySpecificUnit(librarySource, librarySource); | 1138 new LibrarySpecificUnit(librarySource, librarySource); |
| 1108 entry = getCacheEntry(unit); | 1139 entry = getCacheEntry(unit); |
| 1109 setValue(HINTS, AnalysisError.NO_ERRORS); | 1140 setValue(HINTS, AnalysisError.NO_ERRORS); |
| 1110 // dartEntry.setValue(LINTS, AnalysisError.NO_ERRORS); | 1141 setValue(LINTS, AnalysisError.NO_ERRORS); |
| 1111 entry.setState(RESOLVE_REFERENCES_ERRORS, CacheState.FLUSHED); | 1142 setValue(LIBRARY_UNIT_ERRORS, AnalysisError.NO_ERRORS); |
| 1143 setValue(RESOLVE_TYPE_NAMES_ERRORS, AnalysisError.NO_ERRORS); |
| 1144 setValue(RESOLVE_UNIT_ERRORS, AnalysisError.NO_ERRORS); |
| 1112 entry.setState(RESOLVED_UNIT, CacheState.FLUSHED); | 1145 entry.setState(RESOLVED_UNIT, CacheState.FLUSHED); |
| 1113 entry.setState(RESOLVED_UNIT1, CacheState.FLUSHED); | 1146 entry.setState(RESOLVED_UNIT1, CacheState.FLUSHED); |
| 1114 entry.setState(RESOLVED_UNIT2, CacheState.FLUSHED); | 1147 entry.setState(RESOLVED_UNIT2, CacheState.FLUSHED); |
| 1115 entry.setState(RESOLVED_UNIT3, CacheState.FLUSHED); | 1148 entry.setState(RESOLVED_UNIT3, CacheState.FLUSHED); |
| 1116 entry.setState(RESOLVED_UNIT4, CacheState.FLUSHED); | 1149 entry.setState(RESOLVED_UNIT4, CacheState.FLUSHED); |
| 1117 entry.setState(RESOLVED_UNIT5, CacheState.FLUSHED); | 1150 entry.setState(RESOLVED_UNIT5, CacheState.FLUSHED); |
| 1151 entry.setState(RESOLVED_UNIT6, CacheState.FLUSHED); |
| 1152 entry.setState(RESOLVED_UNIT7, CacheState.FLUSHED); |
| 1153 entry.setState(RESOLVED_UNIT8, CacheState.FLUSHED); |
| 1154 entry.setState(RESOLVED_UNIT9, CacheState.FLUSHED); |
| 1118 // USED_IMPORTED_ELEMENTS | 1155 // USED_IMPORTED_ELEMENTS |
| 1119 // USED_LOCAL_ELEMENTS | 1156 // USED_LOCAL_ELEMENTS |
| 1157 setValue(VARIABLE_REFERENCE_ERRORS, AnalysisError.NO_ERRORS); |
| 1120 setValue(VERIFY_ERRORS, AnalysisError.NO_ERRORS); | 1158 setValue(VERIFY_ERRORS, AnalysisError.NO_ERRORS); |
| 1121 }); | 1159 }); |
| 1122 | 1160 |
| 1123 CacheEntry entry = getCacheEntry(AnalysisContextTarget.request); | 1161 CacheEntry entry = getCacheEntry(AnalysisContextTarget.request); |
| 1124 entry.setValue(TYPE_PROVIDER, typeProvider, TargetedResult.EMPTY_LIST); | 1162 entry.setValue(TYPE_PROVIDER, typeProvider, TargetedResult.EMPTY_LIST); |
| 1125 } | 1163 } |
| 1126 | 1164 |
| 1127 @override | 1165 @override |
| 1128 void removeListener(AnalysisListener listener) { | 1166 void removeListener(AnalysisListener listener) { |
| 1129 _listeners.remove(listener); | 1167 _listeners.remove(listener); |
| 1130 } | 1168 } |
| 1131 | 1169 |
| 1132 @override | 1170 @override |
| 1133 CompilationUnit resolveCompilationUnit( | 1171 CompilationUnit resolveCompilationUnit( |
| 1134 Source unitSource, LibraryElement library) { | 1172 Source unitSource, LibraryElement library) { |
| 1135 if (library == null) { | 1173 if (library == null) { |
| 1136 return null; | 1174 return null; |
| 1137 } | 1175 } |
| 1138 return resolveCompilationUnit2(unitSource, library.source); | 1176 return resolveCompilationUnit2(unitSource, library.source); |
| 1139 } | 1177 } |
| 1140 | 1178 |
| 1141 @override | 1179 @override |
| 1142 CompilationUnit resolveCompilationUnit2( | 1180 CompilationUnit resolveCompilationUnit2( |
| 1143 Source unitSource, Source librarySource) { | 1181 Source unitSource, Source librarySource) { |
| 1144 if (!AnalysisEngine.isDartFileName(unitSource.shortName) || | |
| 1145 !AnalysisEngine.isDartFileName(librarySource.shortName)) { | |
| 1146 return null; | |
| 1147 } | |
| 1148 return computeResult( | 1182 return computeResult( |
| 1149 new LibrarySpecificUnit(librarySource, unitSource), RESOLVED_UNIT); | 1183 new LibrarySpecificUnit(librarySource, unitSource), RESOLVED_UNIT); |
| 1150 } | 1184 } |
| 1151 | 1185 |
| 1152 @override | 1186 @override |
| 1153 @deprecated | 1187 @deprecated |
| 1154 ht.HtmlUnit resolveHtmlUnit(Source htmlSource) { | 1188 ht.HtmlUnit resolveHtmlUnit(Source htmlSource) { |
| 1155 // TODO(brianwilkerson) Remove this method after switching to the new task | 1189 // TODO(brianwilkerson) Remove this method after switching to the new task |
| 1156 // model. | 1190 // model. |
| 1157 throw new UnimplementedError('Not supported in the new task model'); | 1191 throw new UnimplementedError('Not supported in the new task model'); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1185 | 1219 |
| 1186 @override | 1220 @override |
| 1187 void test_flushAstStructures(Source source) { | 1221 void test_flushAstStructures(Source source) { |
| 1188 CacheEntry entry = getCacheEntry(source); | 1222 CacheEntry entry = getCacheEntry(source); |
| 1189 entry.setState(PARSED_UNIT, CacheState.FLUSHED); | 1223 entry.setState(PARSED_UNIT, CacheState.FLUSHED); |
| 1190 entry.setState(RESOLVED_UNIT1, CacheState.FLUSHED); | 1224 entry.setState(RESOLVED_UNIT1, CacheState.FLUSHED); |
| 1191 entry.setState(RESOLVED_UNIT2, CacheState.FLUSHED); | 1225 entry.setState(RESOLVED_UNIT2, CacheState.FLUSHED); |
| 1192 entry.setState(RESOLVED_UNIT3, CacheState.FLUSHED); | 1226 entry.setState(RESOLVED_UNIT3, CacheState.FLUSHED); |
| 1193 entry.setState(RESOLVED_UNIT4, CacheState.FLUSHED); | 1227 entry.setState(RESOLVED_UNIT4, CacheState.FLUSHED); |
| 1194 entry.setState(RESOLVED_UNIT5, CacheState.FLUSHED); | 1228 entry.setState(RESOLVED_UNIT5, CacheState.FLUSHED); |
| 1229 entry.setState(RESOLVED_UNIT6, CacheState.FLUSHED); |
| 1230 entry.setState(RESOLVED_UNIT7, CacheState.FLUSHED); |
| 1231 entry.setState(RESOLVED_UNIT8, CacheState.FLUSHED); |
| 1232 entry.setState(RESOLVED_UNIT9, CacheState.FLUSHED); |
| 1195 entry.setState(RESOLVED_UNIT, CacheState.FLUSHED); | 1233 entry.setState(RESOLVED_UNIT, CacheState.FLUSHED); |
| 1196 } | 1234 } |
| 1197 | 1235 |
| 1198 @override | 1236 @override |
| 1199 bool validateCacheConsistency() { | 1237 bool validateCacheConsistency() { |
| 1200 int consistencyCheckStart = JavaSystem.nanoTime(); | 1238 int consistencyCheckStart = JavaSystem.nanoTime(); |
| 1201 HashSet<Source> changedSources = new HashSet<Source>(); | 1239 HashSet<Source> changedSources = new HashSet<Source>(); |
| 1202 HashSet<Source> missingSources = new HashSet<Source>(); | 1240 HashSet<Source> missingSources = new HashSet<Source>(); |
| 1203 for (Source source in _cache.sources) { | 1241 for (Source source in _cache.sources) { |
| 1204 CacheEntry entry = _cache.get(source); | 1242 CacheEntry entry = _cache.get(source); |
| 1205 int sourceTime = getModificationStamp(source); | 1243 int sourceTime = getModificationStamp(source); |
| 1206 if (sourceTime != entry.modificationTime) { | 1244 if (sourceTime != entry.modificationTime) { |
| 1207 changedSources.add(source); | 1245 changedSources.add(source); |
| 1208 } | 1246 } |
| 1209 if (entry.exception != null) { | 1247 if (entry.exception != null) { |
| 1210 if (!exists(source)) { | 1248 if (!exists(source)) { |
| 1211 missingSources.add(source); | 1249 missingSources.add(source); |
| 1212 } | 1250 } |
| 1213 } | 1251 } |
| 1214 } | 1252 } |
| 1215 for (Source source in changedSources) { | 1253 for (Source source in changedSources) { |
| 1216 _sourceChanged(source); | 1254 _sourceChanged(source); |
| 1217 } | 1255 } |
| 1218 int removalCount = 0; | 1256 int removalCount = 0; |
| 1219 for (Source source in missingSources) { | 1257 for (Source source in missingSources) { |
| 1220 if (getLibrariesContaining(source).isEmpty && | 1258 if (getLibrariesContaining(source).isEmpty && |
| 1221 getLibrariesDependingOn(source).isEmpty) { | 1259 getLibrariesDependingOn(source).isEmpty) { |
| 1222 _cache.remove(source); | 1260 _removeFromCache(source); |
| 1223 removalCount++; | 1261 removalCount++; |
| 1224 } | 1262 } |
| 1225 } | 1263 } |
| 1226 int consistencyCheckEnd = JavaSystem.nanoTime(); | 1264 int consistencyCheckEnd = JavaSystem.nanoTime(); |
| 1227 if (changedSources.length > 0 || missingSources.length > 0) { | 1265 if (changedSources.length > 0 || missingSources.length > 0) { |
| 1228 StringBuffer buffer = new StringBuffer(); | 1266 StringBuffer buffer = new StringBuffer(); |
| 1229 buffer.write("Consistency check took "); | 1267 buffer.write("Consistency check took "); |
| 1230 buffer.write((consistencyCheckEnd - consistencyCheckStart) / 1000000.0); | 1268 buffer.write((consistencyCheckEnd - consistencyCheckStart) / 1000000.0); |
| 1231 buffer.writeln(" ms and found"); | 1269 buffer.writeln(" ms and found"); |
| 1232 buffer.write(" "); | 1270 buffer.write(" "); |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1420 /** | 1458 /** |
| 1421 * Create a cache entry for the given [source]. The source was explicitly | 1459 * Create a cache entry for the given [source]. The source was explicitly |
| 1422 * added to this context if [explicitlyAdded] is `true`. Return the cache | 1460 * added to this context if [explicitlyAdded] is `true`. Return the cache |
| 1423 * entry that was created. | 1461 * entry that was created. |
| 1424 */ | 1462 */ |
| 1425 CacheEntry _createCacheEntry(Source source, bool explicitlyAdded) { | 1463 CacheEntry _createCacheEntry(Source source, bool explicitlyAdded) { |
| 1426 CacheEntry entry = new CacheEntry(source); | 1464 CacheEntry entry = new CacheEntry(source); |
| 1427 entry.modificationTime = getModificationStamp(source); | 1465 entry.modificationTime = getModificationStamp(source); |
| 1428 entry.explicitlyAdded = explicitlyAdded; | 1466 entry.explicitlyAdded = explicitlyAdded; |
| 1429 _cache.put(entry); | 1467 _cache.put(entry); |
| 1468 if (!explicitlyAdded) { |
| 1469 _implicitAnalysisEventsController |
| 1470 .add(new ImplicitAnalysisEvent(source, true)); |
| 1471 } |
| 1430 return entry; | 1472 return entry; |
| 1431 } | 1473 } |
| 1432 | 1474 |
| 1433 /** | 1475 /** |
| 1434 * Return a list containing all of the cache entries for targets associated | 1476 * Return a list containing all of the cache entries for targets associated |
| 1435 * with the given [source]. | 1477 * with the given [source]. |
| 1436 */ | 1478 */ |
| 1437 List<CacheEntry> _entriesFor(Source source) { | 1479 List<CacheEntry> _entriesFor(Source source) { |
| 1438 List<CacheEntry> entries = <CacheEntry>[]; | 1480 List<CacheEntry> entries = <CacheEntry>[]; |
| 1439 MapIterator<AnalysisTarget, CacheEntry> iterator = _cache.iterator(); | 1481 MapIterator<AnalysisTarget, CacheEntry> iterator = _cache.iterator(); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1500 return Source.EMPTY_LIST; | 1542 return Source.EMPTY_LIST; |
| 1501 } | 1543 } |
| 1502 return sources; | 1544 return sources; |
| 1503 } | 1545 } |
| 1504 | 1546 |
| 1505 /** | 1547 /** |
| 1506 * Look at the given [source] to see whether a task needs to be performed | 1548 * Look at the given [source] to see whether a task needs to be performed |
| 1507 * related to it. If so, add the source to the set of sources that need to be | 1549 * related to it. If so, add the source to the set of sources that need to be |
| 1508 * processed. This method is intended to be used for testing purposes only. | 1550 * processed. This method is intended to be used for testing purposes only. |
| 1509 */ | 1551 */ |
| 1510 void _getSourcesNeedingProcessing(Source source, CacheEntry entry, | 1552 void _getSourcesNeedingProcessing( |
| 1511 bool isPriority, bool hintsEnabled, bool lintsEnabled, | 1553 Source source, |
| 1554 CacheEntry entry, |
| 1555 bool isPriority, |
| 1556 bool hintsEnabled, |
| 1557 bool lintsEnabled, |
| 1512 HashSet<Source> sources) { | 1558 HashSet<Source> sources) { |
| 1513 CacheState state = entry.getState(CONTENT); | 1559 CacheState state = entry.getState(CONTENT); |
| 1514 if (state == CacheState.INVALID || | 1560 if (state == CacheState.INVALID || |
| 1515 (isPriority && state == CacheState.FLUSHED)) { | 1561 (isPriority && state == CacheState.FLUSHED)) { |
| 1516 sources.add(source); | 1562 sources.add(source); |
| 1517 return; | 1563 return; |
| 1518 } else if (state == CacheState.ERROR) { | 1564 } else if (state == CacheState.ERROR) { |
| 1519 return; | 1565 return; |
| 1520 } | 1566 } |
| 1521 state = entry.getState(SOURCE_KIND); | 1567 state = entry.getState(SOURCE_KIND); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1582 if (hintsEnabled) { | 1628 if (hintsEnabled) { |
| 1583 state = unitEntry.getState(HINTS); | 1629 state = unitEntry.getState(HINTS); |
| 1584 if (state == CacheState.INVALID || | 1630 if (state == CacheState.INVALID || |
| 1585 (isPriority && state == CacheState.FLUSHED)) { | 1631 (isPriority && state == CacheState.FLUSHED)) { |
| 1586 sources.add(source); | 1632 sources.add(source); |
| 1587 return; | 1633 return; |
| 1588 } else if (state == CacheState.ERROR) { | 1634 } else if (state == CacheState.ERROR) { |
| 1589 return; | 1635 return; |
| 1590 } | 1636 } |
| 1591 } | 1637 } |
| 1592 // if (lintsEnabled) { | 1638 if (lintsEnabled) { |
| 1593 // state = unitEntry.getState(LINTS); | 1639 state = unitEntry.getState(LINTS); |
| 1594 // if (state == CacheState.INVALID || | 1640 if (state == CacheState.INVALID || |
| 1595 // (isPriority && state == CacheState.FLUSHED)) { | 1641 (isPriority && state == CacheState.FLUSHED)) { |
| 1596 // sources.add(source); | 1642 sources.add(source); |
| 1597 // return; | 1643 return; |
| 1598 // } else if (state == CacheState.ERROR) { | 1644 } else if (state == CacheState.ERROR) { |
| 1599 // return; | 1645 return; |
| 1600 // } | 1646 } |
| 1601 // } | 1647 } |
| 1602 } | 1648 } |
| 1603 } | 1649 } |
| 1604 // } else if (kind == SourceKind.HTML) { | 1650 // } else if (kind == SourceKind.HTML) { |
| 1605 // CacheState parsedUnitState = entry.getState(HtmlEntry.PARSED_UNIT); | 1651 // CacheState parsedUnitState = entry.getState(HtmlEntry.PARSED_UNIT); |
| 1606 // if (parsedUnitState == CacheState.INVALID || | 1652 // if (parsedUnitState == CacheState.INVALID || |
| 1607 // (isPriority && parsedUnitState == CacheState.FLUSHED)) { | 1653 // (isPriority && parsedUnitState == CacheState.FLUSHED)) { |
| 1608 // sources.add(source); | 1654 // sources.add(source); |
| 1609 // return; | 1655 // return; |
| 1610 // } | 1656 // } |
| 1611 // CacheState resolvedUnitState = | 1657 // CacheState resolvedUnitState = |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1630 * given [source] has been updated to the given [errors]. | 1676 * given [source] has been updated to the given [errors]. |
| 1631 */ | 1677 */ |
| 1632 void _notifyErrors( | 1678 void _notifyErrors( |
| 1633 Source source, List<AnalysisError> errors, LineInfo lineInfo) { | 1679 Source source, List<AnalysisError> errors, LineInfo lineInfo) { |
| 1634 int count = _listeners.length; | 1680 int count = _listeners.length; |
| 1635 for (int i = 0; i < count; i++) { | 1681 for (int i = 0; i < count; i++) { |
| 1636 _listeners[i].computedErrors(this, source, errors, lineInfo); | 1682 _listeners[i].computedErrors(this, source, errors, lineInfo); |
| 1637 } | 1683 } |
| 1638 } | 1684 } |
| 1639 | 1685 |
| 1686 void _removeFromCache(Source source) { |
| 1687 CacheEntry entry = _cache.remove(source); |
| 1688 if (entry != null && !entry.explicitlyAdded) { |
| 1689 _implicitAnalysisEventsController |
| 1690 .add(new ImplicitAnalysisEvent(source, false)); |
| 1691 } |
| 1692 } |
| 1693 |
| 1640 /** | 1694 /** |
| 1641 * Remove the given [source] from the priority order if it is in the list. | 1695 * Remove the given [source] from the priority order if it is in the list. |
| 1642 */ | 1696 */ |
| 1643 void _removeFromPriorityOrder(Source source) { | 1697 void _removeFromPriorityOrder(Source source) { |
| 1644 int count = _priorityOrder.length; | 1698 int count = _priorityOrder.length; |
| 1645 List<Source> newOrder = <Source>[]; | 1699 List<Source> newOrder = <Source>[]; |
| 1646 for (int i = 0; i < count; i++) { | 1700 for (int i = 0; i < count; i++) { |
| 1647 if (_priorityOrder[i] != source) { | 1701 if (_priorityOrder[i] != source) { |
| 1648 newOrder.add(_priorityOrder[i]); | 1702 newOrder.add(_priorityOrder[i]); |
| 1649 } | 1703 } |
| 1650 } | 1704 } |
| 1651 if (newOrder.length < count) { | 1705 if (newOrder.length < count) { |
| 1652 analysisPriorityOrder = newOrder; | 1706 analysisPriorityOrder = newOrder; |
| 1653 } | 1707 } |
| 1654 } | 1708 } |
| 1655 | 1709 |
| 1656 /** | 1710 /** |
| 1657 * Create an entry for the newly added [source] and invalidate any sources | 1711 * Create an entry for the newly added [source] and invalidate any sources |
| 1658 * that referenced the source before it existed. | 1712 * that referenced the source before it existed. |
| 1659 */ | 1713 */ |
| 1660 void _sourceAvailable(Source source) { | 1714 void _sourceAvailable(Source source) { |
| 1715 // TODO(brianwilkerson) This method needs to check whether the source was |
| 1716 // previously being implicitly analyzed. If so, the cache entry needs to be |
| 1717 // update to reflect the new status and an event needs to be generated to |
| 1718 // inform clients that it is no longer being implicitly analyzed. |
| 1661 CacheEntry entry = _cache.get(source); | 1719 CacheEntry entry = _cache.get(source); |
| 1662 if (entry == null) { | 1720 if (entry == null) { |
| 1663 _createCacheEntry(source, true); | 1721 _createCacheEntry(source, true); |
| 1664 } else { | 1722 } else { |
| 1665 entry.modificationTime = getModificationStamp(source); | 1723 entry.modificationTime = getModificationStamp(source); |
| 1666 entry.setState(CONTENT, CacheState.INVALID); | 1724 entry.setState(CONTENT, CacheState.INVALID); |
| 1667 } | 1725 } |
| 1668 } | 1726 } |
| 1669 | 1727 |
| 1670 /** | 1728 /** |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1684 entry.setState(CONTENT, CacheState.FLUSHED); | 1742 entry.setState(CONTENT, CacheState.FLUSHED); |
| 1685 try { | 1743 try { |
| 1686 TimestampedData<String> fileContents = getContents(source); | 1744 TimestampedData<String> fileContents = getContents(source); |
| 1687 if (fileContents.data == sourceContent) { | 1745 if (fileContents.data == sourceContent) { |
| 1688 int time = fileContents.modificationTime; | 1746 int time = fileContents.modificationTime; |
| 1689 for (CacheEntry entry in _entriesFor(source)) { | 1747 for (CacheEntry entry in _entriesFor(source)) { |
| 1690 entry.modificationTime = time; | 1748 entry.modificationTime = time; |
| 1691 } | 1749 } |
| 1692 return; | 1750 return; |
| 1693 } | 1751 } |
| 1694 } catch (e) {} | 1752 } catch (e) { |
| 1753 entry.modificationTime = -1; |
| 1754 } |
| 1695 } | 1755 } |
| 1696 // We need to invalidate the cache. | 1756 // We need to invalidate the cache. |
| 1697 { | 1757 { |
| 1698 Object delta = null; | 1758 Object delta = null; |
| 1699 if (AnalysisEngine.instance.limitInvalidationInTaskModel && | 1759 if (AnalysisEngine.instance.limitInvalidationInTaskModel && |
| 1700 AnalysisEngine.isDartFileName(source.fullName)) { | 1760 AnalysisEngine.isDartFileName(source.fullName)) { |
| 1701 // TODO(scheglov) Incorrect implementation in general. | 1761 // TODO(scheglov) Incorrect implementation in general. |
| 1702 entry.setState(TOKEN_STREAM, CacheState.FLUSHED); | 1762 entry.setState(TOKEN_STREAM, CacheState.FLUSHED); |
| 1703 entry.setState(PARSED_UNIT, CacheState.FLUSHED); | 1763 entry.setState(PARSED_UNIT, CacheState.FLUSHED); |
| 1704 List<Source> librarySources = getLibrariesContaining(source); | 1764 List<Source> librarySources = getLibrariesContaining(source); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1721 // 'dartDelta: add=${dartDelta.addedNames} remove=${dartDelta.r
emovedNames}'); | 1781 // 'dartDelta: add=${dartDelta.addedNames} remove=${dartDelta.r
emovedNames}'); |
| 1722 delta = dartDelta; | 1782 delta = dartDelta; |
| 1723 entry.setState(CONTENT, CacheState.INVALID, delta: delta); | 1783 entry.setState(CONTENT, CacheState.INVALID, delta: delta); |
| 1724 return; | 1784 return; |
| 1725 } | 1785 } |
| 1726 } | 1786 } |
| 1727 } | 1787 } |
| 1728 } | 1788 } |
| 1729 entry.setState(CONTENT, CacheState.INVALID); | 1789 entry.setState(CONTENT, CacheState.INVALID); |
| 1730 } | 1790 } |
| 1731 dartWorkManager.applyChange( | 1791 for (WorkManager workManager in workManagers) { |
| 1732 Source.EMPTY_LIST, <Source>[source], Source.EMPTY_LIST); | 1792 workManager.applyChange( |
| 1733 htmlWorkManager.applyChange( | 1793 Source.EMPTY_LIST, <Source>[source], Source.EMPTY_LIST); |
| 1734 Source.EMPTY_LIST, <Source>[source], Source.EMPTY_LIST); | 1794 } |
| 1735 } | 1795 } |
| 1736 | 1796 |
| 1737 /** | 1797 /** |
| 1738 * Record that the give [source] has been deleted. | 1798 * Record that the give [source] has been deleted. |
| 1739 */ | 1799 */ |
| 1740 void _sourceDeleted(Source source) { | 1800 void _sourceDeleted(Source source) { |
| 1741 // TODO(brianwilkerson) Implement this. | 1801 // TODO(brianwilkerson) Implement or remove this. |
| 1742 // SourceEntry sourceEntry = _cache.get(source); | 1802 // SourceEntry sourceEntry = _cache.get(source); |
| 1743 // if (sourceEntry is HtmlEntry) { | 1803 // if (sourceEntry is HtmlEntry) { |
| 1744 // HtmlEntry htmlEntry = sourceEntry; | 1804 // HtmlEntry htmlEntry = sourceEntry; |
| 1745 // htmlEntry.recordContentError(new CaughtException( | 1805 // htmlEntry.recordContentError(new CaughtException( |
| 1746 // new AnalysisException("This source was marked as being deleted"), | 1806 // new AnalysisException("This source was marked as being deleted"), |
| 1747 // null)); | 1807 // null)); |
| 1748 // } else if (sourceEntry is DartEntry) { | 1808 // } else if (sourceEntry is DartEntry) { |
| 1749 // DartEntry dartEntry = sourceEntry; | 1809 // DartEntry dartEntry = sourceEntry; |
| 1750 // HashSet<Source> libraries = new HashSet<Source>(); | 1810 // HashSet<Source> libraries = new HashSet<Source>(); |
| 1751 // for (Source librarySource in getLibrariesContaining(source)) { | 1811 // for (Source librarySource in getLibrariesContaining(source)) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1762 // new AnalysisException("This source was marked as being deleted"), | 1822 // new AnalysisException("This source was marked as being deleted"), |
| 1763 // null)); | 1823 // null)); |
| 1764 // } | 1824 // } |
| 1765 _removeFromPriorityOrder(source); | 1825 _removeFromPriorityOrder(source); |
| 1766 } | 1826 } |
| 1767 | 1827 |
| 1768 /** | 1828 /** |
| 1769 * Record that the given [source] has been removed. | 1829 * Record that the given [source] has been removed. |
| 1770 */ | 1830 */ |
| 1771 void _sourceRemoved(Source source) { | 1831 void _sourceRemoved(Source source) { |
| 1772 _cache.remove(source); | 1832 _removeFromCache(source); |
| 1773 _removeFromPriorityOrder(source); | 1833 _removeFromPriorityOrder(source); |
| 1774 } | 1834 } |
| 1775 | 1835 |
| 1776 /** | 1836 /** |
| 1777 * TODO(scheglov) A hackish, limited incremental resolution implementation. | 1837 * TODO(scheglov) A hackish, limited incremental resolution implementation. |
| 1778 */ | 1838 */ |
| 1779 bool _tryPoorMansIncrementalResolution(Source unitSource, String newCode) { | 1839 bool _tryPoorMansIncrementalResolution(Source unitSource, String newCode) { |
| 1780 return PerformanceStatistics.incrementalAnalysis.makeCurrentWhile(() { | 1840 return PerformanceStatistics.incrementalAnalysis.makeCurrentWhile(() { |
| 1781 incrementalResolutionValidation_lastUnitSource = null; | 1841 incrementalResolutionValidation_lastUnitSource = null; |
| 1782 incrementalResolutionValidation_lastLibrarySource = null; | 1842 incrementalResolutionValidation_lastLibrarySource = null; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1804 } | 1864 } |
| 1805 // prepare the existing unit | 1865 // prepare the existing unit |
| 1806 CompilationUnit oldUnit = | 1866 CompilationUnit oldUnit = |
| 1807 getResolvedCompilationUnit2(unitSource, librarySource); | 1867 getResolvedCompilationUnit2(unitSource, librarySource); |
| 1808 if (oldUnit == null) { | 1868 if (oldUnit == null) { |
| 1809 return false; | 1869 return false; |
| 1810 } | 1870 } |
| 1811 // do resolution | 1871 // do resolution |
| 1812 Stopwatch perfCounter = new Stopwatch()..start(); | 1872 Stopwatch perfCounter = new Stopwatch()..start(); |
| 1813 PoorMansIncrementalResolver resolver = new PoorMansIncrementalResolver( | 1873 PoorMansIncrementalResolver resolver = new PoorMansIncrementalResolver( |
| 1814 typeProvider, unitSource, null, sourceEntry, unitEntry, oldUnit, | 1874 typeProvider, |
| 1815 analysisOptions.incrementalApi, analysisOptions); | 1875 unitSource, |
| 1876 null, |
| 1877 sourceEntry, |
| 1878 unitEntry, |
| 1879 oldUnit, |
| 1880 analysisOptions.incrementalApi); |
| 1816 bool success = resolver.resolve(newCode); | 1881 bool success = resolver.resolve(newCode); |
| 1817 AnalysisEngine.instance.instrumentationService.logPerformance( | 1882 AnalysisEngine.instance.instrumentationService.logPerformance( |
| 1818 AnalysisPerformanceKind.INCREMENTAL, perfCounter, | 1883 AnalysisPerformanceKind.INCREMENTAL, |
| 1884 perfCounter, |
| 1819 'success=$success,context_id=$_id,code_length=${newCode.length}'); | 1885 'success=$success,context_id=$_id,code_length=${newCode.length}'); |
| 1820 if (!success) { | 1886 if (!success) { |
| 1821 return false; | 1887 return false; |
| 1822 } | 1888 } |
| 1823 // if validation, remember the result, but throw it away | 1889 // if validation, remember the result, but throw it away |
| 1824 if (analysisOptions.incrementalValidation) { | 1890 if (analysisOptions.incrementalValidation) { |
| 1825 incrementalResolutionValidation_lastUnitSource = oldUnit.element.source; | 1891 incrementalResolutionValidation_lastUnitSource = oldUnit.element.source; |
| 1826 incrementalResolutionValidation_lastLibrarySource = | 1892 incrementalResolutionValidation_lastLibrarySource = |
| 1827 oldUnit.element.library.source; | 1893 oldUnit.element.library.source; |
| 1828 incrementalResolutionValidation_lastUnit = oldUnit; | 1894 incrementalResolutionValidation_lastUnit = oldUnit; |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2022 new PendingFuture<T>(_context, target, computeValue); | 2088 new PendingFuture<T>(_context, target, computeValue); |
| 2023 if (!pendingFuture.evaluate(entry)) { | 2089 if (!pendingFuture.evaluate(entry)) { |
| 2024 _context._pendingFutureTargets | 2090 _context._pendingFutureTargets |
| 2025 .putIfAbsent(target, () => <PendingFuture>[]) | 2091 .putIfAbsent(target, () => <PendingFuture>[]) |
| 2026 .add(pendingFuture); | 2092 .add(pendingFuture); |
| 2027 scheduleComputation(); | 2093 scheduleComputation(); |
| 2028 } | 2094 } |
| 2029 return pendingFuture.future; | 2095 return pendingFuture.future; |
| 2030 } | 2096 } |
| 2031 } | 2097 } |
| OLD | NEW |