| 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 14 matching lines...) Expand all Loading... |
| 363 this.index, | 375 this.index, |
| 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 : notificationManager = |
| 374 // "new NotificationManager(channel, resourceProvider)" | 386 new NotificationManager(channel, resourceProvider) { |
| 375 : notificationManager = null { | |
| 376 _performance = performanceDuringStartup; | 387 _performance = performanceDuringStartup; |
| 377 defaultContextOptions.incremental = true; | 388 defaultContextOptions.incremental = true; |
| 378 defaultContextOptions.incrementalApi = | 389 defaultContextOptions.incrementalApi = |
| 379 options.enableIncrementalResolutionApi; | 390 options.enableIncrementalResolutionApi; |
| 380 defaultContextOptions.incrementalValidation = | 391 defaultContextOptions.incrementalValidation = |
| 381 options.enableIncrementalResolutionValidation; | 392 options.enableIncrementalResolutionValidation; |
| 382 defaultContextOptions.finerGrainedInvalidation = | 393 defaultContextOptions.finerGrainedInvalidation = |
| 383 options.finerGrainedInvalidation; | 394 options.finerGrainedInvalidation; |
| 384 defaultContextOptions.generateImplicitErrors = false; | 395 defaultContextOptions.generateImplicitErrors = false; |
| 385 operationQueue = new ServerOperationQueue(); | 396 operationQueue = new ServerOperationQueue(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 options.enableNewAnalysisDriver); | 429 options.enableNewAnalysisDriver); |
| 419 } | 430 } |
| 420 this.fileResolverProvider = fileResolverProvider; | 431 this.fileResolverProvider = fileResolverProvider; |
| 421 this.packageResolverProvider = packageResolverProvider; | 432 this.packageResolverProvider = packageResolverProvider; |
| 422 ServerContextManagerCallbacks contextManagerCallbacks = | 433 ServerContextManagerCallbacks contextManagerCallbacks = |
| 423 new ServerContextManagerCallbacks(this, resourceProvider); | 434 new ServerContextManagerCallbacks(this, resourceProvider); |
| 424 contextManager.callbacks = contextManagerCallbacks; | 435 contextManager.callbacks = contextManagerCallbacks; |
| 425 AnalysisEngine.instance.logger = new AnalysisLogger(this); | 436 AnalysisEngine.instance.logger = new AnalysisLogger(this); |
| 426 _onAnalysisStartedController = new StreamController.broadcast(); | 437 _onAnalysisStartedController = new StreamController.broadcast(); |
| 427 _onFileAnalyzedController = new StreamController.broadcast(); | 438 _onFileAnalyzedController = new StreamController.broadcast(); |
| 439 // temporary plugin support: |
| 440 _onFileAddedController = new StreamController.broadcast(); |
| 441 // temporary plugin support: |
| 442 _onFileChangedController = new StreamController.broadcast(); |
| 428 _onPriorityChangeController = | 443 _onPriorityChangeController = |
| 429 new StreamController<PriorityChangeEvent>.broadcast(); | 444 new StreamController<PriorityChangeEvent>.broadcast(); |
| 430 running = true; | 445 running = true; |
| 431 onAnalysisStarted.first.then((_) { | 446 onAnalysisStarted.first.then((_) { |
| 432 onAnalysisComplete.then((_) { | 447 onAnalysisComplete.then((_) { |
| 433 performanceAfterStartup = new ServerPerformance(); | 448 performanceAfterStartup = new ServerPerformance(); |
| 434 _performance = performanceAfterStartup; | 449 _performance = performanceAfterStartup; |
| 435 }); | 450 }); |
| 436 }); | 451 }); |
| 437 _setupIndexInvalidation(); | 452 _setupIndexInvalidation(); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 512 */ | 527 */ |
| 513 Stream<ContextsChangedEvent> get onContextsChanged => | 528 Stream<ContextsChangedEvent> get onContextsChanged => |
| 514 _onContextsChangedController.stream; | 529 _onContextsChangedController.stream; |
| 515 | 530 |
| 516 /** | 531 /** |
| 517 * The stream that is notified when a single file has been analyzed. | 532 * The stream that is notified when a single file has been analyzed. |
| 518 */ | 533 */ |
| 519 Stream get onFileAnalyzed => _onFileAnalyzedController.stream; | 534 Stream get onFileAnalyzed => _onFileAnalyzedController.stream; |
| 520 | 535 |
| 521 /** | 536 /** |
| 537 * The stream that is notified when a single file has been added. This exists |
| 538 * as a temporary stopgap for plugins, until the official plugin API is |
| 539 * complete. |
| 540 */ |
| 541 Stream get onFileAdded => _onFileAddedController.stream; |
| 542 |
| 543 /** |
| 544 * The stream that is notified when a single file has been changed. This |
| 545 * exists as a temporary stopgap for plugins, until the official plugin API is |
| 546 * complete. |
| 547 */ |
| 548 Stream get onFileChanged => _onFileChangedController.stream; |
| 549 |
| 550 /** |
| 522 * The stream that is notified when priority sources change. | 551 * The stream that is notified when priority sources change. |
| 523 */ | 552 */ |
| 524 Stream<PriorityChangeEvent> get onPriorityChange => | 553 Stream<PriorityChangeEvent> get onPriorityChange => |
| 525 _onPriorityChangeController.stream; | 554 _onPriorityChangeController.stream; |
| 526 | 555 |
| 527 /** | 556 /** |
| 528 * The [Future] that completes when the next operation is performed. | 557 * The [Future] that completes when the next operation is performed. |
| 529 */ | 558 */ |
| 530 Future get test_onOperationPerformed { | 559 Future get test_onOperationPerformed { |
| 531 if (_test_onOperationPerformedCompleter == null) { | 560 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. | 1541 // Protocol parsing should have ensured that we never get here. |
| 1513 throw new AnalysisException('Illegal change type'); | 1542 throw new AnalysisException('Illegal change type'); |
| 1514 } | 1543 } |
| 1515 | 1544 |
| 1516 fileContentOverlay[file] = newContents; | 1545 fileContentOverlay[file] = newContents; |
| 1517 | 1546 |
| 1518 driverMap.values.forEach((driver) { | 1547 driverMap.values.forEach((driver) { |
| 1519 driver.changeFile(file); | 1548 driver.changeFile(file); |
| 1520 }); | 1549 }); |
| 1521 | 1550 |
| 1551 // temporary plugin support: |
| 1552 _onFileChangedController.add(file); |
| 1553 |
| 1522 // If the file did not exist, and is "overlay only", it still should be | 1554 // 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. | 1555 // analyzed. Add it to driver to which it should have been added. |
| 1524 contextManager.getDriverFor(file)?.addFile(file); | 1556 contextManager.getDriverFor(file)?.addFile(file); |
| 1525 | 1557 |
| 1526 // TODO(scheglov) implement other cases | 1558 // TODO(scheglov) implement other cases |
| 1527 }); | 1559 }); |
| 1528 return; | 1560 return; |
| 1529 } | 1561 } |
| 1530 changes.forEach((file, change) { | 1562 changes.forEach((file, change) { |
| 1531 ContextSourcePair contextSource = getContextSourcePair(file); | 1563 ContextSourcePair contextSource = getContextSourcePair(file); |
| (...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1981 } | 2013 } |
| 1982 | 2014 |
| 1983 @override | 2015 @override |
| 1984 void applyChangesToContext(Folder contextFolder, ChangeSet changeSet) { | 2016 void applyChangesToContext(Folder contextFolder, ChangeSet changeSet) { |
| 1985 if (analysisServer.options.enableNewAnalysisDriver) { | 2017 if (analysisServer.options.enableNewAnalysisDriver) { |
| 1986 nd.AnalysisDriver analysisDriver = | 2018 nd.AnalysisDriver analysisDriver = |
| 1987 analysisServer.driverMap[contextFolder]; | 2019 analysisServer.driverMap[contextFolder]; |
| 1988 if (analysisDriver != null) { | 2020 if (analysisDriver != null) { |
| 1989 changeSet.addedSources.forEach((source) { | 2021 changeSet.addedSources.forEach((source) { |
| 1990 analysisDriver.addFile(source.fullName); | 2022 analysisDriver.addFile(source.fullName); |
| 2023 // temporary plugin support: |
| 2024 analysisServer._onFileAddedController.add(source.fullName); |
| 1991 }); | 2025 }); |
| 1992 changeSet.changedSources.forEach((source) { | 2026 changeSet.changedSources.forEach((source) { |
| 1993 analysisDriver.changeFile(source.fullName); | 2027 analysisDriver.changeFile(source.fullName); |
| 2028 // temporary plugin support: |
| 2029 analysisServer._onFileChangedController.add(source.fullName); |
| 1994 }); | 2030 }); |
| 1995 changeSet.removedSources.forEach((source) { | 2031 changeSet.removedSources.forEach((source) { |
| 1996 analysisDriver.removeFile(source.fullName); | 2032 analysisDriver.removeFile(source.fullName); |
| 1997 }); | 2033 }); |
| 1998 } | 2034 } |
| 1999 } else { | 2035 } else { |
| 2000 AnalysisContext context = analysisServer.folderMap[contextFolder]; | 2036 AnalysisContext context = analysisServer.folderMap[contextFolder]; |
| 2001 if (context != null) { | 2037 if (context != null) { |
| 2002 context.applyChanges(changeSet); | 2038 context.applyChanges(changeSet); |
| 2003 analysisServer.schedulePerformAnalysisOperation(context); | 2039 analysisServer.schedulePerformAnalysisOperation(context); |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2259 /** | 2295 /** |
| 2260 * The [PerformanceTag] for time spent in server request handlers. | 2296 * The [PerformanceTag] for time spent in server request handlers. |
| 2261 */ | 2297 */ |
| 2262 static PerformanceTag serverRequests = new PerformanceTag('serverRequests'); | 2298 static PerformanceTag serverRequests = new PerformanceTag('serverRequests'); |
| 2263 | 2299 |
| 2264 /** | 2300 /** |
| 2265 * The [PerformanceTag] for time spent in split store microtasks. | 2301 * The [PerformanceTag] for time spent in split store microtasks. |
| 2266 */ | 2302 */ |
| 2267 static PerformanceTag splitStore = new PerformanceTag('splitStore'); | 2303 static PerformanceTag splitStore = new PerformanceTag('splitStore'); |
| 2268 } | 2304 } |
| OLD | NEW |