Remove DartSdk.useSummary.

Initial:  https://dart-review.googlesource.com/c/sdk/+/149495
Reverted: https://dart-review.googlesource.com/c/sdk/+/149687
Change-Id: Ibd3f1af1aef83adc35f77cfbda66e07c5ae99922
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153241
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
Konstantin Shcheglov 2020-07-03 15:56:41 +00:00 committed by commit-bot@chromium.org
parent 9cfdc02e58
commit 326f7b4a8f
28 changed files with 41 additions and 140 deletions

View file

@ -437,12 +437,12 @@ class Driver implements ServerStarter {
}
final defaultSdkPath = _getSdkPath(results);
final dartSdkManager = DartSdkManager(defaultSdkPath, true);
final dartSdkManager = DartSdkManager(defaultSdkPath);
// TODO(brianwilkerson) It would be nice to avoid creating an SDK that
// cannot be re-used, but the SDK is needed to create a package map provider
// in the case where we need to run `pub` in order to get the package map.
var defaultSdk = _createDefaultSdk(defaultSdkPath, true);
var defaultSdk = _createDefaultSdk(defaultSdkPath);
//
// Initialize the instrumentation service.
//
@ -825,12 +825,12 @@ class Driver implements ServerStarter {
return parser;
}
DartSdk _createDefaultSdk(String defaultSdkPath, bool useSummaries) {
DartSdk _createDefaultSdk(String defaultSdkPath) {
var resourceProvider = PhysicalResourceProvider.INSTANCE;
var sdk = FolderBasedDartSdk(
resourceProvider, resourceProvider.getFolder(defaultSdkPath));
sdk.useSummary = useSummaries;
return sdk;
return FolderBasedDartSdk(
resourceProvider,
resourceProvider.getFolder(defaultSdkPath),
);
}
/// Constructs a uuid combining the current date and a random integer.

View file

@ -516,10 +516,6 @@ class ContextsPage extends DiagnosticPageWithNav {
if (sdkOptions != null) {
h3('SDK analysis options');
p(describe(sdkOptions), raw: true);
if (sdk is FolderBasedDartSdk) {
p(writeOption('Use summaries', sdk.useSummary), raw: true);
}
}
buf.writeln('</div>');

View file

@ -121,7 +121,7 @@ class AbstractAnalysisTest with ResourceProviderMixin {
serverChannel,
resourceProvider,
options,
DartSdkManager(resourceProvider.convertPath('/sdk'), true),
DartSdkManager(resourceProvider.convertPath('/sdk')),
CrashReportingAttachmentsBuilder.empty,
InstrumentationService.NULL_SERVICE);
}

View file

@ -84,7 +84,7 @@ class AnalysisServerTest with ResourceProviderMixin {
channel,
resourceProvider,
AnalysisServerOptions(),
DartSdkManager(convertPath('/sdk'), false),
DartSdkManager(convertPath('/sdk')),
CrashReportingAttachmentsBuilder.empty,
InstrumentationService.NULL_SERVICE);
}

View file

@ -111,7 +111,7 @@ abstract class AbstractClient {
serverChannel,
resourceProvider,
serverOptions,
DartSdkManager(sdkPath, true),
DartSdkManager(sdkPath),
CrashReportingAttachmentsBuilder.empty,
InstrumentationService.NULL_SERVICE);
}

View file

@ -1591,7 +1591,7 @@ abstract class ContextManagerTest with ResourceProviderMixin {
resourceProvider.newFolder(projPath);
// Create an SDK in the mock file system.
MockSdk(resourceProvider: resourceProvider);
var sdkManager = DartSdkManager(convertPath('/sdk'), true);
var sdkManager = DartSdkManager(convertPath('/sdk'));
manager = ContextManagerImpl(
resourceProvider,
sdkManager,
@ -2290,7 +2290,7 @@ class TestContextManagerCallbacks extends ContextManagerCallbacks {
expect(contextRoot.root, path);
currentContextTimestamps[path] = now;
var builder = createContextBuilder(folder, options, useSummaries: true);
var builder = createContextBuilder(folder, options);
builder.analysisDriverScheduler = scheduler;
builder.byteStore = MemoryByteStore();
builder.performanceLog = logger;
@ -2347,8 +2347,7 @@ class TestContextManagerCallbacks extends ContextManagerCallbacks {
}
@override
ContextBuilder createContextBuilder(Folder folder, AnalysisOptions options,
{bool useSummaries = false}) {
ContextBuilder createContextBuilder(Folder folder, AnalysisOptions options) {
var builderOptions = ContextBuilderOptions();
builderOptions.defaultOptions = options;
var builder = ContextBuilder(resourceProvider, sdkManager, null,

View file

@ -363,7 +363,7 @@ class AnalysisTestHelper with ResourceProviderMixin {
serverChannel,
resourceProvider,
AnalysisServerOptions(),
DartSdkManager(convertPath('/sdk'), false),
DartSdkManager(convertPath('/sdk')),
CrashReportingAttachmentsBuilder.empty,
InstrumentationService.NULL_SERVICE);
handler = AnalysisDomainHandler(server);

View file

@ -31,7 +31,7 @@ void main() {
MockServerChannel(),
provider,
AnalysisServerOptions(),
DartSdkManager('', false),
DartSdkManager(''),
CrashReportingAttachmentsBuilder.empty,
InstrumentationService.NULL_SERVICE);
handler = ExecutionDomainHandler(server);

View file

@ -29,7 +29,7 @@ void main() {
serverChannel,
resourceProvider,
AnalysisServerOptions(),
DartSdkManager('', false),
DartSdkManager(''),
CrashReportingAttachmentsBuilder.empty,
InstrumentationService.NULL_SERVICE);
handler = ServerDomainHandler(server);

View file

@ -118,7 +118,7 @@ abstract class AbstractLspAnalysisServerTest
channel,
resourceProvider,
AnalysisServerOptions(),
DartSdkManager(convertPath('/sdk'), false),
DartSdkManager(convertPath('/sdk')),
CrashReportingAttachmentsBuilder.empty,
InstrumentationService.NULL_SERVICE);
server.pluginManager = pluginManager;

View file

@ -105,7 +105,7 @@ class SocketServerTest {
final errorNotifier = ErrorNotifier();
final server = SocketServer(
AnalysisServerOptions(),
DartSdkManager('', false),
DartSdkManager(''),
CrashReportingAttachmentsBuilder.empty,
errorNotifier,
null,

View file

@ -77,7 +77,7 @@ class MigrationBase {
serverChannel,
resourceProvider,
options,
DartSdkManager(sdkPath, true),
DartSdkManager(sdkPath),
CrashReportingAttachmentsBuilder.empty,
InstrumentationService.NULL_SERVICE);
}

View file

@ -1,3 +1,7 @@
## 0.39.12-dev
* Deprecated `canUseSummaries` in `DartSdkManager` constructor.
Summaries are not supported this way for SDK.
## 0.39.11
* Deprecated `ClassElement.hasReferenceToSuper`.
It was used internally, should not be part of API.

View file

@ -10,7 +10,6 @@ import 'package:analyzer/src/dart/sdk/sdk.dart';
import 'package:analyzer/src/generated/engine.dart';
import 'package:analyzer/src/generated/sdk.dart';
import 'package:args/args.dart';
import 'package:path/path.dart';
const String analysisOptionsFileOption = 'options';
const String defineVariableOption = 'D';
@ -103,18 +102,12 @@ ContextBuilderOptions createContextBuilderOptions(ArgResults args) {
/// SDK manager. The manager will use summary information if [useSummaries] is
/// `true` and if the summary information exists.
DartSdkManager createDartSdkManager(
ResourceProvider resourceProvider, bool useSummaries, ArgResults args) {
ResourceProvider resourceProvider, ArgResults args) {
String sdkPath = args[sdkPathOption];
bool canUseSummaries = useSummaries &&
args.rest.every((String sourcePath) {
sourcePath = context.absolute(sourcePath);
sourcePath = context.normalize(sourcePath);
return !context.isWithin(sdkPath, sourcePath);
});
return DartSdkManager(
sdkPath ?? FolderBasedDartSdk.defaultSdkDirectory(resourceProvider)?.path,
canUseSummaries);
sdkPath ?? FolderBasedDartSdk.defaultSdkDirectory(resourceProvider)?.path,
);
}
/// Add the standard flags and options to the given [parser]. The standard flags

View file

@ -249,7 +249,6 @@ class ContextBuilder {
resourceProvider.getFolder(sdkPath),
);
sdk.analysisOptions = analysisOptions;
sdk.useSummary = sdkManager.canUseSummaries;
return sdk;
});
}

View file

@ -60,7 +60,7 @@ class ContextBuilderImpl implements ContextBuilder {
if (sdkPath == null) {
throw ArgumentError('Cannot find path to the SDK');
}
DartSdkManager sdkManager = DartSdkManager(sdkPath, true);
DartSdkManager sdkManager = DartSdkManager(sdkPath);
if (scheduler == null) {
scheduler = AnalysisDriverScheduler(performanceLog);

View file

@ -72,8 +72,7 @@ class ContextLocatorImpl implements ContextLocator {
}
PerformanceLog performanceLog = PerformanceLog(StringBuffer());
AnalysisDriverScheduler scheduler = AnalysisDriverScheduler(performanceLog);
DartSdkManager sdkManager =
DartSdkManager(sdkPath ?? _defaultSdkPath, true);
DartSdkManager sdkManager = DartSdkManager(sdkPath ?? _defaultSdkPath);
scheduler.start();
ContextBuilderOptions options = ContextBuilderOptions();
ContextBuilder builder =

View file

@ -31,10 +31,6 @@ abstract class AbstractDartSdk implements DartSdk {
/// The [AnalysisOptions] to use to create the [context].
AnalysisOptions _analysisOptions;
/// The flag that specifies whether an SDK summary should be used. This is a
/// temporary flag until summaries are enabled by default.
bool _useSummary = false;
/// The [AnalysisContext] which is used for all of the sources in this SDK.
SdkAnalysisContext _analysisContext;
@ -72,18 +68,6 @@ abstract class AbstractDartSdk implements DartSdk {
@override
List<String> get uris => libraryMap.uris;
/// Return `true` if the SDK summary will be used when available.
bool get useSummary => _useSummary;
/// Specify whether SDK summary should be used.
set useSummary(bool use) {
if (_analysisContext != null) {
throw StateError(
'The "useSummary" flag cannot be changed after context creation.');
}
_useSummary = use;
}
/// Add the extensions from one or more sdk extension files to this sdk. The
/// [extensions] should be a table mapping the names of extensions to the
/// paths where those extensions can be found.

View file

@ -65,16 +65,12 @@ class DartSdkManager {
/// The absolute path to the directory containing the default SDK.
final String defaultSdkDirectory;
/// A flag indicating whether it is acceptable to use summaries when they are
/// available.
final bool canUseSummaries;
/// A table mapping (an encoding of) analysis options and SDK locations to the
/// DartSdk from that location that has been configured with those options.
Map<SdkDescription, DartSdk> sdkMap = HashMap<SdkDescription, DartSdk>();
/// Initialize a newly created manager.
DartSdkManager(this.defaultSdkDirectory, this.canUseSummaries);
DartSdkManager(this.defaultSdkDirectory, [@deprecated bool canUseSummaries]);
/// Return any SDK that has been created, or `null` if no SDKs have been
/// created.

View file

@ -26,10 +26,6 @@ abstract class AbstractDartSdk implements DartSdk {
/// The [AnalysisOptions] to use to create the [context].
AnalysisOptions _analysisOptions;
/// The flag that specifies whether an SDK summary should be used. This is a
/// temporary flag until summaries are enabled by default.
bool _useSummary = false;
/// The [AnalysisContext] which is used for all of the sources in this SDK.
SdkAnalysisContext _analysisContext;
@ -61,18 +57,6 @@ abstract class AbstractDartSdk implements DartSdk {
@override
List<String> get uris => libraryMap.uris;
/// Return `true` if the SDK summary will be used when available.
bool get useSummary => _useSummary;
/// Specify whether SDK summary should be used.
set useSummary(bool use) {
if (_analysisContext != null) {
throw StateError(
'The "useSummary" flag cannot be changed after context creation.');
}
_useSummary = use;
}
/// Add the extensions from one or more sdk extension files to this sdk. The
/// [extensions] should be a table mapping the names of extensions to the
/// paths where those extensions can be found.

View file

@ -36,7 +36,6 @@ List<int> buildSdkSummary({
resourceProvider,
resourceProvider.getFolder(sdkPath),
);
sdk.useSummary = false;
sdk.analysisOptions = AnalysisOptionsImpl();
// Append libraries from the embedder.

View file

@ -1,5 +1,5 @@
name: analyzer
version: 0.39.11
version: 0.39.12-dev
description: This package provides a library that performs static analysis of Dart code.
homepage: https://github.com/dart-lang/sdk/tree/master/pkg/analyzer

View file

@ -18,7 +18,7 @@ main() {
@reflectiveTest
class DartSdkManagerTest with ResourceProviderMixin {
void test_anySdk() {
DartSdkManager manager = DartSdkManager('/a/b/c', false);
DartSdkManager manager = DartSdkManager('/a/b/c');
expect(manager.anySdk, isNull);
SdkDescription description = SdkDescription('/c/d');
@ -29,7 +29,7 @@ class DartSdkManagerTest with ResourceProviderMixin {
}
void test_getSdk_differentDescriptors() {
DartSdkManager manager = DartSdkManager('/a/b/c', false);
DartSdkManager manager = DartSdkManager('/a/b/c');
SdkDescription description1 = SdkDescription('/c/d');
DartSdk sdk1 = MockSdk(resourceProvider: resourceProvider);
@ -46,7 +46,7 @@ class DartSdkManagerTest with ResourceProviderMixin {
}
void test_getSdk_sameDescriptor() {
DartSdkManager manager = DartSdkManager('/a/b/c', false);
DartSdkManager manager = DartSdkManager('/a/b/c');
SdkDescription description = SdkDescription('/c/d');
DartSdk sdk = MockSdk(resourceProvider: resourceProvider);

View file

@ -71,55 +71,25 @@ class ArgumentsTest with ResourceProviderMixin {
expect(defaultOptions.implicitDynamic, true);
}
void test_createDartSdkManager_noPath_noSummaries() {
void test_createDartSdkManager_noPath() {
ArgParser parser = ArgParser();
defineAnalysisArguments(parser);
List<String> args = [];
ArgResults result = parse(resourceProvider, parser, args);
DartSdkManager manager =
createDartSdkManager(resourceProvider, false, result);
DartSdkManager manager = createDartSdkManager(resourceProvider, result);
expect(manager, isNotNull);
expect(manager.defaultSdkDirectory,
FolderBasedDartSdk.defaultSdkDirectory(resourceProvider)?.path);
expect(manager.canUseSummaries, false);
}
void test_createDartSdkManager_noPath_summaries() {
ArgParser parser = ArgParser();
defineAnalysisArguments(parser);
List<String> args = [];
ArgResults result = parse(resourceProvider, parser, args);
DartSdkManager manager =
createDartSdkManager(resourceProvider, true, result);
expect(manager, isNotNull);
expect(manager.defaultSdkDirectory,
FolderBasedDartSdk.defaultSdkDirectory(resourceProvider)?.path);
expect(manager.canUseSummaries, true);
}
void test_createDartSdkManager_path_noSummaries() {
void test_createDartSdkManager_path() {
ArgParser parser = ArgParser();
defineAnalysisArguments(parser);
List<String> args = ['--dart-sdk=x'];
ArgResults result = parse(resourceProvider, parser, args);
DartSdkManager manager =
createDartSdkManager(resourceProvider, false, result);
DartSdkManager manager = createDartSdkManager(resourceProvider, result);
expect(manager, isNotNull);
expect(manager.defaultSdkDirectory, 'x');
expect(manager.canUseSummaries, false);
}
void test_createDartSdkManager_path_summaries() {
ArgParser parser = ArgParser();
defineAnalysisArguments(parser);
List<String> args = ['--dart-sdk=y'];
ArgResults result = parse(resourceProvider, parser, args);
DartSdkManager manager =
createDartSdkManager(resourceProvider, true, result);
expect(manager, isNotNull);
expect(manager.defaultSdkDirectory, 'y');
expect(manager.canUseSummaries, true);
}
void test_defineAnalysisArguments() {

View file

@ -76,14 +76,14 @@ const Map<String, LibraryInfo> libraries = const {
"core": const LibraryInfo("core/core.dart"),
};
''');
sdkManager = DartSdkManager(defaultSdkPath, false);
sdkManager = DartSdkManager(defaultSdkPath);
builder = ContextBuilder(resourceProvider, sdkManager, contentCache,
options: builderOptions);
}
void setUp() {
MockSdk(resourceProvider: resourceProvider);
sdkManager = DartSdkManager(convertPath('/sdk'), false);
sdkManager = DartSdkManager(convertPath('/sdk'));
contentCache = ContentCache();
builder = ContextBuilder(
resourceProvider,

View file

@ -229,20 +229,6 @@ class FolderBasedDartSdkTest with ResourceProviderMixin {
expect(partSource, normalSource);
}
void test_useSummary_afterContextCreation() {
FolderBasedDartSdk sdk = _createDartSdk();
sdk.context;
expect(() {
sdk.useSummary = true;
}, throwsStateError);
}
void test_useSummary_beforeContextCreation() {
FolderBasedDartSdk sdk = _createDartSdk();
sdk.useSummary = true;
sdk.context;
}
FolderBasedDartSdk _createDartSdk() {
Folder sdkDirectory = getFolder('/sdk');
_createFile(sdkDirectory,

View file

@ -552,7 +552,7 @@ class Driver with HasContextMixin implements CommandLineStarter {
useSummaries ? options.buildSummaryInputs : <String>[]);
// Once options and embedders are processed, setup the SDK.
_setupSdk(options, useSummaries, analysisOptions);
_setupSdk(options, analysisOptions);
// Choose a package resolution policy and a diet parsing policy based on
// the command-line options.
@ -627,8 +627,7 @@ class Driver with HasContextMixin implements CommandLineStarter {
return analyzer.analyze(formatter);
}
void _setupSdk(CommandLineOptions options, bool useSummaries,
AnalysisOptions analysisOptions) {
void _setupSdk(CommandLineOptions options, AnalysisOptions analysisOptions) {
if (sdk == null) {
if (options.dartSdkSummaryPath != null) {
sdk = SummaryBasedDartSdk(options.dartSdkSummaryPath, true);
@ -636,12 +635,6 @@ class Driver with HasContextMixin implements CommandLineStarter {
var dartSdkPath = options.dartSdkPath;
var dartSdk = FolderBasedDartSdk(
resourceProvider, resourceProvider.getFolder(dartSdkPath));
dartSdk.useSummary = useSummaries &&
options.sourceFiles.every((String sourcePath) {
sourcePath = path.absolute(sourcePath);
sourcePath = path.normalize(sourcePath);
return !path.isWithin(dartSdkPath, sourcePath);
});
dartSdk.analysisOptions = analysisOptions;
sdk = dartSdk;
}

View file

@ -53,7 +53,6 @@ void main() {
var sdk = driver.sdk;
expect(sdk, const TypeMatcher<FolderBasedDartSdk>());
expect((sdk as FolderBasedDartSdk).useSummary, isFalse);
}));
});
}