OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 serialization.elements; | 5 library serialization.elements; |
6 | 6 |
7 import 'dart:convert'; | 7 import 'dart:convert'; |
8 | 8 |
9 import 'package:analyzer/dart/ast/ast.dart'; | 9 import 'package:analyzer/dart/ast/ast.dart'; |
10 import 'package:analyzer/dart/element/element.dart'; | 10 import 'package:analyzer/dart/element/element.dart'; |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 */ | 131 */ |
132 static const int currentMinorVersion = 0; | 132 static const int currentMinorVersion = 0; |
133 | 133 |
134 final List<String> _linkedLibraryUris = <String>[]; | 134 final List<String> _linkedLibraryUris = <String>[]; |
135 final List<LinkedLibraryBuilder> _linkedLibraries = <LinkedLibraryBuilder>[]; | 135 final List<LinkedLibraryBuilder> _linkedLibraries = <LinkedLibraryBuilder>[]; |
136 final List<String> _unlinkedUnitUris = <String>[]; | 136 final List<String> _unlinkedUnitUris = <String>[]; |
137 final List<UnlinkedUnitBuilder> _unlinkedUnits = <UnlinkedUnitBuilder>[]; | 137 final List<UnlinkedUnitBuilder> _unlinkedUnits = <UnlinkedUnitBuilder>[]; |
138 final List<String> _unlinkedUnitHashes = <String>[]; | 138 final List<String> _unlinkedUnitHashes = <String>[]; |
139 | 139 |
140 /** | 140 /** |
| 141 * Add a fallback library to the package bundle, corresponding to the library |
| 142 * whose defining compilation unit is located at [source]. Caller must also |
| 143 * call [addFallbackUnit] for all compilation units contained in the library |
| 144 * (including the defining compilation unit). |
| 145 */ |
| 146 void addFallbackLibrary(Source source) { |
| 147 String uri = source.uri.toString(); |
| 148 _linkedLibraryUris.add(uri); |
| 149 _linkedLibraries.add(new LinkedLibraryBuilder(fallbackMode: true)); |
| 150 } |
| 151 |
| 152 /** |
| 153 * Add a fallback compilation unit to the package bundle, corresponding to |
| 154 * the compilation unit located at [source]. |
| 155 */ |
| 156 void addFallbackUnit(Source source) { |
| 157 String uri = source.uri.toString(); |
| 158 _unlinkedUnitUris.add(uri); |
| 159 _unlinkedUnits |
| 160 .add(new UnlinkedUnitBuilder(fallbackModePath: source.fullName)); |
| 161 } |
| 162 |
| 163 /** |
141 * Assemble a new [PackageBundleBuilder] using the gathered information. | 164 * Assemble a new [PackageBundleBuilder] using the gathered information. |
142 */ | 165 */ |
143 PackageBundleBuilder assemble() { | 166 PackageBundleBuilder assemble() { |
144 return new PackageBundleBuilder( | 167 return new PackageBundleBuilder( |
145 linkedLibraryUris: _linkedLibraryUris, | 168 linkedLibraryUris: _linkedLibraryUris, |
146 linkedLibraries: _linkedLibraries, | 169 linkedLibraries: _linkedLibraries, |
147 unlinkedUnitUris: _unlinkedUnitUris, | 170 unlinkedUnitUris: _unlinkedUnitUris, |
148 unlinkedUnits: _unlinkedUnits, | 171 unlinkedUnits: _unlinkedUnits, |
149 unlinkedUnitHashes: _unlinkedUnitHashes, | 172 unlinkedUnitHashes: _unlinkedUnitHashes, |
150 majorVersion: currentMajorVersion, | 173 majorVersion: currentMajorVersion, |
(...skipping 1429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1580 exportNames.add(new LinkedExportNameBuilder( | 1603 exportNames.add(new LinkedExportNameBuilder( |
1581 name: name, | 1604 name: name, |
1582 dependency: serializeDependency(dependentLibrary), | 1605 dependency: serializeDependency(dependentLibrary), |
1583 unit: unit, | 1606 unit: unit, |
1584 kind: kind)); | 1607 kind: kind)); |
1585 } | 1608 } |
1586 pb.exportNames = exportNames; | 1609 pb.exportNames = exportNames; |
1587 return pb; | 1610 return pb; |
1588 } | 1611 } |
1589 } | 1612 } |
OLD | NEW |