Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 analysis.server; | 5 library analysis.server; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 import 'dart:core'; | 9 import 'dart:core'; |
| 10 import 'dart:io' as io; | 10 import 'dart:io' as io; |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 329 * The package resolver provider used to override the way package URI's are | 329 * The package resolver provider used to override the way package URI's are |
| 330 * resolved in some contexts. | 330 * resolved in some contexts. |
| 331 */ | 331 */ |
| 332 ResolverProvider packageResolverProvider; | 332 ResolverProvider packageResolverProvider; |
| 333 | 333 |
| 334 nd.PerformanceLog _analysisPerformanceLogger; | 334 nd.PerformanceLog _analysisPerformanceLogger; |
| 335 ByteStore byteStore; | 335 ByteStore byteStore; |
| 336 nd.AnalysisDriverScheduler analysisDriverScheduler; | 336 nd.AnalysisDriverScheduler analysisDriverScheduler; |
| 337 | 337 |
| 338 /** | 338 /** |
| 339 * This exists as a temporary stopgap for plugins, until the official plugin | |
| 340 * API is complete. | |
| 341 */ | |
| 342 StreamController<String> _onFileAddedController; | |
| 343 | |
| 344 /** | |
| 345 * This exists as a temporary stopgap for plugins, until the official plugin | |
| 346 * API is complete. | |
| 347 */ | |
| 348 StreamController<String> _onFileChangedController; | |
| 349 | |
| 350 /** | |
| 339 * The set of the files that are currently priority. | 351 * The set of the files that are currently priority. |
| 340 */ | 352 */ |
| 341 final Set<String> priorityFiles = new Set<String>(); | 353 final Set<String> priorityFiles = new Set<String>(); |
| 342 | 354 |
| 343 /** | 355 /** |
| 344 * The DiagnosticServer for this AnalysisServer. If available, it can be used | 356 * The DiagnosticServer for this AnalysisServer. If available, it can be used |
| 345 * to start an http diagnostics server or return the port for an existing | 357 * to start an http diagnostics server or return the port for an existing |
| 346 * server. | 358 * server. |
| 347 */ | 359 */ |
| 348 DiagnosticServer diagnosticServer; | 360 DiagnosticServer diagnosticServer; |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 364 this.serverPlugin, | 376 this.serverPlugin, |
| 365 this.options, | 377 this.options, |
| 366 this.sdkManager, | 378 this.sdkManager, |
| 367 this.instrumentationService, | 379 this.instrumentationService, |
| 368 {this.diagnosticServer, | 380 {this.diagnosticServer, |
| 369 ResolverProvider fileResolverProvider: null, | 381 ResolverProvider fileResolverProvider: null, |
| 370 ResolverProvider packageResolverProvider: null, | 382 ResolverProvider packageResolverProvider: null, |
| 371 bool useSingleContextManager: false, | 383 bool useSingleContextManager: false, |
| 372 this.rethrowExceptions: true}) | 384 this.rethrowExceptions: true}) |
| 373 // TODO(brianwilkerson) Initialize notificationManager to | 385 // TODO(brianwilkerson) Initialize notificationManager to |
| 374 // "new NotificationManager(channel, resourceProvider)" | 386 // "new NotificationManager(channel, resourceProvider)" |
|
Brian Wilkerson
2017/03/13 21:00:22
You can delete the TODO comment now.
| |
| 375 : notificationManager = null { | 387 : notificationManager = |
| 388 new NotificationManager(channel, resourceProvider) { | |
| 376 _performance = performanceDuringStartup; | 389 _performance = performanceDuringStartup; |
| 377 defaultContextOptions.incremental = true; | 390 defaultContextOptions.incremental = true; |
| 378 defaultContextOptions.incrementalApi = | 391 defaultContextOptions.incrementalApi = |
| 379 options.enableIncrementalResolutionApi; | 392 options.enableIncrementalResolutionApi; |
| 380 defaultContextOptions.incrementalValidation = | 393 defaultContextOptions.incrementalValidation = |
| 381 options.enableIncrementalResolutionValidation; | 394 options.enableIncrementalResolutionValidation; |
| 382 defaultContextOptions.finerGrainedInvalidation = | 395 defaultContextOptions.finerGrainedInvalidation = |
| 383 options.finerGrainedInvalidation; | 396 options.finerGrainedInvalidation; |
| 384 defaultContextOptions.generateImplicitErrors = false; | 397 defaultContextOptions.generateImplicitErrors = false; |
| 385 operationQueue = new ServerOperationQueue(); | 398 operationQueue = new ServerOperationQueue(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 418 options.enableNewAnalysisDriver); | 431 options.enableNewAnalysisDriver); |
| 419 } | 432 } |
| 420 this.fileResolverProvider = fileResolverProvider; | 433 this.fileResolverProvider = fileResolverProvider; |
| 421 this.packageResolverProvider = packageResolverProvider; | 434 this.packageResolverProvider = packageResolverProvider; |
| 422 ServerContextManagerCallbacks contextManagerCallbacks = | 435 ServerContextManagerCallbacks contextManagerCallbacks = |
| 423 new ServerContextManagerCallbacks(this, resourceProvider); | 436 new ServerContextManagerCallbacks(this, resourceProvider); |
| 424 contextManager.callbacks = contextManagerCallbacks; | 437 contextManager.callbacks = contextManagerCallbacks; |
| 425 AnalysisEngine.instance.logger = new AnalysisLogger(this); | 438 AnalysisEngine.instance.logger = new AnalysisLogger(this); |
| 426 _onAnalysisStartedController = new StreamController.broadcast(); | 439 _onAnalysisStartedController = new StreamController.broadcast(); |
| 427 _onFileAnalyzedController = new StreamController.broadcast(); | 440 _onFileAnalyzedController = new StreamController.broadcast(); |
| 441 // temporary plugin support: | |
| 442 _onFileAddedController = new StreamController.broadcast(); | |
| 443 // temporary plugin support: | |
| 444 _onFileChangedController = new StreamController.broadcast(); | |
| 428 _onPriorityChangeController = | 445 _onPriorityChangeController = |
| 429 new StreamController<PriorityChangeEvent>.broadcast(); | 446 new StreamController<PriorityChangeEvent>.broadcast(); |
| 430 running = true; | 447 running = true; |
| 431 onAnalysisStarted.first.then((_) { | 448 onAnalysisStarted.first.then((_) { |
| 432 onAnalysisComplete.then((_) { | 449 onAnalysisComplete.then((_) { |
| 433 performanceAfterStartup = new ServerPerformance(); | 450 performanceAfterStartup = new ServerPerformance(); |
| 434 _performance = performanceAfterStartup; | 451 _performance = performanceAfterStartup; |
| 435 }); | 452 }); |
| 436 }); | 453 }); |
| 437 _setupIndexInvalidation(); | 454 _setupIndexInvalidation(); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 512 */ | 529 */ |
| 513 Stream<ContextsChangedEvent> get onContextsChanged => | 530 Stream<ContextsChangedEvent> get onContextsChanged => |
| 514 _onContextsChangedController.stream; | 531 _onContextsChangedController.stream; |
| 515 | 532 |
| 516 /** | 533 /** |
| 517 * The stream that is notified when a single file has been analyzed. | 534 * The stream that is notified when a single file has been analyzed. |
| 518 */ | 535 */ |
| 519 Stream get onFileAnalyzed => _onFileAnalyzedController.stream; | 536 Stream get onFileAnalyzed => _onFileAnalyzedController.stream; |
| 520 | 537 |
| 521 /** | 538 /** |
| 539 * The stream that is notified when a single file has been added. This exists | |
| 540 * as a temporary stopgap for plugins, until the official plugin API is | |
| 541 * complete. | |
| 542 */ | |
| 543 Stream get onFileAdded => _onFileAddedController.stream; | |
| 544 | |
| 545 /** | |
| 546 * The stream that is notified when a single file has been changed. This | |
| 547 * exists as a temporary stopgap for plugins, until the official plugin API is | |
| 548 * complete. | |
| 549 */ | |
| 550 Stream get onFileChanged => _onFileChangedController.stream; | |
| 551 | |
| 552 /** | |
| 522 * The stream that is notified when priority sources change. | 553 * The stream that is notified when priority sources change. |
| 523 */ | 554 */ |
| 524 Stream<PriorityChangeEvent> get onPriorityChange => | 555 Stream<PriorityChangeEvent> get onPriorityChange => |
| 525 _onPriorityChangeController.stream; | 556 _onPriorityChangeController.stream; |
| 526 | 557 |
| 527 /** | 558 /** |
| 528 * The [Future] that completes when the next operation is performed. | 559 * The [Future] that completes when the next operation is performed. |
| 529 */ | 560 */ |
| 530 Future get test_onOperationPerformed { | 561 Future get test_onOperationPerformed { |
| 531 if (_test_onOperationPerformedCompleter == null) { | 562 if (_test_onOperationPerformedCompleter == null) { |
| (...skipping 980 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1512 // Protocol parsing should have ensured that we never get here. | 1543 // Protocol parsing should have ensured that we never get here. |
| 1513 throw new AnalysisException('Illegal change type'); | 1544 throw new AnalysisException('Illegal change type'); |
| 1514 } | 1545 } |
| 1515 | 1546 |
| 1516 fileContentOverlay[file] = newContents; | 1547 fileContentOverlay[file] = newContents; |
| 1517 | 1548 |
| 1518 driverMap.values.forEach((driver) { | 1549 driverMap.values.forEach((driver) { |
| 1519 driver.changeFile(file); | 1550 driver.changeFile(file); |
| 1520 }); | 1551 }); |
| 1521 | 1552 |
| 1553 // temporary plugin support: | |
| 1554 _onFileAddedController.add(file); | |
|
Brian Wilkerson
2017/03/13 21:00:22
Should this be `_onFileChangedController`?
| |
| 1555 | |
| 1522 // If the file did not exist, and is "overlay only", it still should be | 1556 // If the file did not exist, and is "overlay only", it still should be |
| 1523 // analyzed. Add it to driver to which it should have been added. | 1557 // analyzed. Add it to driver to which it should have been added. |
| 1524 contextManager.getDriverFor(file)?.addFile(file); | 1558 contextManager.getDriverFor(file)?.addFile(file); |
| 1525 | 1559 |
| 1526 // TODO(scheglov) implement other cases | 1560 // TODO(scheglov) implement other cases |
| 1527 }); | 1561 }); |
| 1528 return; | 1562 return; |
| 1529 } | 1563 } |
| 1530 changes.forEach((file, change) { | 1564 changes.forEach((file, change) { |
| 1531 ContextSourcePair contextSource = getContextSourcePair(file); | 1565 ContextSourcePair contextSource = getContextSourcePair(file); |
| (...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1981 } | 2015 } |
| 1982 | 2016 |
| 1983 @override | 2017 @override |
| 1984 void applyChangesToContext(Folder contextFolder, ChangeSet changeSet) { | 2018 void applyChangesToContext(Folder contextFolder, ChangeSet changeSet) { |
| 1985 if (analysisServer.options.enableNewAnalysisDriver) { | 2019 if (analysisServer.options.enableNewAnalysisDriver) { |
| 1986 nd.AnalysisDriver analysisDriver = | 2020 nd.AnalysisDriver analysisDriver = |
| 1987 analysisServer.driverMap[contextFolder]; | 2021 analysisServer.driverMap[contextFolder]; |
| 1988 if (analysisDriver != null) { | 2022 if (analysisDriver != null) { |
| 1989 changeSet.addedSources.forEach((source) { | 2023 changeSet.addedSources.forEach((source) { |
| 1990 analysisDriver.addFile(source.fullName); | 2024 analysisDriver.addFile(source.fullName); |
| 2025 // temporary plugin support: | |
| 2026 analysisServer._onFileAddedController.add(source.fullName); | |
| 1991 }); | 2027 }); |
| 1992 changeSet.changedSources.forEach((source) { | 2028 changeSet.changedSources.forEach((source) { |
| 1993 analysisDriver.changeFile(source.fullName); | 2029 analysisDriver.changeFile(source.fullName); |
| 2030 // temporary plugin support: | |
| 2031 analysisServer._onFileChangedController.add(source.fullName); | |
| 1994 }); | 2032 }); |
| 1995 changeSet.removedSources.forEach((source) { | 2033 changeSet.removedSources.forEach((source) { |
| 1996 analysisDriver.removeFile(source.fullName); | 2034 analysisDriver.removeFile(source.fullName); |
| 1997 }); | 2035 }); |
| 1998 } | 2036 } |
| 1999 } else { | 2037 } else { |
| 2000 AnalysisContext context = analysisServer.folderMap[contextFolder]; | 2038 AnalysisContext context = analysisServer.folderMap[contextFolder]; |
| 2001 if (context != null) { | 2039 if (context != null) { |
| 2002 context.applyChanges(changeSet); | 2040 context.applyChanges(changeSet); |
| 2003 analysisServer.schedulePerformAnalysisOperation(context); | 2041 analysisServer.schedulePerformAnalysisOperation(context); |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2259 /** | 2297 /** |
| 2260 * The [PerformanceTag] for time spent in server request handlers. | 2298 * The [PerformanceTag] for time spent in server request handlers. |
| 2261 */ | 2299 */ |
| 2262 static PerformanceTag serverRequests = new PerformanceTag('serverRequests'); | 2300 static PerformanceTag serverRequests = new PerformanceTag('serverRequests'); |
| 2263 | 2301 |
| 2264 /** | 2302 /** |
| 2265 * The [PerformanceTag] for time spent in split store microtasks. | 2303 * The [PerformanceTag] for time spent in split store microtasks. |
| 2266 */ | 2304 */ |
| 2267 static PerformanceTag splitStore = new PerformanceTag('splitStore'); | 2305 static PerformanceTag splitStore = new PerformanceTag('splitStore'); |
| 2268 } | 2306 } |
| OLD | NEW |