Parts. Support for exports from library fragments in ExportLocation.
Change-Id: I1f489dbbfe96b0d17e6b8bdb1df262d057f8a4b6 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386362 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
committed by
Commit Queue
parent
36054eeeaf
commit
ca996da11e
@@ -96,7 +96,7 @@ import 'package:meta/meta.dart';
|
||||
// TODO(scheglov): Clean up the list of implicitly analyzed files.
|
||||
class AnalysisDriver {
|
||||
/// The version of data format, should be incremented on every format change.
|
||||
static const int DATA_VERSION = 386;
|
||||
static const int DATA_VERSION = 387;
|
||||
|
||||
/// The number of exception contexts allowed to write. Once this field is
|
||||
/// zero, we stop writing any new exception contexts in this process.
|
||||
|
||||
@@ -1016,7 +1016,7 @@ class LibraryReader {
|
||||
|
||||
ExportLocation _readExportLocation() {
|
||||
return ExportLocation(
|
||||
containerIndex: _reader.readUInt30(),
|
||||
fragmentIndex: _reader.readUInt30(),
|
||||
exportIndex: _reader.readUInt30(),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -317,7 +317,7 @@ class BundleWriter {
|
||||
}
|
||||
|
||||
void _writeExportLocation(ExportLocation location) {
|
||||
_sink.writeUInt30(location.containerIndex);
|
||||
_sink.writeUInt30(location.fragmentIndex);
|
||||
_sink.writeUInt30(location.exportIndex);
|
||||
}
|
||||
|
||||
|
||||
@@ -76,39 +76,33 @@ class ExportedReferenceExported extends ExportedReference {
|
||||
}
|
||||
|
||||
class ExportLocation {
|
||||
/// The index of the container with the `export` directive, `0` means the
|
||||
/// library itself, a positive value means a `+1` index in the library
|
||||
/// augmentations.
|
||||
final int containerIndex;
|
||||
/// The index of the fragment with the `export` directive, `0` means the
|
||||
/// library file, a positive value means an included fragment.
|
||||
final int fragmentIndex;
|
||||
|
||||
/// The index in [LibraryElementImpl.libraryExports].
|
||||
final int exportIndex;
|
||||
|
||||
ExportLocation({
|
||||
required this.containerIndex,
|
||||
required this.fragmentIndex,
|
||||
required this.exportIndex,
|
||||
});
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return other is ExportLocation &&
|
||||
other.containerIndex == containerIndex &&
|
||||
other.fragmentIndex == fragmentIndex &&
|
||||
other.exportIndex == exportIndex;
|
||||
}
|
||||
|
||||
LibraryExportElementImpl exportOf(LibraryElementImpl library) {
|
||||
// TODO(scheglov): support for exports from parts
|
||||
assert(containerIndex == 0);
|
||||
return library.libraryExports[exportIndex];
|
||||
// var container = containerIndex == 0
|
||||
// ? library
|
||||
// : library.augmentations[containerIndex - 1];
|
||||
// return container.libraryExports[exportIndex];
|
||||
var fragment = library.units[fragmentIndex];
|
||||
return fragment.libraryExports[exportIndex];
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return '($containerIndex, $exportIndex)';
|
||||
return '($fragmentIndex, $exportIndex)';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -142,7 +142,7 @@ class LibraryBuilder with MacroApplicationsContainer {
|
||||
var export = Export(
|
||||
exporter: this,
|
||||
location: ExportLocation(
|
||||
containerIndex: fragmentIndex,
|
||||
fragmentIndex: fragmentIndex,
|
||||
exportIndex: exportIndex,
|
||||
),
|
||||
combinators: combinators,
|
||||
|
||||
@@ -330,6 +330,27 @@ void f() {
|
||||
]);
|
||||
}
|
||||
|
||||
test_notDeprecated_class_exportedFromPart() async {
|
||||
newFile('$testPackageLibPath/a.dart', r'''
|
||||
class A {}
|
||||
''');
|
||||
|
||||
newFile('$testPackageLibPath/b.dart', r'''
|
||||
part of 'c.dart';
|
||||
export 'a.dart';
|
||||
''');
|
||||
|
||||
newFile('$testPackageLibPath/c.dart', r'''
|
||||
part 'b.dart';
|
||||
''');
|
||||
|
||||
await assertNoErrorsInCode('''
|
||||
import 'c.dart';
|
||||
|
||||
void f(A a) {}
|
||||
''');
|
||||
}
|
||||
|
||||
test_notDeprecated_class_hasDirectImport() async {
|
||||
newFile('$testPackageLibPath/a.dart', r'''
|
||||
class A {}
|
||||
|
||||
Reference in New Issue
Block a user