OLD | NEW |
---|---|
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 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 | 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('libraries'); | 5 #library('libraries'); |
6 | 6 |
7 /** | 7 /** |
8 * A bit flag used by [LibraryInfo] indicating that a library is used by dart2js | |
9 */ | |
10 final int DART2JS_PLATFORM = 1; | |
11 | |
12 /** | |
13 * A bit flag used by [LibraryInfo] indicating that a library is used by the VM | |
14 */ | |
15 final int VM_PLATFORM = 2; | |
16 | |
17 /** | |
8 * Mapping of "dart:" library name (e.g. "core") to information about that libra ry. | 18 * Mapping of "dart:" library name (e.g. "core") to information about that libra ry. |
9 * This information is structured such that Dart Editor can parse this file | 19 * This information is structured such that Dart Editor can parse this file |
10 * and extract the necessary information without executing it | 20 * and extract the necessary information without executing it |
11 * while other tools can access via execution. | 21 * while other tools can access via execution. |
12 */ | 22 */ |
13 final Map<String, LibraryInfo> LIBRARIES = const <LibraryInfo> { | 23 final Map<String, LibraryInfo> LIBRARIES = const <LibraryInfo> { |
14 | 24 |
15 // Used by VM applications | 25 // Used by VM applications |
16 "builtin": const LibraryInfo( | 26 "builtin": const LibraryInfo( |
17 "builtin/builtin_runtime.dart", | 27 "builtin/builtin_runtime.dart", |
18 category: "Server"), | 28 category: "Server", |
29 platforms: VM_PLATFORM), | |
19 | 30 |
31 // Is moving to pkg directory | |
20 "compiler": const LibraryInfo( | 32 "compiler": const LibraryInfo( |
21 "compiler/compiler.dart", | 33 "compiler/compiler.dart", |
22 category: "Tools"), | 34 category: "Tools", |
35 platforms: 0), | |
23 | 36 |
24 "core": const LibraryInfo( | 37 "core": const LibraryInfo( |
25 "core/core_runtime.dart", | 38 "core/core_runtime.dart", |
26 dart2jsPath: "compiler/implementation/lib/core.dart"), | 39 dart2jsPath: "compiler/implementation/lib/core.dart"), |
27 | 40 |
28 "coreimpl": const LibraryInfo( | 41 "coreimpl": const LibraryInfo( |
29 "coreimpl/coreimpl_runtime.dart", | 42 "coreimpl/coreimpl_runtime.dart", |
30 implementation: true, | 43 implementation: true, |
31 dart2jsPath: "compiler/implementation/lib/coreimpl.dart", | 44 dart2jsPath: "compiler/implementation/lib/coreimpl.dart", |
32 dart2jsPatchPath: "compiler/implementation/lib/coreimpl.dartp"), | 45 dart2jsPatchPath: "compiler/implementation/lib/coreimpl.dartp"), |
33 | 46 |
34 "crypto": const LibraryInfo( | 47 "crypto": const LibraryInfo( |
35 "crypto/crypto.dart"), | 48 "crypto/crypto.dart"), |
36 | 49 |
37 // dom/dom_frog.dart is a placeholder for dartium dom | 50 // dom/dom_frog.dart is a placeholder for dartium dom |
38 "dom_deprecated": const LibraryInfo( | 51 "dom_deprecated": const LibraryInfo( |
39 "dom/dom_dart2js.dart", | 52 "dom/dom_dart2js.dart", |
40 dart2jsPath: "dom/dart2js/dom_dart2js.dart", | 53 dart2jsPath: "dom/dart2js/dom_dart2js.dart", |
41 internal: true), | 54 documented: false), |
42 | 55 |
43 "html": const LibraryInfo( | 56 "html": const LibraryInfo( |
44 "html/html_dartium.dart", | 57 "html/html_dartium.dart", |
45 category: "Client", | 58 category: "Client", |
46 dart2jsPath: "html/dart2js/html_dart2js.dart"), | 59 dart2jsPath: "html/dart2js/html_dart2js.dart"), |
47 | 60 |
48 "io": const LibraryInfo( | 61 "io": const LibraryInfo( |
49 "io/io_runtime.dart", | 62 "io/io_runtime.dart", |
50 category: "Server", | 63 category: "Server", |
51 dart2jsPath: "compiler/implementation/lib/io.dart"), | 64 dart2jsPath: "compiler/implementation/lib/io.dart"), |
52 | 65 |
53 "isolate": const LibraryInfo( | 66 "isolate": const LibraryInfo( |
54 "isolate/isolate.dart"), | 67 "isolate/isolate.dart"), |
55 | 68 |
56 "json": const LibraryInfo( | 69 "json": const LibraryInfo( |
57 "json/json.dart"), | 70 "json/json.dart"), |
58 | 71 |
59 "math": const LibraryInfo( | 72 "math": const LibraryInfo( |
60 "math/math.dart", | 73 "math/math.dart", |
61 dart2jsPatchPath: "compiler/implementation/lib/math.dartp"), | 74 dart2jsPatchPath: "compiler/implementation/lib/math.dartp"), |
62 | 75 |
63 "mirrors": const LibraryInfo( | 76 "mirrors": const LibraryInfo( |
64 "mirrors/mirrors.dart"), | 77 "mirrors/mirrors.dart"), |
65 | 78 |
66 // Used by Dartium applications | 79 // Used by Dartium applications |
67 "nativewrappers": const LibraryInfo( | 80 "nativewrappers": const LibraryInfo( |
68 "html/nativewrappers.dart", | 81 "html/nativewrappers.dart", |
69 category: "Client", | 82 category: "Client", |
70 implementation: true), | 83 implementation: true, |
71 | 84 platforms: VM_PLATFORM), |
keertip
2012/08/23 18:03:11
Add documented: false? Currently file shows up as
danrubel
2012/08/23 18:12:02
Good point. Done.
| |
72 "unittest": const LibraryInfo( | |
73 "unittest/unittest.dart", | |
74 category: "Tools"), | |
75 | 85 |
76 "uri": const LibraryInfo( | 86 "uri": const LibraryInfo( |
77 "uri/uri.dart"), | 87 "uri/uri.dart"), |
78 | 88 |
79 "utf": const LibraryInfo( | 89 "utf": const LibraryInfo( |
80 "utf/utf.dart"), | 90 "utf/utf.dart"), |
81 | 91 |
82 "web": const LibraryInfo( | 92 "web": const LibraryInfo( |
83 "web/web.dart"), | 93 "web/web.dart"), |
84 | 94 |
85 // Used by dart2js | 95 // Used by dart2js |
86 "_js_helper": const LibraryInfo( | 96 "_js_helper": const LibraryInfo( |
87 "compiler/implementation/lib/js_helper.dart", | 97 "compiler/implementation/lib/js_helper.dart", |
88 category: "Internal", | 98 category: "Internal", |
89 internal: true), | 99 documented: false, |
100 platforms: DART2JS_PLATFORM), | |
90 | 101 |
91 // Used by dart2js | 102 // Used by dart2js |
92 "_interceptors": const LibraryInfo( | 103 "_interceptors": const LibraryInfo( |
93 "compiler/implementation/lib/interceptors.dart", | 104 "compiler/implementation/lib/interceptors.dart", |
94 category: "Internal", | 105 category: "Internal", |
95 internal: true), | 106 documented: false, |
107 platforms: DART2JS_PLATFORM), | |
96 }; | 108 }; |
97 | 109 |
98 /** | 110 /** |
99 * Information about a "dart:" library. | 111 * Information about a "dart:" library. |
100 */ | 112 */ |
101 class LibraryInfo { | 113 class LibraryInfo { |
102 | 114 |
103 /** | 115 /** |
104 * Path to the library's *.dart file relative to this file. | 116 * Path to the library's *.dart file relative to this file. |
105 */ | 117 */ |
106 final String path; | 118 final String path; |
107 | 119 |
108 /** | 120 /** |
109 * The category in which the library should appear in the editor | 121 * The category in which the library should appear in the editor |
110 * (e.g. "Common", "Client", "Server", ...). | 122 * (e.g. "Common", "Client", "Server", ...). |
111 */ | 123 */ |
112 final String category; | 124 final String category; |
113 | 125 |
114 /** | 126 /** |
115 * Path to the dart2js library's *.dart file relative to this file | 127 * Path to the dart2js library's *.dart file relative to this file |
116 * or null if dart2js uses the common library path defined above. | 128 * or null if dart2js uses the common library path defined above. |
129 * Access using the [#getDart2JsPath()] method. | |
117 */ | 130 */ |
118 final String dart2jsPath; | 131 final String dart2jsPath; |
119 | 132 |
120 /** | 133 /** |
121 * Path to the dart2js library's patch file relative to this file | 134 * Path to the dart2js library's patch file relative to this file |
122 * or null if no dart2js patch file associated with this library. | 135 * or null if no dart2js patch file associated with this library. |
136 * Access using the [#getDart2JsPatchPath()] method. | |
123 */ | 137 */ |
124 final String dart2jsPatchPath; | 138 final String dart2jsPatchPath; |
125 | 139 |
126 /** | 140 /** |
127 * True if this library is internal and should not be shown to the user | 141 * True if this library is documented and should be shown to the user |
128 */ | 142 */ |
129 final bool internal; | 143 final bool documented; |
144 | |
145 /** | |
146 * Bit flags indicating which platforms consume this library | |
147 * See [DART2JS_LIBRARY] and [VM_LIBRARY] | |
148 */ | |
149 final int platforms; | |
130 | 150 |
131 /** | 151 /** |
132 * True if the library contains implementation details for another library. | 152 * True if the library contains implementation details for another library. |
133 * The implication is that these libraries are less commonly used | 153 * The implication is that these libraries are less commonly used |
134 * and that tools like Dart Editor should not show these libraries | 154 * and that tools like Dart Editor should not show these libraries |
135 * in a list of all libraries unless the user specifically asks the tool to do so. | 155 * in a list of all libraries unless the user specifically asks the tool to do so. |
136 * (e.g. "coreimpl" contains implementation for the "core" library). | 156 * (e.g. "coreimpl" contains implementation for the "core" library). |
137 */ | 157 */ |
138 final bool implementation; | 158 final bool implementation; |
139 | 159 |
140 const LibraryInfo(this.path, [this.category = "Shared", | 160 const LibraryInfo(this.path, [ |
141 this.dart2jsPath, this.dart2jsPatchPath, | 161 this.category = "Shared", |
142 this.implementation = false, this.internal = false]); | 162 this.dart2jsPath, |
163 this.dart2jsPatchPath, | |
164 this.implementation = false, | |
165 this.documented = true, | |
166 this.platforms = DART2JS_PLATFORM | VM_PLATFORM]); | |
167 | |
168 bool isDart2JsLibrary() => (platforms & DART2JS_PLATFORM) != 0; | |
169 bool isVmLibrary() => (platforms & VM_PLATFORM) != 0; | |
170 | |
171 String getDart2JsPath() => dart2jsPath != null ? "lib/$dart2jsPath" : "lib/$pa th"; | |
172 String getDart2jsPatchPath() => dart2jsPatchPath != null ? "lib/$dart2jsPatchP ath" : null; | |
143 } | 173 } |
OLD | NEW |