mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 19:40:29 +00:00
Remove DartSdk.getLinkedBundle().
R=brianwilkerson@google.com Change-Id: I2335ad03856b73e6d864d939a90839ef85dcab78 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149487 Commit-Queue: Konstantin Shcheglov <scheglov@google.com> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
parent
d0a6192554
commit
439e99483f
|
@ -50,9 +50,6 @@ class EmbedderSdk extends AbstractDartSdk {
|
|||
/// The url mappings for this SDK.
|
||||
Map<String, String> get urlMappings => _urlMappings;
|
||||
|
||||
@override
|
||||
PackageBundle getLinkedBundle() => null;
|
||||
|
||||
@override
|
||||
String getRelativePathFromFile(JavaFile file) => file.getAbsolutePath();
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@ import 'package:analyzer/src/generated/engine.dart';
|
|||
import 'package:analyzer/src/generated/java_engine_io.dart';
|
||||
import 'package:analyzer/src/generated/sdk.dart';
|
||||
import 'package:analyzer/src/generated/source_io.dart';
|
||||
import 'package:analyzer/src/summary/idl.dart' show PackageBundle;
|
||||
import 'package:path/path.dart' as pathos;
|
||||
import 'package:yaml/yaml.dart';
|
||||
|
||||
|
@ -56,8 +55,6 @@ abstract class AbstractDartSdk implements DartSdk {
|
|||
*/
|
||||
final Map<String, Source> _uriToSourceMap = HashMap<String, Source>();
|
||||
|
||||
PackageBundle _sdkBundle;
|
||||
|
||||
/**
|
||||
* Return the analysis options for this SDK analysis context.
|
||||
*/
|
||||
|
@ -152,27 +149,11 @@ abstract class AbstractDartSdk implements DartSdk {
|
|||
return null;
|
||||
}
|
||||
|
||||
@override
|
||||
PackageBundle getLinkedBundle() {
|
||||
if (_useSummary) {
|
||||
_sdkBundle ??= getSummarySdkBundle();
|
||||
return _sdkBundle;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
String getRelativePathFromFile(File file);
|
||||
|
||||
@override
|
||||
SdkLibrary getSdkLibrary(String dartUri) => libraryMap.getLibrary(dartUri);
|
||||
|
||||
/**
|
||||
* Return the [PackageBundle] for this SDK, if it exists, or `null` otherwise.
|
||||
* This method should not be used outside of `analyzer` and `analyzer_cli`
|
||||
* packages.
|
||||
*/
|
||||
PackageBundle getSummarySdkBundle();
|
||||
|
||||
Source internalMapDartUri(String dartUri) {
|
||||
// TODO(brianwilkerson) Figure out how to unify the implementations in the
|
||||
// two subclasses.
|
||||
|
@ -266,15 +247,10 @@ class EmbedderSdk extends AbstractDartSdk {
|
|||
static const String _EMBEDDED_LIB_MAP_KEY = 'embedded_libs';
|
||||
final Map<String, String> _urlMappings = HashMap<String, String>();
|
||||
|
||||
Folder _embedderYamlLibFolder;
|
||||
|
||||
EmbedderSdk(
|
||||
ResourceProvider resourceProvider, Map<Folder, YamlMap> embedderYamls) {
|
||||
this.resourceProvider = resourceProvider;
|
||||
embedderYamls?.forEach(_processEmbedderYaml);
|
||||
if (embedderYamls?.length == 1) {
|
||||
_embedderYamlLibFolder = embedderYamls.keys.first;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -294,25 +270,6 @@ class EmbedderSdk extends AbstractDartSdk {
|
|||
@override
|
||||
String getRelativePathFromFile(File file) => file.path;
|
||||
|
||||
@override
|
||||
PackageBundle getSummarySdkBundle() {
|
||||
String name = 'strong.sum';
|
||||
File file = _embedderYamlLibFolder.parent.getChildAssumingFile(name);
|
||||
try {
|
||||
if (file.exists) {
|
||||
List<int> bytes = file.readAsBytesSync();
|
||||
return PackageBundle.fromBuffer(bytes);
|
||||
}
|
||||
} catch (exception, stackTrace) {
|
||||
AnalysisEngine.instance.instrumentationService.logException(
|
||||
CaughtException.withMessage(
|
||||
'Failed to load SDK analysis summary from $file',
|
||||
exception,
|
||||
stackTrace));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@override
|
||||
Source internalMapDartUri(String dartUri) {
|
||||
String libraryName;
|
||||
|
@ -568,33 +525,6 @@ class FolderBasedDartSdk extends AbstractDartSdk {
|
|||
return filePath.substring(libPath.length + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the [PackageBundle] for this SDK, if it exists, or `null` otherwise.
|
||||
* This method should not be used outside of `analyzer` and `analyzer_cli`
|
||||
* packages.
|
||||
*/
|
||||
@override
|
||||
PackageBundle getSummarySdkBundle() {
|
||||
String rootPath = directory.path;
|
||||
String name = 'strong.sum';
|
||||
String path =
|
||||
resourceProvider.pathContext.join(rootPath, 'lib', '_internal', name);
|
||||
try {
|
||||
File file = resourceProvider.getFile(path);
|
||||
if (file.exists) {
|
||||
List<int> bytes = file.readAsBytesSync();
|
||||
return PackageBundle.fromBuffer(bytes);
|
||||
}
|
||||
} catch (exception, stackTrace) {
|
||||
AnalysisEngine.instance.instrumentationService.logException(
|
||||
CaughtException.withMessage(
|
||||
'Failed to load SDK analysis summary from $path',
|
||||
exception,
|
||||
stackTrace));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read all of the configuration files to initialize the library maps.
|
||||
* Return the initialized library map.
|
||||
|
|
|
@ -10,7 +10,6 @@ import 'package:analyzer/src/generated/engine.dart'
|
|||
show AnalysisContext, AnalysisOptions;
|
||||
import 'package:analyzer/src/generated/source.dart' show Source;
|
||||
import 'package:analyzer/src/generated/utilities_general.dart';
|
||||
import 'package:analyzer/src/summary/idl.dart' show PackageBundle;
|
||||
|
||||
/**
|
||||
* A Dart SDK installed in a specified location.
|
||||
|
@ -74,14 +73,6 @@ abstract class DartSdk {
|
|||
*/
|
||||
Source fromFileUri(Uri uri);
|
||||
|
||||
/**
|
||||
* Return the linked [PackageBundle] for this SDK, if it can be provided, or
|
||||
* `null` otherwise.
|
||||
*
|
||||
* This is a temporary API, don't use it.
|
||||
*/
|
||||
PackageBundle getLinkedBundle();
|
||||
|
||||
/**
|
||||
* Return the library representing the library with the given 'dart:' [uri],
|
||||
* or `null` if the given URI does not denote a library in this SDK.
|
||||
|
|
|
@ -85,9 +85,6 @@ class SummaryBasedDartSdk implements DartSdk {
|
|||
return null;
|
||||
}
|
||||
|
||||
@override
|
||||
PackageBundle getLinkedBundle() => _bundle;
|
||||
|
||||
@override
|
||||
SdkLibrary getSdkLibrary(String uri) {
|
||||
// This is not quite correct, but currently it's used only in
|
||||
|
|
|
@ -8,8 +8,6 @@ import 'package:analyzer/src/context/context.dart';
|
|||
import 'package:analyzer/src/generated/engine.dart';
|
||||
import 'package:analyzer/src/generated/sdk.dart';
|
||||
import 'package:analyzer/src/generated/source.dart';
|
||||
import 'package:analyzer/src/summary/idl.dart' show PackageBundle;
|
||||
import 'package:analyzer/src/summary/summary_file_builder.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
const String sdkRoot = '/sdk';
|
||||
|
@ -1083,9 +1081,6 @@ class MockSdk implements DartSdk {
|
|||
@override
|
||||
final List<SdkLibrary> sdkLibraries = [];
|
||||
|
||||
/// The cached linked bundle of the SDK.
|
||||
PackageBundle _bundle;
|
||||
|
||||
/// Optional [additionalLibraries] should have unique URIs, and paths in
|
||||
/// their units are relative (will be put into `sdkRoot/lib`).
|
||||
MockSdk({
|
||||
|
@ -1223,22 +1218,6 @@ class MockSdk implements DartSdk {
|
|||
return null;
|
||||
}
|
||||
|
||||
@override
|
||||
PackageBundle getLinkedBundle() {
|
||||
if (_bundle == null) {
|
||||
File summaryFile = resourceProvider
|
||||
.getFile(resourceProvider.convertPath('/lib/_internal/strong.sum'));
|
||||
List<int> bytes;
|
||||
if (summaryFile.exists) {
|
||||
bytes = summaryFile.readAsBytesSync();
|
||||
} else {
|
||||
bytes = _computeLinkedBundleBytes();
|
||||
}
|
||||
_bundle = PackageBundle.fromBuffer(bytes);
|
||||
}
|
||||
return _bundle;
|
||||
}
|
||||
|
||||
@override
|
||||
SdkLibrary getSdkLibrary(String dartUri) {
|
||||
for (SdkLibrary library in _LIBRARIES) {
|
||||
|
@ -1261,14 +1240,6 @@ class MockSdk implements DartSdk {
|
|||
// table above.
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Compute the bytes of the linked bundle associated with this SDK.
|
||||
List<int> _computeLinkedBundleBytes() {
|
||||
return buildSdkSummary(
|
||||
resourceProvider: resourceProvider,
|
||||
sdkPath: sdkRoot,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MockSdkLibrary implements SdkLibrary {
|
||||
|
|
|
@ -9,7 +9,6 @@ import 'package:analyzer/src/generated/engine.dart';
|
|||
import 'package:analyzer/src/generated/java_engine_io.dart';
|
||||
import 'package:analyzer/src/generated/sdk.dart';
|
||||
import 'package:analyzer/src/generated/source.dart';
|
||||
import 'package:analyzer/src/summary/summarize_elements.dart';
|
||||
import 'package:analyzer/src/test_utilities/resource_provider_mixin.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
@ -55,26 +54,6 @@ class EmbedderSdkTest extends EmbedderRelatedTest {
|
|||
expectSource('$foxLib/deep/directory/part.dart', 'dart:deep/part.dart');
|
||||
}
|
||||
|
||||
void test_getLinkedBundle_noBundle() {
|
||||
EmbedderYamlLocator locator = EmbedderYamlLocator({
|
||||
'fox': <Folder>[pathTranslator.getResource(foxLib)]
|
||||
});
|
||||
EmbedderSdk sdk = EmbedderSdk(resourceProvider, locator.embedderYamls);
|
||||
expect(sdk.getLinkedBundle(), isNull);
|
||||
}
|
||||
|
||||
void test_getLinkedBundle_strong() {
|
||||
pathTranslator.newFileWithBytes(
|
||||
'$foxPath/strong.sum', PackageBundleAssembler().assemble().toBuffer());
|
||||
EmbedderYamlLocator locator = EmbedderYamlLocator({
|
||||
'fox': <Folder>[pathTranslator.getResource(foxLib)]
|
||||
});
|
||||
EmbedderSdk sdk = EmbedderSdk(resourceProvider, locator.embedderYamls);
|
||||
sdk.analysisOptions = AnalysisOptionsImpl();
|
||||
sdk.useSummary = true;
|
||||
expect(sdk.getLinkedBundle(), isNotNull);
|
||||
}
|
||||
|
||||
void test_getSdkLibrary() {
|
||||
EmbedderYamlLocator locator = EmbedderYamlLocator({
|
||||
'fox': <Folder>[pathTranslator.getResource(foxLib)]
|
||||
|
|
|
@ -554,11 +554,6 @@ class Driver with HasContextMixin implements CommandLineStarter {
|
|||
// Once options and embedders are processed, setup the SDK.
|
||||
_setupSdk(options, useSummaries, analysisOptions);
|
||||
|
||||
var sdkBundle = sdk.getLinkedBundle();
|
||||
if (sdkBundle != null) {
|
||||
summaryDataStore.addBundle(null, sdkBundle);
|
||||
}
|
||||
|
||||
// Choose a package resolution policy and a diet parsing policy based on
|
||||
// the command-line options.
|
||||
var sourceFactory = _chooseUriResolutionPolicy(options, embedderMap,
|
||||
|
|
Loading…
Reference in a new issue