| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 import 'dart:collection' show HashSet, Queue; | 5 import 'dart:collection' show HashSet, Queue; |
| 6 import 'dart:convert' show BASE64, JSON, UTF8; | 6 import 'dart:convert' show BASE64, JSON, UTF8; |
| 7 import 'dart:io' show File; | 7 import 'dart:io' show File; |
| 8 | 8 |
| 9 import 'package:analyzer/analyzer.dart' | 9 import 'package:analyzer/analyzer.dart' |
| 10 show AnalysisError, CompilationUnit, ErrorSeverity; | 10 show AnalysisError, CompilationUnit, ErrorSeverity; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 final SummaryDataStore summaryData; | 61 final SummaryDataStore summaryData; |
| 62 final ExtensionTypeSet _extensionTypes; | 62 final ExtensionTypeSet _extensionTypes; |
| 63 | 63 |
| 64 ModuleCompiler._(AnalysisContext context, this.summaryData) | 64 ModuleCompiler._(AnalysisContext context, this.summaryData) |
| 65 : context = context, | 65 : context = context, |
| 66 _extensionTypes = new ExtensionTypeSet(context); | 66 _extensionTypes = new ExtensionTypeSet(context); |
| 67 | 67 |
| 68 factory ModuleCompiler(AnalyzerOptions options, | 68 factory ModuleCompiler(AnalyzerOptions options, |
| 69 {ResourceProvider resourceProvider, | 69 {ResourceProvider resourceProvider, |
| 70 String analysisRoot, | 70 String analysisRoot, |
| 71 List<UriResolver> fileResolvers}) { | 71 List<UriResolver> fileResolvers, |
| 72 SummaryDataStore summaryData}) { |
| 72 // TODO(danrubel): refactor with analyzer CLI into analyzer common code | 73 // TODO(danrubel): refactor with analyzer CLI into analyzer common code |
| 73 AnalysisEngine.instance.processRequiredPlugins(); | 74 AnalysisEngine.instance.processRequiredPlugins(); |
| 74 | 75 |
| 75 resourceProvider ??= PhysicalResourceProvider.INSTANCE; | 76 resourceProvider ??= PhysicalResourceProvider.INSTANCE; |
| 76 analysisRoot ??= path.current; | 77 analysisRoot ??= path.current; |
| 77 | 78 |
| 78 var contextBuilder = new ContextBuilder(resourceProvider, | 79 var contextBuilder = new ContextBuilder(resourceProvider, |
| 79 new DartSdkManager(options.dartSdkPath, true), new ContentCache(), | 80 new DartSdkManager(options.dartSdkPath, true), new ContentCache(), |
| 80 options: options.contextBuilderOptions); | 81 options: options.contextBuilderOptions); |
| 81 | 82 |
| 82 var analysisOptions = contextBuilder.getAnalysisOptions(analysisRoot); | 83 var analysisOptions = contextBuilder.getAnalysisOptions(analysisRoot); |
| 83 var sdk = contextBuilder.findSdk(null, analysisOptions); | 84 var sdk = contextBuilder.findSdk(null, analysisOptions); |
| 84 | 85 |
| 85 var sdkResolver = new DartUriResolver(sdk); | 86 var sdkResolver = new DartUriResolver(sdk); |
| 86 | 87 |
| 87 // Read the summaries. | 88 // Read the summaries. |
| 88 var summaryData = | 89 summaryData ??= |
| 89 new SummaryDataStore(options.summaryPaths, recordDependencyInfo: true); | 90 new SummaryDataStore(options.summaryPaths, resourceProvider: resourcePro
vider, recordDependencyInfo: true); |
| 90 var sdkSummaryBundle = sdk.getLinkedBundle(); | 91 var sdkSummaryBundle = sdk.getLinkedBundle(); |
| 91 if (sdkSummaryBundle != null) { | 92 if (sdkSummaryBundle != null) { |
| 92 summaryData.addBundle(null, sdkSummaryBundle); | 93 summaryData.addBundle(null, sdkSummaryBundle); |
| 93 } | 94 } |
| 94 | 95 |
| 95 var srcFactory = createSourceFactory(options, | 96 var srcFactory = createSourceFactory(options, |
| 96 sdkResolver: sdkResolver, | 97 sdkResolver: sdkResolver, |
| 97 fileResolvers: fileResolvers, | 98 fileResolvers: fileResolvers, |
| 98 summaryData: summaryData, | 99 summaryData: summaryData, |
| 99 resourceProvider: resourceProvider); | 100 resourceProvider: resourceProvider); |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 577 // Fall back to a relative path. | 578 // Fall back to a relative path. |
| 578 return path.toUri(path.relative(path.fromUri(uri), from: dir)).toString(); | 579 return path.toUri(path.relative(path.fromUri(uri), from: dir)).toString(); |
| 579 } | 580 } |
| 580 | 581 |
| 581 for (int i = 0; i < list.length; i++) { | 582 for (int i = 0; i < list.length; i++) { |
| 582 list[i] = transformUri(list[i]); | 583 list[i] = transformUri(list[i]); |
| 583 } | 584 } |
| 584 map['file'] = transformUri(map['file']); | 585 map['file'] = transformUri(map['file']); |
| 585 return map; | 586 return map; |
| 586 } | 587 } |
| OLD | NEW |