Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(275)

Side by Side Diff: pkg/analyzer/lib/src/generated/sdk.dart

Issue 2415413003: Remove unused method and field from DartSdkManager (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 analyzer.src.generated.sdk; 5 library analyzer.src.generated.sdk;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analyzer/dart/ast/ast.dart'; 9 import 'package:analyzer/dart/ast/ast.dart';
10 import 'package:analyzer/dart/ast/token.dart'; 10 import 'package:analyzer/dart/ast/token.dart';
11 import 'package:analyzer/dart/ast/visitor.dart'; 11 import 'package:analyzer/dart/ast/visitor.dart';
12 import 'package:analyzer/src/generated/engine.dart' 12 import 'package:analyzer/src/generated/engine.dart'
13 show AnalysisContext, AnalysisOptions, AnalysisOptionsImpl; 13 show AnalysisContext, AnalysisOptions, AnalysisOptionsImpl;
14 import 'package:analyzer/src/generated/source.dart' show Source; 14 import 'package:analyzer/src/generated/source.dart' show Source;
15 import 'package:analyzer/src/generated/utilities_general.dart'; 15 import 'package:analyzer/src/generated/utilities_general.dart';
16 import 'package:analyzer/src/summary/idl.dart' show PackageBundle; 16 import 'package:analyzer/src/summary/idl.dart' show PackageBundle;
17 17
18 /** 18 /**
19 * A function used to create a new DartSdk with the given [options]. If the
20 * passed [options] are `null`, then default options are used.
21 */
22 typedef DartSdk SdkCreator(AnalysisOptions options);
23
24 /**
25 * A Dart SDK installed in a specified location. 19 * A Dart SDK installed in a specified location.
26 */ 20 */
27 abstract class DartSdk { 21 abstract class DartSdk {
28 /** 22 /**
29 * The short name of the dart SDK 'async' library. 23 * The short name of the dart SDK 'async' library.
30 */ 24 */
31 static const String DART_ASYNC = "dart:async"; 25 static const String DART_ASYNC = "dart:async";
32 26
33 /** 27 /**
34 * The short name of the dart SDK 'core' library. 28 * The short name of the dart SDK 'core' library.
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 */ 105 */
112 final String defaultSdkDirectory; 106 final String defaultSdkDirectory;
113 107
114 /** 108 /**
115 * A flag indicating whether it is acceptable to use summaries when they are 109 * A flag indicating whether it is acceptable to use summaries when they are
116 * available. 110 * available.
117 */ 111 */
118 final bool canUseSummaries; 112 final bool canUseSummaries;
119 113
120 /** 114 /**
121 * The function used to create new SDK's.
122 */
123 final SdkCreator sdkCreator;
124
125 /**
126 * A table mapping (an encoding of) analysis options and SDK locations to the 115 * A table mapping (an encoding of) analysis options and SDK locations to the
127 * DartSdk from that location that has been configured with those options. 116 * DartSdk from that location that has been configured with those options.
128 */ 117 */
129 Map<SdkDescription, DartSdk> sdkMap = new HashMap<SdkDescription, DartSdk>(); 118 Map<SdkDescription, DartSdk> sdkMap = new HashMap<SdkDescription, DartSdk>();
130 119
131 /** 120 /**
132 * Initialize a newly created manager. 121 * Initialize a newly created manager.
133 */ 122 */
134 DartSdkManager( 123 DartSdkManager(this.defaultSdkDirectory, this.canUseSummaries);
135 this.defaultSdkDirectory, this.canUseSummaries, this.sdkCreator);
136 124
137 /** 125 /**
138 * Return any SDK that has been created, or `null` if no SDKs have been 126 * Return any SDK that has been created, or `null` if no SDKs have been
139 * created. 127 * created.
140 */ 128 */
141 DartSdk get anySdk { 129 DartSdk get anySdk {
142 if (sdkMap.isEmpty) { 130 if (sdkMap.isEmpty) {
143 return null; 131 return null;
144 } 132 }
145 return sdkMap.values.first; 133 return sdkMap.values.first;
146 } 134 }
147 135
148 /** 136 /**
149 * Return a list of the descriptors of the SDKs that are currently being 137 * Return a list of the descriptors of the SDKs that are currently being
150 * managed. 138 * managed.
151 */ 139 */
152 List<SdkDescription> get sdkDescriptors => sdkMap.keys.toList(); 140 List<SdkDescription> get sdkDescriptors => sdkMap.keys.toList();
153 141
154 /** 142 /**
155 * Return the Dart SDK that is appropriate for the given analysis [options]. 143 * Return the Dart SDK that is appropriate for the given SDK [description].
156 * If such an SDK has not yet been created, then the [sdkCreator] will be 144 * If such an SDK has not yet been created, then the [ifAbsent] function will
157 * invoked to create it. 145 * be invoked to create it.
158 */ 146 */
159 DartSdk getSdk(SdkDescription description, DartSdk ifAbsent()) { 147 DartSdk getSdk(SdkDescription description, DartSdk ifAbsent()) {
160 return sdkMap.putIfAbsent(description, ifAbsent); 148 return sdkMap.putIfAbsent(description, ifAbsent);
161 } 149 }
162
163 /**
164 * Return the Dart SDK that is appropriate for the given analysis [options].
165 * If such an SDK has not yet been created, then the [sdkCreator] will be
166 * invoked to create it.
167 */
168 DartSdk getSdkForOptions(AnalysisOptions options) {
169 // TODO(brianwilkerson) Remove this method and the field sdkCreator.
170 SdkDescription description =
171 new SdkDescription(<String>[defaultSdkDirectory], options);
172 return getSdk(description, () => sdkCreator(options));
173 }
174 } 150 }
175 151
176 /** 152 /**
177 * A map from Dart library URI's to the [SdkLibraryImpl] representing that 153 * A map from Dart library URI's to the [SdkLibraryImpl] representing that
178 * library. 154 * library.
179 */ 155 */
180 class LibraryMap { 156 class LibraryMap {
181 /** 157 /**
182 * A table mapping Dart library URI's to the library. 158 * A table mapping Dart library URI's to the library.
183 */ 159 */
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 _platformsToPatchPaths[platforms] = paths; 659 _platformsToPatchPaths[platforms] = paths;
684 } 660 }
685 661
686 /** 662 /**
687 * Record that this library can be run on the VM. 663 * Record that this library can be run on the VM.
688 */ 664 */
689 void setVmLibrary() { 665 void setVmLibrary() {
690 _platforms |= VM_PLATFORM; 666 _platforms |= VM_PLATFORM;
691 } 667 }
692 } 668 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/test/socket_server_test.dart ('k') | pkg/analyzer/test/generated/sdk_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698