4
4
5
5
#library ('libraries' );
6
6
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
+
7
17
/**
8
18
* Mapping of "dart:" library name (e.g. "core") to information about that library.
9
19
* This information is structured such that Dart Editor can parse this file
@@ -15,11 +25,14 @@ final Map<String, LibraryInfo> LIBRARIES = const <LibraryInfo> {
15
25
// Used by VM applications
16
26
"builtin" : const LibraryInfo (
17
27
"builtin/builtin_runtime.dart" ,
18
- category: "Server" ),
28
+ category: "Server" ,
29
+ platforms: VM_PLATFORM ),
19
30
31
+ // Is moving to pkg directory
20
32
"compiler" : const LibraryInfo (
21
33
"compiler/compiler.dart" ,
22
- category: "Tools" ),
34
+ category: "Tools" ,
35
+ platforms: 0 ),
23
36
24
37
"core" : const LibraryInfo (
25
38
"core/core_runtime.dart" ,
@@ -37,8 +50,9 @@ final Map<String, LibraryInfo> LIBRARIES = const <LibraryInfo> {
37
50
// dom/dom_frog.dart is a placeholder for dartium dom
38
51
"dom_deprecated" : const LibraryInfo (
39
52
"dom/dom_dart2js.dart" ,
53
+ implementation: true ,
40
54
dart2jsPath: "dom/dart2js/dom_dart2js.dart" ,
41
- internal : true ),
55
+ documented : false ),
42
56
43
57
"html" : const LibraryInfo (
44
58
"html/html_dartium.dart" ,
@@ -67,11 +81,9 @@ final Map<String, LibraryInfo> LIBRARIES = const <LibraryInfo> {
67
81
"nativewrappers" : const LibraryInfo (
68
82
"html/nativewrappers.dart" ,
69
83
category: "Client" ,
70
- implementation: true ),
71
-
72
- "unittest" : const LibraryInfo (
73
- "unittest/unittest.dart" ,
74
- category: "Tools" ),
84
+ implementation: true ,
85
+ documented: false ,
86
+ platforms: VM_PLATFORM ),
75
87
76
88
"uri" : const LibraryInfo (
77
89
"uri/uri.dart" ),
@@ -86,13 +98,15 @@ final Map<String, LibraryInfo> LIBRARIES = const <LibraryInfo> {
86
98
"_js_helper" : const LibraryInfo (
87
99
"compiler/implementation/lib/js_helper.dart" ,
88
100
category: "Internal" ,
89
- internal: true ),
101
+ documented: false ,
102
+ platforms: DART2JS_PLATFORM ),
90
103
91
104
// Used by dart2js
92
105
"_interceptors" : const LibraryInfo (
93
106
"compiler/implementation/lib/interceptors.dart" ,
94
107
category: "Internal" ,
95
- internal: true ),
108
+ documented: false ,
109
+ platforms: DART2JS_PLATFORM ),
96
110
};
97
111
98
112
/**
@@ -114,19 +128,27 @@ class LibraryInfo {
114
128
/**
115
129
* Path to the dart2js library's *.dart file relative to this file
116
130
* or null if dart2js uses the common library path defined above.
131
+ * Access using the [#getDart2JsPath()] method.
117
132
*/
118
133
final String dart2jsPath;
119
134
120
135
/**
121
136
* Path to the dart2js library's patch file relative to this file
122
137
* or null if no dart2js patch file associated with this library.
138
+ * Access using the [#getDart2JsPatchPath()] method.
123
139
*/
124
140
final String dart2jsPatchPath;
125
141
126
142
/**
127
- * True if this library is internal and should not be shown to the user
143
+ * True if this library is documented and should be shown to the user
128
144
*/
129
- final bool internal;
145
+ final bool documented;
146
+
147
+ /**
148
+ * Bit flags indicating which platforms consume this library
149
+ * See [DART2JS_LIBRARY] and [VM_LIBRARY]
150
+ */
151
+ final int platforms;
130
152
131
153
/**
132
154
* True if the library contains implementation details for another library.
@@ -137,7 +159,17 @@ class LibraryInfo {
137
159
*/
138
160
final bool implementation;
139
161
140
- const LibraryInfo (this .path, [this .category = "Shared" ,
141
- this .dart2jsPath, this .dart2jsPatchPath,
142
- this .implementation = false , this .internal = false ]);
162
+ const LibraryInfo (this .path, [
163
+ this .category = "Shared" ,
164
+ this .dart2jsPath,
165
+ this .dart2jsPatchPath,
166
+ this .implementation = false ,
167
+ this .documented = true ,
168
+ this .platforms = DART2JS_PLATFORM | VM_PLATFORM ]);
169
+
170
+ bool isDart2JsLibrary () => (platforms & DART2JS_PLATFORM ) != 0 ;
171
+ bool isVmLibrary () => (platforms & VM_PLATFORM ) != 0 ;
172
+
173
+ String getDart2JsPath () => dart2jsPath != null ? "lib/$dart2jsPath " : "lib/$path " ;
174
+ String getDart2jsPatchPath () => dart2jsPatchPath != null ? "lib/$dart2jsPatchPath " : null ;
143
175
}
0 commit comments