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

Side by Side Diff: pkg/analyzer_experimental/lib/src/generated/sdk_io.dart

Issue 16256021: Remove trailing spaces in analyzer_experimental (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 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 | Annotate | Revision Log
OLDNEW
1 // This code was auto-generated, is not intended to be edited, and is subject to 1 // This code was auto-generated, is not intended to be edited, and is subject to
2 // significant change. Please see the README file for more information. 2 // significant change. Please see the README file for more information.
3
4 library engine.sdk.io; 3 library engine.sdk.io;
5
6 import 'dart:io'; 4 import 'dart:io';
7 import 'java_core.dart'; 5 import 'java_core.dart';
8 import 'java_io.dart'; 6 import 'java_io.dart';
9 import 'java_engine.dart'; 7 import 'java_engine.dart';
10 import 'java_engine_io.dart'; 8 import 'java_engine_io.dart';
11 import 'source_io.dart'; 9 import 'source_io.dart';
12 import 'error.dart'; 10 import 'error.dart';
13 import 'scanner.dart'; 11 import 'scanner.dart';
14 import 'ast.dart'; 12 import 'ast.dart';
15 import 'parser.dart'; 13 import 'parser.dart';
16 import 'sdk.dart'; 14 import 'sdk.dart';
17 import 'engine.dart'; 15 import 'engine.dart';
18
19
20 /** 16 /**
21 * Instances of the class {@code DirectoryBasedDartSdk} represent a Dart SDK ins talled in a 17 * Instances of the class {@code DirectoryBasedDartSdk} represent a Dart SDK ins talled in a
22 * specified directory. 18 * specified directory.
23 * @coverage dart.engine.sdk 19 * @coverage dart.engine.sdk
24 */ 20 */
25 class DirectoryBasedDartSdk implements DartSdk { 21 class DirectoryBasedDartSdk implements DartSdk {
26 22
27 /** 23 /**
28 * The {@link AnalysisContext} which is used for all of the sources in this {@ link DartSdk}. 24 * The {@link AnalysisContext} which is used for all of the sources in this {@ link DartSdk}.
29 */ 25 */
30 InternalAnalysisContext _analysisContext; 26 InternalAnalysisContext _analysisContext;
31 27
32 /** 28 /**
33 * The directory containing the SDK. 29 * The directory containing the SDK.
34 */ 30 */
35 JavaFile _sdkDirectory; 31 JavaFile _sdkDirectory;
36 32
37 /** 33 /**
38 * The revision number of this SDK, or {@code "0"} if the revision number cann ot be discovered. 34 * The revision number of this SDK, or {@code "0"} if the revision number cann ot be discovered.
39 */ 35 */
40 String _sdkVersion; 36 String _sdkVersion;
41 37
42 /** 38 /**
43 * The file containing the Dartium executable. 39 * The file containing the Dartium executable.
44 */ 40 */
45 JavaFile _dartiumExecutable; 41 JavaFile _dartiumExecutable;
46 42
47 /** 43 /**
48 * The file containing the VM executable. 44 * The file containing the VM executable.
49 */ 45 */
50 JavaFile _vmExecutable; 46 JavaFile _vmExecutable;
51 47
52 /** 48 /**
53 * A mapping from Dart library URI's to the library represented by that URI. 49 * A mapping from Dart library URI's to the library represented by that URI.
54 */ 50 */
55 LibraryMap _libraryMap; 51 LibraryMap _libraryMap;
56 52
57 /** 53 /**
58 * The name of the directory within the SDK directory that contains executable s. 54 * The name of the directory within the SDK directory that contains executable s.
59 */ 55 */
60 static String _BIN_DIRECTORY_NAME = "bin"; 56 static String _BIN_DIRECTORY_NAME = "bin";
61 57
62 /** 58 /**
63 * The name of the directory within the SDK directory that contains Chromium. 59 * The name of the directory within the SDK directory that contains Chromium.
64 */ 60 */
65 static String _CHROMIUM_DIRECTORY_NAME = "chromium"; 61 static String _CHROMIUM_DIRECTORY_NAME = "chromium";
66 62
67 /** 63 /**
68 * The name of the environment variable whose value is the path to the default Dart SDK directory. 64 * The name of the environment variable whose value is the path to the default Dart SDK directory.
69 */ 65 */
70 static String _DART_SDK_ENVIRONMENT_VARIABLE_NAME = "DART_SDK"; 66 static String _DART_SDK_ENVIRONMENT_VARIABLE_NAME = "DART_SDK";
71 67
72 /** 68 /**
73 * The name of the file containing the Dartium executable on Linux. 69 * The name of the file containing the Dartium executable on Linux.
74 */ 70 */
75 static String _DARTIUM_EXECUTABLE_NAME_LINUX = "chrome"; 71 static String _DARTIUM_EXECUTABLE_NAME_LINUX = "chrome";
76 72
77 /** 73 /**
78 * The name of the file containing the Dartium executable on Macintosh. 74 * The name of the file containing the Dartium executable on Macintosh.
79 */ 75 */
80 static String _DARTIUM_EXECUTABLE_NAME_MAC = "Chromium.app/Contents/MacOS/Chro mium"; 76 static String _DARTIUM_EXECUTABLE_NAME_MAC = "Chromium.app/Contents/MacOS/Chro mium";
81 77
82 /** 78 /**
83 * The name of the file containing the Dartium executable on Windows. 79 * The name of the file containing the Dartium executable on Windows.
84 */ 80 */
85 static String _DARTIUM_EXECUTABLE_NAME_WIN = "Chrome.exe"; 81 static String _DARTIUM_EXECUTABLE_NAME_WIN = "Chrome.exe";
86 82
87 /** 83 /**
88 * The name of the {@link System} property whose value is the path to the defa ult Dart SDK 84 * The name of the {@link System} property whose value is the path to the defa ult Dart SDK
89 * directory. 85 * directory.
90 */ 86 */
91 static String _DEFAULT_DIRECTORY_PROPERTY_NAME = "com.google.dart.sdk"; 87 static String _DEFAULT_DIRECTORY_PROPERTY_NAME = "com.google.dart.sdk";
92 88
93 /** 89 /**
94 * The name of the directory within the SDK directory that contains documentat ion for the 90 * The name of the directory within the SDK directory that contains documentat ion for the
95 * libraries. 91 * libraries.
96 */ 92 */
97 static String _DOCS_DIRECTORY_NAME = "docs"; 93 static String _DOCS_DIRECTORY_NAME = "docs";
98 94
99 /** 95 /**
100 * The suffix added to the name of a library to derive the name of the file co ntaining the 96 * The suffix added to the name of a library to derive the name of the file co ntaining the
101 * documentation for that library. 97 * documentation for that library.
102 */ 98 */
103 static String _DOC_FILE_SUFFIX = "_api.json"; 99 static String _DOC_FILE_SUFFIX = "_api.json";
104 100
105 /** 101 /**
106 * The name of the directory within the SDK directory that contains the librar ies file. 102 * The name of the directory within the SDK directory that contains the librar ies file.
107 */ 103 */
108 static String _INTERNAL_DIR = "_internal"; 104 static String _INTERNAL_DIR = "_internal";
109 105
110 /** 106 /**
111 * The name of the directory within the SDK directory that contains the librar ies. 107 * The name of the directory within the SDK directory that contains the librar ies.
112 */ 108 */
113 static String _LIB_DIRECTORY_NAME = "lib"; 109 static String _LIB_DIRECTORY_NAME = "lib";
114 110
115 /** 111 /**
116 * The name of the libraries file. 112 * The name of the libraries file.
117 */ 113 */
118 static String _LIBRARIES_FILE = "libraries.dart"; 114 static String _LIBRARIES_FILE = "libraries.dart";
119 115
120 /** 116 /**
121 * The name of the file within the SDK directory that contains the revision nu mber of the SDK. 117 * The name of the file within the SDK directory that contains the revision nu mber of the SDK.
122 */ 118 */
123 static String _REVISION_FILE_NAME = "revision"; 119 static String _REVISION_FILE_NAME = "revision";
124 120
125 /** 121 /**
126 * The name of the file containing the VM executable on the Windows operating system. 122 * The name of the file containing the VM executable on the Windows operating system.
127 */ 123 */
128 static String _VM_EXECUTABLE_NAME_WIN = "dart.exe"; 124 static String _VM_EXECUTABLE_NAME_WIN = "dart.exe";
129 125
130 /** 126 /**
131 * The name of the file containing the VM executable on non-Windows operating systems. 127 * The name of the file containing the VM executable on non-Windows operating systems.
132 */ 128 */
133 static String _VM_EXECUTABLE_NAME = "dart"; 129 static String _VM_EXECUTABLE_NAME = "dart";
134 130
135 /** 131 /**
136 * Return the default Dart SDK, or {@code null} if the directory containing th e default SDK cannot 132 * Return the default Dart SDK, or {@code null} if the directory containing th e default SDK cannot
137 * be determined (or does not exist). 133 * be determined (or does not exist).
138 * @return the default Dart SDK 134 * @return the default Dart SDK
139 */ 135 */
140 static DirectoryBasedDartSdk get defaultSdk { 136 static DirectoryBasedDartSdk get defaultSdk {
141 JavaFile sdkDirectory = defaultSdkDirectory; 137 JavaFile sdkDirectory = defaultSdkDirectory;
142 if (sdkDirectory == null) { 138 if (sdkDirectory == null) {
143 return null; 139 return null;
144 } 140 }
145 return new DirectoryBasedDartSdk(sdkDirectory); 141 return new DirectoryBasedDartSdk(sdkDirectory);
146 } 142 }
147 143
148 /** 144 /**
149 * Return the default directory for the Dart SDK, or {@code null} if the direc tory cannot be 145 * Return the default directory for the Dart SDK, or {@code null} if the direc tory cannot be
150 * determined (or does not exist). The default directory is provided by a {@li nk System} property 146 * determined (or does not exist). The default directory is provided by a {@li nk System} property
151 * named {@code com.google.dart.sdk}, or, if the property is not defined, an e nvironment variable 147 * named {@code com.google.dart.sdk}, or, if the property is not defined, an e nvironment variable
152 * named {@code DART_SDK}. 148 * named {@code DART_SDK}.
153 * @return the default directory for the Dart SDK 149 * @return the default directory for the Dart SDK
154 */ 150 */
155 static JavaFile get defaultSdkDirectory { 151 static JavaFile get defaultSdkDirectory {
156 String sdkProperty = JavaSystemIO.getProperty(_DEFAULT_DIRECTORY_PROPERTY_NA ME); 152 String sdkProperty = JavaSystemIO.getProperty(_DEFAULT_DIRECTORY_PROPERTY_NA ME);
157 if (sdkProperty == null) { 153 if (sdkProperty == null) {
158 sdkProperty = JavaSystemIO.getenv(_DART_SDK_ENVIRONMENT_VARIABLE_NAME); 154 sdkProperty = JavaSystemIO.getenv(_DART_SDK_ENVIRONMENT_VARIABLE_NAME);
159 if (sdkProperty == null) { 155 if (sdkProperty == null) {
160 return null; 156 return null;
161 } 157 }
162 } 158 }
163 JavaFile sdkDirectory = new JavaFile(sdkProperty); 159 JavaFile sdkDirectory = new JavaFile(sdkProperty);
164 if (!sdkDirectory.exists()) { 160 if (!sdkDirectory.exists()) {
165 return null; 161 return null;
166 } 162 }
167 return sdkDirectory; 163 return sdkDirectory;
168 } 164 }
169 165
170 /** 166 /**
171 * Initialize a newly created SDK to represent the Dart SDK installed in the g iven directory. 167 * Initialize a newly created SDK to represent the Dart SDK installed in the g iven directory.
172 * @param sdkDirectory the directory containing the SDK 168 * @param sdkDirectory the directory containing the SDK
173 */ 169 */
174 DirectoryBasedDartSdk(JavaFile sdkDirectory) { 170 DirectoryBasedDartSdk(JavaFile sdkDirectory) {
175 this._sdkDirectory = sdkDirectory.getAbsoluteFile(); 171 this._sdkDirectory = sdkDirectory.getAbsoluteFile();
176 initializeSdk(); 172 initializeSdk();
177 initializeLibraryMap(); 173 initializeLibraryMap();
178 _analysisContext = new AnalysisContextImpl(); 174 _analysisContext = new AnalysisContextImpl();
179 _analysisContext.sourceFactory = new SourceFactory.con2([new DartUriResolver (this)]); 175 _analysisContext.sourceFactory = new SourceFactory.con2([new DartUriResolver (this)]);
180 List<String> uris2 = uris; 176 List<String> uris2 = uris;
181 ChangeSet changeSet = new ChangeSet(); 177 ChangeSet changeSet = new ChangeSet();
182 for (String uri in uris2) { 178 for (String uri in uris2) {
183 changeSet.added(_analysisContext.sourceFactory.forUri(uri)); 179 changeSet.added(_analysisContext.sourceFactory.forUri(uri));
184 } 180 }
185 _analysisContext.applyChanges(changeSet); 181 _analysisContext.applyChanges(changeSet);
186 } 182 }
187 Source fromEncoding(ContentCache contentCache, UriKind kind, Uri uri) => new F ileBasedSource.con2(contentCache, new JavaFile.fromUri(uri), kind); 183 Source fromEncoding(ContentCache contentCache, UriKind kind, Uri uri) => new F ileBasedSource.con2(contentCache, new JavaFile.fromUri(uri), kind);
188 AnalysisContext get context => _analysisContext; 184 AnalysisContext get context => _analysisContext;
189 185
190 /** 186 /**
191 * Return the file containing the Dartium executable, or {@code null} if it do es not exist. 187 * Return the file containing the Dartium executable, or {@code null} if it do es not exist.
192 * @return the file containing the Dartium executable 188 * @return the file containing the Dartium executable
193 */ 189 */
194 JavaFile get dartiumExecutable { 190 JavaFile get dartiumExecutable {
195 { 191 {
196 if (_dartiumExecutable == null) { 192 if (_dartiumExecutable == null) {
197 JavaFile file = new JavaFile.relative(dartiumWorkingDirectory, dartiumBi naryName); 193 JavaFile file = new JavaFile.relative(dartiumWorkingDirectory, dartiumBi naryName);
198 if (file.exists()) { 194 if (file.exists()) {
199 _dartiumExecutable = file; 195 _dartiumExecutable = file;
200 } 196 }
201 } 197 }
202 } 198 }
203 return _dartiumExecutable; 199 return _dartiumExecutable;
204 } 200 }
205 201
206 /** 202 /**
207 * Return the directory where dartium can be found in the Dart SDK (the direct ory that will be the 203 * Return the directory where dartium can be found in the Dart SDK (the direct ory that will be the
208 * working directory is Dartium is invoked without changing the default). 204 * working directory is Dartium is invoked without changing the default).
209 * @return the directory where dartium can be found 205 * @return the directory where dartium can be found
210 */ 206 */
211 JavaFile get dartiumWorkingDirectory => new JavaFile.relative(_sdkDirectory.ge tParentFile(), _CHROMIUM_DIRECTORY_NAME); 207 JavaFile get dartiumWorkingDirectory => new JavaFile.relative(_sdkDirectory.ge tParentFile(), _CHROMIUM_DIRECTORY_NAME);
212 208
213 /** 209 /**
214 * Return the directory containing the SDK. 210 * Return the directory containing the SDK.
215 * @return the directory containing the SDK 211 * @return the directory containing the SDK
216 */ 212 */
217 JavaFile get directory => _sdkDirectory; 213 JavaFile get directory => _sdkDirectory;
218 214
219 /** 215 /**
220 * Return the directory containing documentation for the SDK. 216 * Return the directory containing documentation for the SDK.
221 * @return the SDK's documentation directory 217 * @return the SDK's documentation directory
222 */ 218 */
223 JavaFile get docDirectory => new JavaFile.relative(_sdkDirectory, _DOCS_DIRECT ORY_NAME); 219 JavaFile get docDirectory => new JavaFile.relative(_sdkDirectory, _DOCS_DIRECT ORY_NAME);
224 220
225 /** 221 /**
226 * Return the auxiliary documentation file for the given library, or {@code nu ll} if no such file 222 * Return the auxiliary documentation file for the given library, or {@code nu ll} if no such file
227 * exists. 223 * exists.
228 * @param libraryName the name of the library associated with the documentatio n file to be 224 * @param libraryName the name of the library associated with the documentatio n file to be
229 * returned 225 * returned
230 * @return the auxiliary documentation file for the library 226 * @return the auxiliary documentation file for the library
231 */ 227 */
232 JavaFile getDocFileFor(String libraryName) { 228 JavaFile getDocFileFor(String libraryName) {
233 JavaFile dir = docDirectory; 229 JavaFile dir = docDirectory;
234 if (!dir.exists()) { 230 if (!dir.exists()) {
235 return null; 231 return null;
236 } 232 }
237 JavaFile libDir = new JavaFile.relative(dir, libraryName); 233 JavaFile libDir = new JavaFile.relative(dir, libraryName);
238 JavaFile docFile = new JavaFile.relative(libDir, "${libraryName}${_DOC_FILE_ SUFFIX}"); 234 JavaFile docFile = new JavaFile.relative(libDir, "${libraryName}${_DOC_FILE_ SUFFIX}");
239 if (docFile.exists()) { 235 if (docFile.exists()) {
240 return docFile; 236 return docFile;
241 } 237 }
242 return null; 238 return null;
243 } 239 }
244 240
245 /** 241 /**
246 * Return the directory within the SDK directory that contains the libraries. 242 * Return the directory within the SDK directory that contains the libraries.
247 * @return the directory that contains the libraries 243 * @return the directory that contains the libraries
248 */ 244 */
249 JavaFile get libraryDirectory => new JavaFile.relative(_sdkDirectory, _LIB_DIR ECTORY_NAME); 245 JavaFile get libraryDirectory => new JavaFile.relative(_sdkDirectory, _LIB_DIR ECTORY_NAME);
250 List<SdkLibrary> get sdkLibraries => _libraryMap.sdkLibraries; 246 List<SdkLibrary> get sdkLibraries => _libraryMap.sdkLibraries;
251 SdkLibrary getSdkLibrary(String dartUri) => _libraryMap.getLibrary(dartUri); 247 SdkLibrary getSdkLibrary(String dartUri) => _libraryMap.getLibrary(dartUri);
252 248
253 /** 249 /**
254 * Return the revision number of this SDK, or {@code "0"} if the revision numb er cannot be 250 * Return the revision number of this SDK, or {@code "0"} if the revision numb er cannot be
255 * discovered. 251 * discovered.
256 * @return the revision number of this SDK 252 * @return the revision number of this SDK
257 */ 253 */
258 String get sdkVersion { 254 String get sdkVersion {
259 { 255 {
260 if (_sdkVersion == null) { 256 if (_sdkVersion == null) {
261 _sdkVersion = DartSdk.DEFAULT_VERSION; 257 _sdkVersion = DartSdk.DEFAULT_VERSION;
262 JavaFile revisionFile = new JavaFile.relative(_sdkDirectory, _REVISION_F ILE_NAME); 258 JavaFile revisionFile = new JavaFile.relative(_sdkDirectory, _REVISION_F ILE_NAME);
263 try { 259 try {
264 String revision = revisionFile.readAsStringSync(); 260 String revision = revisionFile.readAsStringSync();
265 if (revision != null) { 261 if (revision != null) {
266 _sdkVersion = revision; 262 _sdkVersion = revision;
267 } 263 }
268 } on IOException catch (exception) { 264 } on IOException catch (exception) {
269 } 265 }
270 } 266 }
271 } 267 }
272 return _sdkVersion; 268 return _sdkVersion;
273 } 269 }
274 270
275 /** 271 /**
276 * Return an array containing the library URI's for the libraries defined in t his SDK. 272 * Return an array containing the library URI's for the libraries defined in t his SDK.
277 * @return the library URI's for the libraries defined in this SDK 273 * @return the library URI's for the libraries defined in this SDK
278 */ 274 */
279 List<String> get uris => _libraryMap.uris; 275 List<String> get uris => _libraryMap.uris;
280 276
281 /** 277 /**
282 * Return the file containing the VM executable, or {@code null} if it does no t exist. 278 * Return the file containing the VM executable, or {@code null} if it does no t exist.
283 * @return the file containing the VM executable 279 * @return the file containing the VM executable
284 */ 280 */
285 JavaFile get vmExecutable { 281 JavaFile get vmExecutable {
286 { 282 {
287 if (_vmExecutable == null) { 283 if (_vmExecutable == null) {
288 JavaFile file = new JavaFile.relative(new JavaFile.relative(_sdkDirector y, _BIN_DIRECTORY_NAME), binaryName); 284 JavaFile file = new JavaFile.relative(new JavaFile.relative(_sdkDirector y, _BIN_DIRECTORY_NAME), binaryName);
289 if (file.exists()) { 285 if (file.exists()) {
290 _vmExecutable = file; 286 _vmExecutable = file;
291 } 287 }
292 } 288 }
293 } 289 }
294 return _vmExecutable; 290 return _vmExecutable;
295 } 291 }
296 292
297 /** 293 /**
298 * Return {@code true} if this SDK includes documentation. 294 * Return {@code true} if this SDK includes documentation.
299 * @return {@code true} if this installation of the SDK has documentation 295 * @return {@code true} if this installation of the SDK has documentation
300 */ 296 */
301 bool hasDocumentation() => docDirectory.exists(); 297 bool hasDocumentation() => docDirectory.exists();
302 298
303 /** 299 /**
304 * Return {@code true} if the Dartium binary is available. 300 * Return {@code true} if the Dartium binary is available.
305 * @return {@code true} if the Dartium binary is available 301 * @return {@code true} if the Dartium binary is available
306 */ 302 */
307 bool isDartiumInstalled() => dartiumExecutable != null; 303 bool isDartiumInstalled() => dartiumExecutable != null;
308 Source mapDartUri(ContentCache contentCache, String dartUri) { 304 Source mapDartUri(ContentCache contentCache, String dartUri) {
309 SdkLibrary library = getSdkLibrary(dartUri); 305 SdkLibrary library = getSdkLibrary(dartUri);
310 if (library == null) { 306 if (library == null) {
311 return null; 307 return null;
312 } 308 }
313 return new FileBasedSource.con2(contentCache, new JavaFile.relative(libraryD irectory, library.path), UriKind.DART_URI); 309 return new FileBasedSource.con2(contentCache, new JavaFile.relative(libraryD irectory, library.path), UriKind.DART_URI);
314 } 310 }
315 311
316 /** 312 /**
317 * Ensure that the dart VM is executable. If it is not, make it executable and log that it was 313 * Ensure that the dart VM is executable. If it is not, make it executable and log that it was
318 * necessary for us to do so. 314 * necessary for us to do so.
319 */ 315 */
320 void ensureVmIsExecutable() { 316 void ensureVmIsExecutable() {
321 } 317 }
322 318
323 /** 319 /**
324 * Return the name of the file containing the VM executable. 320 * Return the name of the file containing the VM executable.
325 * @return the name of the file containing the VM executable 321 * @return the name of the file containing the VM executable
326 */ 322 */
327 String get binaryName { 323 String get binaryName {
328 if (OSUtilities.isWindows()) { 324 if (OSUtilities.isWindows()) {
329 return _VM_EXECUTABLE_NAME_WIN; 325 return _VM_EXECUTABLE_NAME_WIN;
330 } else { 326 } else {
331 return _VM_EXECUTABLE_NAME; 327 return _VM_EXECUTABLE_NAME;
332 } 328 }
333 } 329 }
334 330
335 /** 331 /**
336 * Return the name of the file containing the Dartium executable. 332 * Return the name of the file containing the Dartium executable.
337 * @return the name of the file containing the Dartium executable 333 * @return the name of the file containing the Dartium executable
338 */ 334 */
339 String get dartiumBinaryName { 335 String get dartiumBinaryName {
340 if (OSUtilities.isWindows()) { 336 if (OSUtilities.isWindows()) {
341 return _DARTIUM_EXECUTABLE_NAME_WIN; 337 return _DARTIUM_EXECUTABLE_NAME_WIN;
342 } else if (OSUtilities.isMac()) { 338 } else if (OSUtilities.isMac()) {
343 return _DARTIUM_EXECUTABLE_NAME_MAC; 339 return _DARTIUM_EXECUTABLE_NAME_MAC;
344 } else { 340 } else {
345 return _DARTIUM_EXECUTABLE_NAME_LINUX; 341 return _DARTIUM_EXECUTABLE_NAME_LINUX;
346 } 342 }
347 } 343 }
348 344
349 /** 345 /**
350 * Read all of the configuration files to initialize the library maps. 346 * Read all of the configuration files to initialize the library maps.
351 */ 347 */
352 void initializeLibraryMap() { 348 void initializeLibraryMap() {
353 try { 349 try {
354 JavaFile librariesFile = new JavaFile.relative(new JavaFile.relative(libra ryDirectory, _INTERNAL_DIR), _LIBRARIES_FILE); 350 JavaFile librariesFile = new JavaFile.relative(new JavaFile.relative(libra ryDirectory, _INTERNAL_DIR), _LIBRARIES_FILE);
355 String contents = librariesFile.readAsStringSync(); 351 String contents = librariesFile.readAsStringSync();
356 _libraryMap = new SdkLibrariesReader().readFrom(librariesFile, contents); 352 _libraryMap = new SdkLibrariesReader().readFrom(librariesFile, contents);
357 } catch (exception) { 353 } catch (exception) {
358 AnalysisEngine.instance.logger.logError3(exception); 354 AnalysisEngine.instance.logger.logError3(exception);
359 _libraryMap = new LibraryMap(); 355 _libraryMap = new LibraryMap();
360 } 356 }
361 } 357 }
362 358
363 /** 359 /**
364 * Initialize the state of the SDK. 360 * Initialize the state of the SDK.
365 */ 361 */
366 void initializeSdk() { 362 void initializeSdk() {
367 if (!OSUtilities.isWindows()) { 363 if (!OSUtilities.isWindows()) {
368 ensureVmIsExecutable(); 364 ensureVmIsExecutable();
369 } 365 }
370 } 366 }
371 } 367 }
372
373 /** 368 /**
374 * Instances of the class {@code SdkLibrariesReader} read and parse the librarie s file 369 * Instances of the class {@code SdkLibrariesReader} read and parse the librarie s file
375 * (dart-sdk/lib/_internal/libraries.dart) for information about the libraries i n an SDK. The 370 * (dart-sdk/lib/_internal/libraries.dart) for information about the libraries i n an SDK. The
376 * library information is represented as a Dart file containing a single top-lev el variable whose 371 * library information is represented as a Dart file containing a single top-lev el variable whose
377 * value is a const map. The keys of the map are the names of libraries defined in the SDK and the 372 * value is a const map. The keys of the map are the names of libraries defined in the SDK and the
378 * values in the map are info objects defining the library. For example, a subse t of a typical SDK 373 * values in the map are info objects defining the library. For example, a subse t of a typical SDK
379 * might have a libraries file that looks like the following: 374 * might have a libraries file that looks like the following:
380 * <pre> 375 * <pre>
381 * final Map&lt;String, LibraryInfo&gt; LIBRARIES = const &lt;LibraryInfo&gt; { 376 * final Map&lt;String, LibraryInfo&gt; LIBRARIES = const &lt;LibraryInfo&gt; {
382 * // Used by VM applications 377 * // Used by VM applications
383 * "builtin" : const LibraryInfo( 378 * "builtin" : const LibraryInfo(
384 * "builtin/builtin_runtime.dart", 379 * "builtin/builtin_runtime.dart",
385 * category: "Server", 380 * category: "Server",
386 * platforms: VM_PLATFORM), 381 * platforms: VM_PLATFORM),
387 * "compiler" : const LibraryInfo( 382 * "compiler" : const LibraryInfo(
388 * "compiler/compiler.dart", 383 * "compiler/compiler.dart",
389 * category: "Tools", 384 * category: "Tools",
390 * platforms: 0), 385 * platforms: 0),
391 * }; 386 * };
392 * </pre> 387 * </pre>
393 * @coverage dart.engine.sdk 388 * @coverage dart.engine.sdk
394 */ 389 */
395 class SdkLibrariesReader { 390 class SdkLibrariesReader {
396 391
397 /** 392 /**
398 * Return the library map read from the given source. 393 * Return the library map read from the given source.
399 * @return the library map read from the given source 394 * @return the library map read from the given source
400 */ 395 */
401 LibraryMap readFrom(JavaFile librariesFile, String libraryFileContents) { 396 LibraryMap readFrom(JavaFile librariesFile, String libraryFileContents) {
402 List<bool> foundError = [false]; 397 List<bool> foundError = [false];
403 AnalysisErrorListener errorListener = new AnalysisErrorListener_9(foundError ); 398 AnalysisErrorListener errorListener = new AnalysisErrorListener_9(foundError );
404 Source source = new FileBasedSource.con2(null, librariesFile, UriKind.FILE_U RI); 399 Source source = new FileBasedSource.con2(null, librariesFile, UriKind.FILE_U RI);
405 StringScanner scanner = new StringScanner(source, libraryFileContents, error Listener); 400 StringScanner scanner = new StringScanner(source, libraryFileContents, error Listener);
406 Parser parser = new Parser(source, errorListener); 401 Parser parser = new Parser(source, errorListener);
407 CompilationUnit unit = parser.parseCompilationUnit(scanner.tokenize()); 402 CompilationUnit unit = parser.parseCompilationUnit(scanner.tokenize());
408 SdkLibrariesReader_LibraryBuilder libraryBuilder = new SdkLibrariesReader_Li braryBuilder(); 403 SdkLibrariesReader_LibraryBuilder libraryBuilder = new SdkLibrariesReader_Li braryBuilder();
409 if (!foundError[0]) { 404 if (!foundError[0]) {
410 unit.accept(libraryBuilder); 405 unit.accept(libraryBuilder);
411 } 406 }
412 return libraryBuilder.librariesMap; 407 return libraryBuilder.librariesMap;
413 } 408 }
414 } 409 }
415 class SdkLibrariesReader_LibraryBuilder extends RecursiveASTVisitor<Object> { 410 class SdkLibrariesReader_LibraryBuilder extends RecursiveASTVisitor<Object> {
416 411
417 /** 412 /**
418 * The prefix added to the name of a library to form the URI used in code to r eference the 413 * The prefix added to the name of a library to form the URI used in code to r eference the
419 * library. 414 * library.
420 */ 415 */
421 static String _LIBRARY_PREFIX = "dart:"; 416 static String _LIBRARY_PREFIX = "dart:";
422 417
423 /** 418 /**
424 * The name of the optional parameter used to indicate whether the library is an implementation 419 * The name of the optional parameter used to indicate whether the library is an implementation
425 * library. 420 * library.
426 */ 421 */
427 static String _IMPLEMENTATION = "implementation"; 422 static String _IMPLEMENTATION = "implementation";
428 423
429 /** 424 /**
430 * The name of the optional parameter used to indicate whether the library is documented. 425 * The name of the optional parameter used to indicate whether the library is documented.
431 */ 426 */
432 static String _DOCUMENTED = "documented"; 427 static String _DOCUMENTED = "documented";
433 428
434 /** 429 /**
435 * The name of the optional parameter used to specify the category of the libr ary. 430 * The name of the optional parameter used to specify the category of the libr ary.
436 */ 431 */
437 static String _CATEGORY = "category"; 432 static String _CATEGORY = "category";
438 433
439 /** 434 /**
440 * The name of the optional parameter used to specify the platforms on which t he library can be 435 * The name of the optional parameter used to specify the platforms on which t he library can be
441 * used. 436 * used.
442 */ 437 */
443 static String _PLATFORMS = "platforms"; 438 static String _PLATFORMS = "platforms";
444 439
445 /** 440 /**
446 * The value of the {@link #PLATFORMS platforms} parameter used to specify tha t the library can 441 * The value of the {@link #PLATFORMS platforms} parameter used to specify tha t the library can
447 * be used on the VM. 442 * be used on the VM.
448 */ 443 */
449 static String _VM_PLATFORM = "VM_PLATFORM"; 444 static String _VM_PLATFORM = "VM_PLATFORM";
450 445
451 /** 446 /**
452 * The library map that is populated by visiting the AST structure parsed from the contents of 447 * The library map that is populated by visiting the AST structure parsed from the contents of
453 * the libraries file. 448 * the libraries file.
454 */ 449 */
455 LibraryMap _librariesMap = new LibraryMap(); 450 LibraryMap _librariesMap = new LibraryMap();
456 451
457 /** 452 /**
458 * Return the library map that was populated by visiting the AST structure par sed from the 453 * Return the library map that was populated by visiting the AST structure par sed from the
459 * contents of the libraries file. 454 * contents of the libraries file.
460 * @return the library map describing the contents of the SDK 455 * @return the library map describing the contents of the SDK
461 */ 456 */
462 LibraryMap get librariesMap => _librariesMap; 457 LibraryMap get librariesMap => _librariesMap;
463 Object visitMapLiteralEntry(MapLiteralEntry node) { 458 Object visitMapLiteralEntry(MapLiteralEntry node) {
464 String libraryName = null; 459 String libraryName = null;
465 Expression key2 = node.key; 460 Expression key2 = node.key;
466 if (key2 is SimpleStringLiteral) { 461 if (key2 is SimpleStringLiteral) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 return null; 494 return null;
500 } 495 }
501 } 496 }
502 class AnalysisErrorListener_9 implements AnalysisErrorListener { 497 class AnalysisErrorListener_9 implements AnalysisErrorListener {
503 List<bool> foundError; 498 List<bool> foundError;
504 AnalysisErrorListener_9(this.foundError); 499 AnalysisErrorListener_9(this.foundError);
505 void onError(AnalysisError error) { 500 void onError(AnalysisError error) {
506 foundError[0] = true; 501 foundError[0] = true;
507 } 502 }
508 } 503 }
OLDNEW
« no previous file with comments | « pkg/analyzer_experimental/lib/src/generated/sdk.dart ('k') | pkg/analyzer_experimental/lib/src/generated/source.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698