mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 08:24:39 +00:00
Remove unused method and field from DartSdkManager
R=scheglov@google.com Review URL: https://codereview.chromium.org/2415413003 .
This commit is contained in:
parent
136e476c87
commit
3155b1e08c
|
@ -422,19 +422,10 @@ class Driver implements ServerStarter {
|
|||
.path;
|
||||
}
|
||||
bool useSummaries = analysisServerOptions.fileReadMode == 'as-is';
|
||||
SdkCreator defaultSdkCreator = (AnalysisOptions options) {
|
||||
PhysicalResourceProvider resourceProvider =
|
||||
PhysicalResourceProvider.INSTANCE;
|
||||
FolderBasedDartSdk sdk = new FolderBasedDartSdk(
|
||||
resourceProvider, resourceProvider.getFolder(defaultSdkPath));
|
||||
sdk.analysisOptions = options;
|
||||
sdk.useSummary = useSummaries;
|
||||
return sdk;
|
||||
};
|
||||
// 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.
|
||||
DartSdk defaultSdk = defaultSdkCreator(null);
|
||||
DartSdk defaultSdk = _createDefaultSdk(defaultSdkPath, useSummaries);
|
||||
//
|
||||
// Initialize the instrumentation service.
|
||||
//
|
||||
|
@ -458,7 +449,7 @@ class Driver implements ServerStarter {
|
|||
//
|
||||
socketServer = new SocketServer(
|
||||
analysisServerOptions,
|
||||
new DartSdkManager(defaultSdkPath, useSummaries, defaultSdkCreator),
|
||||
new DartSdkManager(defaultSdkPath, useSummaries),
|
||||
defaultSdk,
|
||||
service,
|
||||
serverPlugin,
|
||||
|
@ -586,6 +577,15 @@ class Driver implements ServerStarter {
|
|||
return parser;
|
||||
}
|
||||
|
||||
DartSdk _createDefaultSdk(String defaultSdkPath, bool useSummaries) {
|
||||
PhysicalResourceProvider resourceProvider =
|
||||
PhysicalResourceProvider.INSTANCE;
|
||||
FolderBasedDartSdk sdk = new FolderBasedDartSdk(
|
||||
resourceProvider, resourceProvider.getFolder(defaultSdkPath));
|
||||
sdk.useSummary = useSummaries;
|
||||
return sdk;
|
||||
}
|
||||
|
||||
/**
|
||||
* Print information about how to use the server.
|
||||
*/
|
||||
|
|
|
@ -124,9 +124,12 @@ class AbstractAnalysisTest {
|
|||
ExtensionManager manager = new ExtensionManager();
|
||||
manager.processPlugins(plugins);
|
||||
//
|
||||
// Create an SDK in the mock file system.
|
||||
//
|
||||
new MockSdk(resourceProvider: resourceProvider);
|
||||
//
|
||||
// Create server
|
||||
//
|
||||
MockSdk sdk = new MockSdk(resourceProvider: resourceProvider);
|
||||
return new AnalysisServer(
|
||||
serverChannel,
|
||||
resourceProvider,
|
||||
|
@ -134,8 +137,7 @@ class AbstractAnalysisTest {
|
|||
index,
|
||||
serverPlugin,
|
||||
new AnalysisServerOptions(),
|
||||
new DartSdkManager(
|
||||
resourceProvider.convertPath('/'), false, (_) => sdk),
|
||||
new DartSdkManager(resourceProvider.convertPath('/'), false),
|
||||
InstrumentationService.NULL_SERVICE);
|
||||
}
|
||||
|
||||
|
|
|
@ -137,7 +137,8 @@ import "../foo/foo.dart";
|
|||
manager.processPlugins([plugin]);
|
||||
channel = new MockServerChannel();
|
||||
resourceProvider = new MemoryResourceProvider();
|
||||
MockSdk sdk = new MockSdk(resourceProvider: resourceProvider);
|
||||
// Create an SDK in the mock file system.
|
||||
new MockSdk(resourceProvider: resourceProvider);
|
||||
packageMapProvider = new MockPackageMapProvider();
|
||||
server = new AnalysisServer(
|
||||
channel,
|
||||
|
@ -146,7 +147,7 @@ import "../foo/foo.dart";
|
|||
null,
|
||||
plugin,
|
||||
new AnalysisServerOptions(),
|
||||
new DartSdkManager('/', false, (_) => sdk),
|
||||
new DartSdkManager('/', false),
|
||||
InstrumentationService.NULL_SERVICE,
|
||||
rethrowExceptions: true);
|
||||
processRequiredPlugins();
|
||||
|
|
|
@ -1791,8 +1791,9 @@ abstract class ContextManagerTest {
|
|||
processRequiredPlugins();
|
||||
resourceProvider = new MemoryResourceProvider();
|
||||
packageMapProvider = new MockPackageMapProvider();
|
||||
DartSdk sdk = new MockSdk(resourceProvider: resourceProvider);
|
||||
DartSdkManager sdkManager = new DartSdkManager('/', false, (_) => sdk);
|
||||
// Create an SDK in the mock file system.
|
||||
new MockSdk(resourceProvider: resourceProvider);
|
||||
DartSdkManager sdkManager = new DartSdkManager('/', false);
|
||||
manager = new ContextManagerImpl(
|
||||
resourceProvider,
|
||||
sdkManager,
|
||||
|
@ -2705,7 +2706,7 @@ class TestContextManagerCallbacks extends ContextManagerCallbacks {
|
|||
|
||||
@override
|
||||
ContextBuilder createContextBuilder(Folder folder, AnalysisOptions options) {
|
||||
DartSdkManager sdkManager = new DartSdkManager('/', false, null);
|
||||
DartSdkManager sdkManager = new DartSdkManager('/', false);
|
||||
ContextBuilder builder =
|
||||
new ContextBuilder(resourceProvider, sdkManager, new ContentCache());
|
||||
builder.defaultOptions = options;
|
||||
|
|
|
@ -23,7 +23,6 @@ import 'mock_sdk.dart';
|
|||
import 'mocks.dart';
|
||||
|
||||
main() {
|
||||
|
||||
defineReflectiveSuite(() {
|
||||
defineReflectiveTests(AnalysisDomainTest);
|
||||
defineReflectiveTests(SetSubscriptionsTest);
|
||||
|
@ -40,7 +39,8 @@ main() {
|
|||
ExtensionManager manager = new ExtensionManager();
|
||||
ServerPlugin serverPlugin = new ServerPlugin();
|
||||
manager.processPlugins([serverPlugin]);
|
||||
MockSdk sdk = new MockSdk(resourceProvider: resourceProvider);
|
||||
// Create an SDK in the mock file system.
|
||||
new MockSdk(resourceProvider: resourceProvider);
|
||||
server = new AnalysisServer(
|
||||
serverChannel,
|
||||
resourceProvider,
|
||||
|
@ -48,7 +48,7 @@ main() {
|
|||
null,
|
||||
serverPlugin,
|
||||
new AnalysisServerOptions(),
|
||||
new DartSdkManager('/', false, (_) => sdk),
|
||||
new DartSdkManager('/', false),
|
||||
InstrumentationService.NULL_SERVICE);
|
||||
handler = new AnalysisDomainHandler(server);
|
||||
});
|
||||
|
@ -435,7 +435,8 @@ class AnalysisTestHelper {
|
|||
ExtensionManager manager = new ExtensionManager();
|
||||
ServerPlugin serverPlugin = new ServerPlugin();
|
||||
manager.processPlugins([serverPlugin]);
|
||||
MockSdk sdk = new MockSdk(resourceProvider: resourceProvider);
|
||||
// Create an SDK in the mock file system.
|
||||
new MockSdk(resourceProvider: resourceProvider);
|
||||
server = new AnalysisServer(
|
||||
serverChannel,
|
||||
resourceProvider,
|
||||
|
@ -443,7 +444,7 @@ class AnalysisTestHelper {
|
|||
null,
|
||||
serverPlugin,
|
||||
new AnalysisServerOptions(),
|
||||
new DartSdkManager('/', false, (_) => sdk),
|
||||
new DartSdkManager('/', false),
|
||||
InstrumentationService.NULL_SERVICE);
|
||||
handler = new AnalysisDomainHandler(server);
|
||||
// listen for notifications
|
||||
|
|
|
@ -24,7 +24,6 @@ main() {
|
|||
DiagnosticDomainHandler handler;
|
||||
MemoryResourceProvider resourceProvider;
|
||||
|
||||
|
||||
setUp(() {
|
||||
//
|
||||
// Collect plugins
|
||||
|
@ -45,7 +44,8 @@ main() {
|
|||
//
|
||||
var serverChannel = new MockServerChannel();
|
||||
resourceProvider = new MemoryResourceProvider();
|
||||
MockSdk sdk = new MockSdk(resourceProvider: resourceProvider);
|
||||
// Create an SDK in the mock file system.
|
||||
new MockSdk(resourceProvider: resourceProvider);
|
||||
server = new AnalysisServer(
|
||||
serverChannel,
|
||||
resourceProvider,
|
||||
|
@ -53,7 +53,7 @@ main() {
|
|||
null,
|
||||
serverPlugin,
|
||||
new AnalysisServerOptions(),
|
||||
new DartSdkManager('/', false, (_) => sdk),
|
||||
new DartSdkManager('/', false),
|
||||
InstrumentationService.NULL_SERVICE);
|
||||
handler = new DiagnosticDomainHandler(server);
|
||||
});
|
||||
|
|
|
@ -25,7 +25,6 @@ import 'package:test_reflective_loader/test_reflective_loader.dart';
|
|||
import 'package:typed_mock/typed_mock.dart';
|
||||
|
||||
import 'analysis_abstract.dart';
|
||||
import 'mock_sdk.dart';
|
||||
import 'mocks.dart';
|
||||
import 'operation/operation_queue_test.dart';
|
||||
|
||||
|
@ -49,7 +48,7 @@ main() {
|
|||
null,
|
||||
serverPlugin,
|
||||
new AnalysisServerOptions(),
|
||||
new DartSdkManager('', false, (_) => new MockSdk()),
|
||||
new DartSdkManager('', false),
|
||||
InstrumentationService.NULL_SERVICE);
|
||||
handler = new ExecutionDomainHandler(server);
|
||||
});
|
||||
|
|
|
@ -15,14 +15,12 @@ import 'package:analyzer/src/generated/sdk.dart';
|
|||
import 'package:plugin/manager.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
import 'mock_sdk.dart';
|
||||
import 'mocks.dart';
|
||||
|
||||
main() {
|
||||
AnalysisServer server;
|
||||
ServerDomainHandler handler;
|
||||
|
||||
|
||||
setUp(() {
|
||||
var serverChannel = new MockServerChannel();
|
||||
var resourceProvider = new MemoryResourceProvider();
|
||||
|
@ -36,7 +34,7 @@ main() {
|
|||
null,
|
||||
serverPlugin,
|
||||
new AnalysisServerOptions(),
|
||||
new DartSdkManager('', false, (_) => new MockSdk()),
|
||||
new DartSdkManager('', false),
|
||||
InstrumentationService.NULL_SERVICE);
|
||||
handler = new ServerDomainHandler(server);
|
||||
});
|
||||
|
|
|
@ -21,7 +21,6 @@ import 'package:test/test.dart';
|
|||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import 'context_manager_test.dart' show TestContextManagerCallbacks;
|
||||
import 'mock_sdk.dart';
|
||||
import 'mocks.dart';
|
||||
|
||||
main() {
|
||||
|
@ -64,8 +63,7 @@ class SingleContextManagerTest {
|
|||
packageResolver = new TestUriResolver();
|
||||
|
||||
_processRequiredPlugins();
|
||||
DartSdkManager sdkManager =
|
||||
new DartSdkManager('', false, (_) => new MockSdk());
|
||||
DartSdkManager sdkManager = new DartSdkManager('', false);
|
||||
manager = new SingleContextManager(resourceProvider, sdkManager,
|
||||
(_) => packageResolver, analysisFilesGlobs, new AnalysisOptionsImpl());
|
||||
callbacks = new TestContextManagerCallbacks(resourceProvider);
|
||||
|
|
|
@ -113,12 +113,11 @@ class SocketServerTest {
|
|||
ServerPlugin serverPlugin = new ServerPlugin();
|
||||
ExtensionManager manager = new ExtensionManager();
|
||||
manager.processPlugins([serverPlugin]);
|
||||
SdkCreator sdkCreator = (_) => new FolderBasedDartSdk(resourceProvider,
|
||||
FolderBasedDartSdk.defaultSdkDirectory(resourceProvider));
|
||||
return new SocketServer(
|
||||
new AnalysisServerOptions(),
|
||||
new DartSdkManager('', false, sdkCreator),
|
||||
sdkCreator(null),
|
||||
new DartSdkManager('', false),
|
||||
new FolderBasedDartSdk(resourceProvider,
|
||||
FolderBasedDartSdk.defaultSdkDirectory(resourceProvider)),
|
||||
InstrumentationService.NULL_SERVICE,
|
||||
serverPlugin,
|
||||
null,
|
||||
|
|
|
@ -15,12 +15,6 @@ 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 function used to create a new DartSdk with the given [options]. If the
|
||||
* passed [options] are `null`, then default options are used.
|
||||
*/
|
||||
typedef DartSdk SdkCreator(AnalysisOptions options);
|
||||
|
||||
/**
|
||||
* A Dart SDK installed in a specified location.
|
||||
*/
|
||||
|
@ -117,11 +111,6 @@ class DartSdkManager {
|
|||
*/
|
||||
final bool canUseSummaries;
|
||||
|
||||
/**
|
||||
* The function used to create new SDK's.
|
||||
*/
|
||||
final SdkCreator sdkCreator;
|
||||
|
||||
/**
|
||||
* A table mapping (an encoding of) analysis options and SDK locations to the
|
||||
* DartSdk from that location that has been configured with those options.
|
||||
|
@ -131,8 +120,7 @@ class DartSdkManager {
|
|||
/**
|
||||
* Initialize a newly created manager.
|
||||
*/
|
||||
DartSdkManager(
|
||||
this.defaultSdkDirectory, this.canUseSummaries, this.sdkCreator);
|
||||
DartSdkManager(this.defaultSdkDirectory, this.canUseSummaries);
|
||||
|
||||
/**
|
||||
* Return any SDK that has been created, or `null` if no SDKs have been
|
||||
|
@ -152,25 +140,13 @@ class DartSdkManager {
|
|||
List<SdkDescription> get sdkDescriptors => sdkMap.keys.toList();
|
||||
|
||||
/**
|
||||
* Return the Dart SDK that is appropriate for the given analysis [options].
|
||||
* If such an SDK has not yet been created, then the [sdkCreator] will be
|
||||
* invoked to create it.
|
||||
* Return the Dart SDK that is appropriate for the given SDK [description].
|
||||
* If such an SDK has not yet been created, then the [ifAbsent] function will
|
||||
* be invoked to create it.
|
||||
*/
|
||||
DartSdk getSdk(SdkDescription description, DartSdk ifAbsent()) {
|
||||
return sdkMap.putIfAbsent(description, ifAbsent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the Dart SDK that is appropriate for the given analysis [options].
|
||||
* If such an SDK has not yet been created, then the [sdkCreator] will be
|
||||
* invoked to create it.
|
||||
*/
|
||||
DartSdk getSdkForOptions(AnalysisOptions options) {
|
||||
// TODO(brianwilkerson) Remove this method and the field sdkCreator.
|
||||
SdkDescription description =
|
||||
new SdkDescription(<String>[defaultSdkDirectory], options);
|
||||
return getSdk(description, () => sdkCreator(options));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -22,8 +22,7 @@ main() {
|
|||
@reflectiveTest
|
||||
class DartSdkManagerTest extends EngineTestCase {
|
||||
void test_anySdk() {
|
||||
DartSdkManager manager =
|
||||
new DartSdkManager('/a/b/c', false, _failIfCreated);
|
||||
DartSdkManager manager = new DartSdkManager('/a/b/c', false);
|
||||
expect(manager.anySdk, isNull);
|
||||
|
||||
AnalysisOptions options = new AnalysisOptionsImpl();
|
||||
|
@ -34,8 +33,7 @@ class DartSdkManagerTest extends EngineTestCase {
|
|||
}
|
||||
|
||||
void test_getSdk_differentDescriptors() {
|
||||
DartSdkManager manager =
|
||||
new DartSdkManager('/a/b/c', false, _failIfCreated);
|
||||
DartSdkManager manager = new DartSdkManager('/a/b/c', false);
|
||||
AnalysisOptions options = new AnalysisOptionsImpl();
|
||||
SdkDescription description1 = new SdkDescription(<String>['/c/d'], options);
|
||||
DartSdk sdk1 = new MockSdk();
|
||||
|
@ -51,8 +49,7 @@ class DartSdkManagerTest extends EngineTestCase {
|
|||
}
|
||||
|
||||
void test_getSdk_sameDescriptor() {
|
||||
DartSdkManager manager =
|
||||
new DartSdkManager('/a/b/c', false, _failIfCreated);
|
||||
DartSdkManager manager = new DartSdkManager('/a/b/c', false);
|
||||
AnalysisOptions options = new AnalysisOptionsImpl();
|
||||
SdkDescription description = new SdkDescription(<String>['/c/d'], options);
|
||||
DartSdk sdk = new MockSdk();
|
||||
|
@ -65,11 +62,6 @@ class DartSdkManagerTest extends EngineTestCase {
|
|||
fail('Use of ifAbsent function');
|
||||
return null;
|
||||
}
|
||||
|
||||
DartSdk _failIfCreated(AnalysisOptions _) {
|
||||
fail('Use of sdkCreator');
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@reflectiveTest
|
||||
|
|
|
@ -82,8 +82,7 @@ const Map<String, LibraryInfo> libraries = const {
|
|||
"core": const LibraryInfo("core/core.dart"),
|
||||
};
|
||||
''');
|
||||
sdkManager =
|
||||
new DartSdkManager(defaultSdkPath, false, (_) => new MockSdk());
|
||||
sdkManager = new DartSdkManager(defaultSdkPath, false);
|
||||
builder = new ContextBuilder(resourceProvider, sdkManager, contentCache);
|
||||
}
|
||||
|
||||
|
@ -97,9 +96,7 @@ const Map<String, LibraryInfo> libraries = const {
|
|||
pathContext = resourceProvider.pathContext;
|
||||
new MockSdk(resourceProvider: resourceProvider);
|
||||
sdkManager =
|
||||
new DartSdkManager(resourceProvider.convertPath('/sdk'), false, (_) {
|
||||
fail('Should not be used to create an SDK');
|
||||
});
|
||||
new DartSdkManager(resourceProvider.convertPath('/sdk'), false);
|
||||
contentCache = new ContentCache();
|
||||
builder = new ContextBuilder(resourceProvider, sdkManager, contentCache);
|
||||
}
|
||||
|
|
|
@ -244,8 +244,7 @@ class StressTest {
|
|||
pathContext = resourceProvider.pathContext;
|
||||
fs.Folder sdkDirectory =
|
||||
FolderBasedDartSdk.defaultSdkDirectory(resourceProvider);
|
||||
sdkManager = new DartSdkManager(sdkDirectory.path, false,
|
||||
(_) => new FolderBasedDartSdk(resourceProvider, sdkDirectory));
|
||||
sdkManager = new DartSdkManager(sdkDirectory.path, false);
|
||||
contentCache = new ContentCache();
|
||||
ContextBuilder builder =
|
||||
new ContextBuilder(resourceProvider, sdkManager, contentCache);
|
||||
|
|
Loading…
Reference in a new issue