| 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' hide Resource; | 9 import 'dart:core' hide Resource; |
| 10 import 'dart:io' as io; | 10 import 'dart:io' as io; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 import 'package:analyzer/src/generated/java_engine.dart'; | 36 import 'package:analyzer/src/generated/java_engine.dart'; |
| 37 import 'package:analyzer/src/generated/java_io.dart'; | 37 import 'package:analyzer/src/generated/java_io.dart'; |
| 38 import 'package:analyzer/src/generated/sdk.dart'; | 38 import 'package:analyzer/src/generated/sdk.dart'; |
| 39 import 'package:analyzer/src/generated/source.dart'; | 39 import 'package:analyzer/src/generated/source.dart'; |
| 40 import 'package:analyzer/src/generated/source_io.dart'; | 40 import 'package:analyzer/src/generated/source_io.dart'; |
| 41 import 'package:analyzer/src/generated/utilities_general.dart'; | 41 import 'package:analyzer/src/generated/utilities_general.dart'; |
| 42 import 'package:analyzer/src/task/dart.dart'; | 42 import 'package:analyzer/src/task/dart.dart'; |
| 43 import 'package:analyzer/src/util/glob.dart'; | 43 import 'package:analyzer/src/util/glob.dart'; |
| 44 import 'package:analyzer/task/dart.dart'; | 44 import 'package:analyzer/task/dart.dart'; |
| 45 import 'package:plugin/plugin.dart'; | 45 import 'package:plugin/plugin.dart'; |
| 46 import 'package:yaml/yaml.dart'; |
| 46 | 47 |
| 47 typedef void OptionUpdater(AnalysisOptionsImpl options); | 48 typedef void OptionUpdater(AnalysisOptionsImpl options); |
| 48 | 49 |
| 49 /** | 50 /** |
| 50 * Enum representing reasons why analysis might be done for a given file. | 51 * Enum representing reasons why analysis might be done for a given file. |
| 51 */ | 52 */ |
| 52 class AnalysisDoneReason { | 53 class AnalysisDoneReason { |
| 53 /** | 54 /** |
| 54 * Analysis of the file completed successfully. | 55 * Analysis of the file completed successfully. |
| 55 */ | 56 */ |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 */ | 145 */ |
| 145 bool statusAnalyzing = false; | 146 bool statusAnalyzing = false; |
| 146 | 147 |
| 147 /** | 148 /** |
| 148 * A list of the request handlers used to handle the requests sent to this | 149 * A list of the request handlers used to handle the requests sent to this |
| 149 * server. | 150 * server. |
| 150 */ | 151 */ |
| 151 List<RequestHandler> handlers; | 152 List<RequestHandler> handlers; |
| 152 | 153 |
| 153 /** | 154 /** |
| 154 * The function used to create a new SDK using the default SDK. | |
| 155 */ | |
| 156 final SdkCreator defaultSdkCreator; | |
| 157 | |
| 158 /** | |
| 159 * The object used to manage the SDK's known to this server. | 155 * The object used to manage the SDK's known to this server. |
| 160 */ | 156 */ |
| 161 DartSdkManager sdkManager; | 157 DartSdkManager sdkManager; |
| 162 | 158 |
| 163 /** | 159 /** |
| 164 * The instrumentation service that is to be used by this analysis server. | 160 * The instrumentation service that is to be used by this analysis server. |
| 165 */ | 161 */ |
| 166 final InstrumentationService instrumentationService; | 162 final InstrumentationService instrumentationService; |
| 167 | 163 |
| 168 /** | 164 /** |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 * exceptions to show up in unit tests, but it should be set to false when | 306 * exceptions to show up in unit tests, but it should be set to false when |
| 311 * running a full analysis server. | 307 * running a full analysis server. |
| 312 */ | 308 */ |
| 313 AnalysisServer( | 309 AnalysisServer( |
| 314 this.channel, | 310 this.channel, |
| 315 this.resourceProvider, | 311 this.resourceProvider, |
| 316 PubPackageMapProvider packageMapProvider, | 312 PubPackageMapProvider packageMapProvider, |
| 317 Index _index, | 313 Index _index, |
| 318 this.serverPlugin, | 314 this.serverPlugin, |
| 319 this.options, | 315 this.options, |
| 320 this.defaultSdkCreator, | 316 this.sdkManager, |
| 321 this.instrumentationService, | 317 this.instrumentationService, |
| 322 {ResolverProvider fileResolverProvider: null, | 318 {ResolverProvider fileResolverProvider: null, |
| 323 ResolverProvider packageResolverProvider: null, | 319 ResolverProvider packageResolverProvider: null, |
| 324 bool useSingleContextManager: false, | 320 bool useSingleContextManager: false, |
| 325 this.rethrowExceptions: true}) | 321 this.rethrowExceptions: true}) |
| 326 : index = _index, | 322 : index = _index, |
| 327 searchEngine = _index != null ? new SearchEngineImpl(_index) : null { | 323 searchEngine = _index != null ? new SearchEngineImpl(_index) : null { |
| 328 _performance = performanceDuringStartup; | 324 _performance = performanceDuringStartup; |
| 329 defaultContextOptions.incremental = true; | 325 defaultContextOptions.incremental = true; |
| 330 defaultContextOptions.incrementalApi = | 326 defaultContextOptions.incrementalApi = |
| 331 options.enableIncrementalResolutionApi; | 327 options.enableIncrementalResolutionApi; |
| 332 defaultContextOptions.incrementalValidation = | 328 defaultContextOptions.incrementalValidation = |
| 333 options.enableIncrementalResolutionValidation; | 329 options.enableIncrementalResolutionValidation; |
| 334 defaultContextOptions.finerGrainedInvalidation = | 330 defaultContextOptions.finerGrainedInvalidation = |
| 335 options.finerGrainedInvalidation; | 331 options.finerGrainedInvalidation; |
| 336 defaultContextOptions.generateImplicitErrors = false; | 332 defaultContextOptions.generateImplicitErrors = false; |
| 337 operationQueue = new ServerOperationQueue(); | 333 operationQueue = new ServerOperationQueue(); |
| 338 sdkManager = new DartSdkManager(defaultSdkCreator); | |
| 339 if (useSingleContextManager) { | 334 if (useSingleContextManager) { |
| 340 contextManager = new SingleContextManager(resourceProvider, sdkManager, | 335 contextManager = new SingleContextManager(resourceProvider, sdkManager, |
| 341 packageResolverProvider, analyzedFilesGlobs, defaultContextOptions); | 336 packageResolverProvider, analyzedFilesGlobs, defaultContextOptions); |
| 342 } else { | 337 } else { |
| 343 contextManager = new ContextManagerImpl( | 338 contextManager = new ContextManagerImpl( |
| 344 resourceProvider, | 339 resourceProvider, |
| 345 sdkManager, | 340 sdkManager, |
| 346 packageResolverProvider, | 341 packageResolverProvider, |
| 347 packageMapProvider, | 342 packageMapProvider, |
| 348 analyzedFilesGlobs, | 343 analyzedFilesGlobs, |
| (...skipping 1283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1632 */ | 1627 */ |
| 1633 SourceFactory _createSourceFactory(InternalAnalysisContext context, | 1628 SourceFactory _createSourceFactory(InternalAnalysisContext context, |
| 1634 AnalysisOptions options, FolderDisposition disposition, Folder folder) { | 1629 AnalysisOptions options, FolderDisposition disposition, Folder folder) { |
| 1635 List<UriResolver> resolvers = []; | 1630 List<UriResolver> resolvers = []; |
| 1636 List<UriResolver> packageUriResolvers = | 1631 List<UriResolver> packageUriResolvers = |
| 1637 disposition.createPackageUriResolvers(resourceProvider); | 1632 disposition.createPackageUriResolvers(resourceProvider); |
| 1638 | 1633 |
| 1639 // If no embedded URI resolver was provided, defer to a locator-backed one. | 1634 // If no embedded URI resolver was provided, defer to a locator-backed one. |
| 1640 EmbedderYamlLocator locator = | 1635 EmbedderYamlLocator locator = |
| 1641 disposition.getEmbedderLocator(resourceProvider); | 1636 disposition.getEmbedderLocator(resourceProvider); |
| 1642 EmbedderSdk sdk = new EmbedderSdk(locator.embedderYamls); | 1637 Map<Folder, YamlMap> embedderYamls = locator.embedderYamls; |
| 1643 if (sdk.libraryMap.size() == 0) { | 1638 EmbedderSdk embedderSdk = new EmbedderSdk(embedderYamls); |
| 1644 // The embedder file has no mappings, so use the default Dart SDK. | 1639 if (embedderSdk.libraryMap.size() == 0) { |
| 1640 // There was no embedder file, or the file was empty, so used the default |
| 1641 // SDK. |
| 1645 resolvers.add(new DartUriResolver( | 1642 resolvers.add(new DartUriResolver( |
| 1646 analysisServer.sdkManager.getSdkForOptions(options))); | 1643 analysisServer.sdkManager.getSdkForOptions(options))); |
| 1647 } else { | 1644 } else { |
| 1648 // The embedder uri resolver has mappings, use it instead of the default | 1645 // The embedder file defines an alternate SDK, so use it. |
| 1649 // Dart SDK uri resolver. | 1646 List<String> paths = <String>[]; |
| 1650 resolvers.add(new DartUriResolver(sdk)); | 1647 for (Folder folder in embedderYamls.keys) { |
| 1648 paths.add(folder |
| 1649 .getChildAssumingFile(EmbedderYamlLocator.EMBEDDER_FILE_NAME) |
| 1650 .path); |
| 1651 } |
| 1652 DartSdk dartSdk = analysisServer.sdkManager |
| 1653 .getSdk(new SdkDescription(paths, options), () { |
| 1654 embedderSdk.analysisOptions = options; |
| 1655 // TODO(brianwilkerson) Enable summary use after we have decided where |
| 1656 // summary files for embedder files will live. |
| 1657 embedderSdk.useSummary = false; |
| 1658 return embedderSdk; |
| 1659 }); |
| 1660 resolvers.add(new DartUriResolver(dartSdk)); |
| 1651 } | 1661 } |
| 1652 | 1662 |
| 1653 resolvers.addAll(packageUriResolvers); | 1663 resolvers.addAll(packageUriResolvers); |
| 1654 if (context.fileResolverProvider == null) { | 1664 if (context.fileResolverProvider == null) { |
| 1655 resolvers.add(new ResourceUriResolver(resourceProvider)); | 1665 resolvers.add(new ResourceUriResolver(resourceProvider)); |
| 1656 } else { | 1666 } else { |
| 1657 resolvers.add(context.fileResolverProvider(folder)); | 1667 resolvers.add(context.fileResolverProvider(folder)); |
| 1658 } | 1668 } |
| 1659 return new SourceFactory(resolvers, disposition.packages); | 1669 return new SourceFactory(resolvers, disposition.packages); |
| 1660 } | 1670 } |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1754 /** | 1764 /** |
| 1755 * The [PerformanceTag] for time spent in server request handlers. | 1765 * The [PerformanceTag] for time spent in server request handlers. |
| 1756 */ | 1766 */ |
| 1757 static PerformanceTag serverRequests = new PerformanceTag('serverRequests'); | 1767 static PerformanceTag serverRequests = new PerformanceTag('serverRequests'); |
| 1758 | 1768 |
| 1759 /** | 1769 /** |
| 1760 * The [PerformanceTag] for time spent in split store microtasks. | 1770 * The [PerformanceTag] for time spent in split store microtasks. |
| 1761 */ | 1771 */ |
| 1762 static PerformanceTag splitStore = new PerformanceTag('splitStore'); | 1772 static PerformanceTag splitStore = new PerformanceTag('splitStore'); |
| 1763 } | 1773 } |
| OLD | NEW |