OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
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. | |
4 | |
5 library libraries; | |
6 | |
7 /** | |
8 * A bit flag used by [LibraryInfo] indicating that a library is used by dart2js | |
9 */ | |
10 const int DART2JS_PLATFORM = 1; | |
11 | |
12 /** | |
13 * A bit flag used by [LibraryInfo] indicating that a library is used by the VM | |
14 */ | |
15 const int VM_PLATFORM = 2; | |
16 | |
17 /** | |
18 * Mapping of "dart:" library name (e.g. "core") to information about that libra
ry. | |
19 * This information is structured such that Dart Editor can parse this file | |
20 * and extract the necessary information without executing it | |
21 * while other tools can access via execution. | |
22 */ | |
23 const Map<String, LibraryInfo> LIBRARIES = const { | |
24 | |
25 "async": const LibraryInfo( | |
26 "async/async.dart", | |
27 maturity: Maturity.STABLE, | |
28 dart2jsPatchPath: "_internal/compiler/js_lib/async_patch.dart"), | |
29 | |
30 "collection": const LibraryInfo( | |
31 "collection/collection.dart", | |
32 maturity: Maturity.STABLE, | |
33 dart2jsPatchPath: "_internal/compiler/js_lib/collection_patch.dart"), | |
34 | |
35 "convert": const LibraryInfo( | |
36 "convert/convert.dart", | |
37 maturity: Maturity.STABLE, | |
38 dart2jsPatchPath: "_internal/compiler/js_lib/convert_patch.dart"), | |
39 | |
40 "core": const LibraryInfo( | |
41 "core/core.dart", | |
42 maturity: Maturity.STABLE, | |
43 dart2jsPatchPath: "_internal/compiler/js_lib/core_patch.dart"), | |
44 | |
45 "developer": const LibraryInfo( | |
46 "developer/developer.dart", | |
47 maturity: Maturity.STABLE, | |
48 dart2jsPatchPath: "_internal/js_runtime/lib/developer_patch.dart"), | |
49 | |
50 "html": const LibraryInfo( | |
51 "html/dart2js/html_dart2js.dart", | |
52 category: "Client", | |
53 maturity: Maturity.WEB_STABLE), | |
54 | |
55 "html_common": const LibraryInfo( | |
56 "html/html_common/html_common_dart2js.dart", | |
57 category: "Client", | |
58 maturity: Maturity.WEB_STABLE, | |
59 documented: false, | |
60 implementation: true), | |
61 | |
62 "indexed_db": const LibraryInfo( | |
63 "indexed_db/dart2js/indexed_db_dart2js.dart", | |
64 category: "Client", | |
65 maturity: Maturity.WEB_STABLE), | |
66 | |
67 "io": const LibraryInfo( | |
68 "io/io.dart", | |
69 category: "Server", | |
70 maturity: Maturity.STABLE, | |
71 dart2jsPatchPath: "_internal/compiler/js_lib/io_patch.dart"), | |
72 | |
73 "isolate": const LibraryInfo( | |
74 "isolate/isolate.dart", | |
75 maturity: Maturity.STABLE, | |
76 dart2jsPatchPath: "_internal/compiler/js_lib/isolate_patch.dart"), | |
77 | |
78 "js": const LibraryInfo( | |
79 "js/dartium/js_dartium.dart", | |
80 category: "Client", | |
81 maturity: Maturity.STABLE, | |
82 dart2jsPath: "js/dart2js/js_dart2js.dart"), | |
83 | |
84 "js_util": const LibraryInfo( | |
85 "js_util/dartium/js_util_dartium.dart", | |
86 categories: "Client", | |
87 maturity: Maturity.STABLE, | |
88 dart2jsPath: "js_util/dart2js/js_util_dart2js.dart"), | |
89 | |
90 "math": const LibraryInfo( | |
91 "math/math.dart", | |
92 maturity: Maturity.STABLE, | |
93 dart2jsPatchPath: "_internal/compiler/js_lib/math_patch.dart"), | |
94 | |
95 "mirrors": const LibraryInfo( | |
96 "mirrors/mirrors.dart", | |
97 maturity: Maturity.UNSTABLE, | |
98 dart2jsPatchPath: "_internal/compiler/js_lib/mirrors_patch.dart"), | |
99 | |
100 "typed_data": const LibraryInfo( | |
101 "typed_data/typed_data.dart", | |
102 maturity: Maturity.STABLE, | |
103 dart2jsPatchPath: "_internal/compiler/js_lib/typed_data_patch.dart"), | |
104 | |
105 "_native_typed_data": const LibraryInfo( | |
106 "_internal/compiler/js_lib/native_typed_data.dart", | |
107 category: "Internal", | |
108 implementation: true, | |
109 documented: false, | |
110 platforms: DART2JS_PLATFORM), | |
111 | |
112 "svg": const LibraryInfo( | |
113 "svg/dart2js/svg_dart2js.dart", | |
114 category: "Client", | |
115 maturity: Maturity.WEB_STABLE), | |
116 | |
117 "web_audio": const LibraryInfo( | |
118 "web_audio/dart2js/web_audio_dart2js.dart", | |
119 category: "Client", | |
120 maturity: Maturity.WEB_STABLE), | |
121 | |
122 "web_gl": const LibraryInfo( | |
123 "web_gl/dart2js/web_gl_dart2js.dart", | |
124 category: "Client", | |
125 maturity: Maturity.WEB_STABLE), | |
126 | |
127 "web_sql": const LibraryInfo( | |
128 "web_sql/dart2js/web_sql_dart2js.dart", | |
129 category: "Client", | |
130 maturity: Maturity.WEB_STABLE), | |
131 | |
132 "_internal": const LibraryInfo( | |
133 "internal/internal.dart", | |
134 category: "Internal", | |
135 documented: false, | |
136 dart2jsPatchPath: | |
137 "_internal/compiler/js_lib/internal_patch.dart"), | |
138 | |
139 "_js_helper": const LibraryInfo( | |
140 "_internal/compiler/js_lib/js_helper.dart", | |
141 category: "Internal", | |
142 documented: false, | |
143 platforms: DART2JS_PLATFORM), | |
144 | |
145 "_interceptors": const LibraryInfo( | |
146 "_internal/compiler/js_lib/interceptors.dart", | |
147 category: "Internal", | |
148 documented: false, | |
149 platforms: DART2JS_PLATFORM), | |
150 | |
151 "_foreign_helper": const LibraryInfo( | |
152 "_internal/compiler/js_lib/foreign_helper.dart", | |
153 category: "Internal", | |
154 documented: false, | |
155 platforms: DART2JS_PLATFORM), | |
156 | |
157 "_isolate_helper": const LibraryInfo( | |
158 "_internal/compiler/js_lib/isolate_helper.dart", | |
159 category: "Internal", | |
160 documented: false, | |
161 platforms: DART2JS_PLATFORM), | |
162 | |
163 "_js_mirrors": const LibraryInfo( | |
164 "_internal/compiler/js_lib/js_mirrors.dart", | |
165 category: "Internal", | |
166 documented: false, | |
167 platforms: DART2JS_PLATFORM), | |
168 | |
169 "_js_primitives": const LibraryInfo( | |
170 "_internal/compiler/js_lib/js_primitives.dart", | |
171 category: "Internal", | |
172 documented: false, | |
173 platforms: DART2JS_PLATFORM), | |
174 | |
175 // TODO(ahe): This library is only for dart2dart, perhaps it should use a | |
176 // different platform. | |
177 "_mirror_helper": const LibraryInfo( | |
178 "_internal/compiler/js_lib/mirror_helper.dart", | |
179 category: "Internal", | |
180 documented: false, | |
181 platforms: DART2JS_PLATFORM), | |
182 | |
183 "_js_embedded_names": const LibraryInfo( | |
184 "_internal/compiler/js_lib/shared/embedded_names.dart", | |
185 category: "Internal", | |
186 documented: false, | |
187 platforms: DART2JS_PLATFORM), | |
188 | |
189 "_metadata": const LibraryInfo( | |
190 "html/html_common/metadata.dart", | |
191 category: "Internal", | |
192 documented: false, | |
193 platforms: DART2JS_PLATFORM), | |
194 | |
195 "_runtime": const LibraryInfo( | |
196 "_internal/compiler/js_lib/ddc_runtime/runtime.dart", | |
197 category: "Internal", | |
198 documented: false, | |
199 platforms: DART2JS_PLATFORM), | |
200 | |
201 "_debugger": const LibraryInfo( | |
202 "_internal/compiler/js_lib/debugger.dart", | |
203 category: "Internal", | |
204 documented: false, | |
205 platforms: DART2JS_PLATFORM), | |
206 }; | |
207 | |
208 /** | |
209 * Information about a "dart:" library. | |
210 */ | |
211 class LibraryInfo { | |
212 | |
213 /** | |
214 * Path to the library's *.dart file relative to this file. | |
215 */ | |
216 final String path; | |
217 | |
218 /** | |
219 * The category in which the library should appear in the editor | |
220 * (e.g. "Shared", "Client", "Server", ...). | |
221 * If a category is not specified it defaults to "Shared". | |
222 */ | |
223 final String category; | |
224 | |
225 /** | |
226 * Path to the dart2js library's *.dart file relative to this file | |
227 * or null if dart2js uses the common library path defined above. | |
228 * Access using the [#getDart2JsPath()] method. | |
229 */ | |
230 final String dart2jsPath; | |
231 | |
232 /** | |
233 * Path to the dart2js library's patch file relative to this file | |
234 * or null if no dart2js patch file associated with this library. | |
235 * Access using the [#getDart2JsPatchPath()] method. | |
236 */ | |
237 final String dart2jsPatchPath; | |
238 | |
239 /** | |
240 * True if this library is documented and should be shown to the user. | |
241 */ | |
242 final bool documented; | |
243 | |
244 /** | |
245 * Bit flags indicating which platforms consume this library. | |
246 * See [DART2JS_LIBRARY] and [VM_LIBRARY]. | |
247 */ | |
248 final int platforms; | |
249 | |
250 /** | |
251 * True if the library contains implementation details for another library. | |
252 * The implication is that these libraries are less commonly used | |
253 * and that tools like Dart Editor should not show these libraries | |
254 * in a list of all libraries unless the user specifically asks the tool to | |
255 * do so. | |
256 */ | |
257 final bool implementation; | |
258 | |
259 /** | |
260 * States the current maturity of this library. | |
261 */ | |
262 final Maturity maturity; | |
263 | |
264 const LibraryInfo(this.path, { | |
265 this.category: "Shared", | |
266 this.dart2jsPath, | |
267 this.dart2jsPatchPath, | |
268 this.implementation: false, | |
269 this.documented: true, | |
270 this.maturity: Maturity.UNSPECIFIED, | |
271 this.platforms: DART2JS_PLATFORM | VM_PLATFORM}); | |
272 | |
273 bool get isDart2jsLibrary => (platforms & DART2JS_PLATFORM) != 0; | |
274 bool get isVmLibrary => (platforms & VM_PLATFORM) != 0; | |
275 } | |
276 | |
277 | |
278 | |
279 /** | |
280 * Abstraction to capture the maturity of a library. | |
281 */ | |
282 class Maturity { | |
283 final int level; | |
284 final String name; | |
285 final String description; | |
286 | |
287 const Maturity(this.level, this.name, this.description); | |
288 | |
289 String toString() => "$name: $level\n$description\n"; | |
290 | |
291 static const Maturity DEPRECATED = const Maturity(0, "Deprecated", | |
292 "This library will be remove before next major release."); | |
293 | |
294 static const Maturity EXPERIMENTAL = const Maturity(1, "Experimental", | |
295 "This library is experimental and will likely change or be removed\n" | |
296 "in future versions."); | |
297 | |
298 static const Maturity UNSTABLE = const Maturity(2, "Unstable", | |
299 "This library is in still changing and have not yet endured\n" | |
300 "sufficient real-world testing.\n" | |
301 "Backwards-compatibility is NOT guaranteed."); | |
302 | |
303 static const Maturity WEB_STABLE = const Maturity(3, "Web Stable", | |
304 "This library is tracking the DOM evolution as defined by WC3.\n" | |
305 "Backwards-compatibility is NOT guaranteed."); | |
306 | |
307 static const Maturity STABLE = const Maturity(4, "Stable", | |
308 "The library is stable. API backwards-compatibility is guaranteed.\n" | |
309 "However implementation details might change."); | |
310 | |
311 static const Maturity LOCKED = const Maturity(5, "Locked", | |
312 "This library will not change except when serious bugs are encountered."); | |
313 | |
314 static const Maturity UNSPECIFIED = const Maturity(-1, "Unspecified", | |
315 "The maturity for this library has not been specified."); | |
316 } | |
OLD | NEW |