Skip to content

Allow libraries without a '.dart' ending #1900

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jan 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/src/model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6516,7 +6516,9 @@ class PackageBuilder {
}
}
var sourceKind = await driver.getSourceKind(filePath);
if (sourceKind == SourceKind.LIBRARY) {
// Allow dart source files with inappropriate suffixes (#1897). Those
// do not show up as SourceKind.LIBRARY.
if (sourceKind != SourceKind.PART) {
// Loading libraryElements from part files works, but is painfully slow
// and creates many duplicates.
return await driver.currentSession.getResolvedLibrary(source.fullName);
Expand Down
4 changes: 4 additions & 0 deletions test/model_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,10 @@ void main() {
expect(anonLib.isDeprecated, isFalse);
});

test('can be reexported even if the file suffix is not .dart', () {
expect(fakeLibrary.allClasses.map((c) => c.name), contains('MyClassFromADartFile'));
});

test('that is deprecated has a deprecated css class in linkedName', () {
expect(isDeprecated.linkedName, contains('class="deprecated"'));
});
Expand Down
1 change: 1 addition & 0 deletions testing/test_package/lib/fake.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import 'example.dart';
import 'mylibpub.dart' as renamedLib;
import 'mylibpub.dart' as renamedLib2;
import 'two_exports.dart' show BaseClass;
export 'src/notadotdartfile';

// ignore: uri_does_not_exist
export 'package:test_package_imported/categoryExporting.dart'
Expand Down
4 changes: 4 additions & 0 deletions testing/test_package/lib/src/notadotdartfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/// Test importing with an invalid dart file extension. (#1897)
library test_package.notadotdartfile;

class MyClassFromADartFile {}