mirror of https://github.com/AMT-Cheif/drift.git
Emit direct imports in preprocess step
This commit is contained in:
parent
7f6e22b892
commit
f8635469d4
|
@ -118,6 +118,10 @@ class DriftPreprocessor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// If there aren't any expressions to resolve we don't need to crawl and
|
||||||
|
// just use the direct imports.
|
||||||
|
seenFiles.addAll(queue);
|
||||||
}
|
}
|
||||||
|
|
||||||
final importedDartFiles =
|
final importedDartFiles =
|
||||||
|
|
|
@ -24,14 +24,19 @@ var expr_0 = const MyConverter();
|
||||||
''');
|
''');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('does not emit Dart file if no Dart expressions are used', () async {
|
test('only includes direct imports if no Dart expressions are used',
|
||||||
|
() async {
|
||||||
final backend = TestBackend.inTest({
|
final backend = TestBackend.inTest({
|
||||||
'a|lib/main.drift': '''
|
'a|lib/main.drift': '''
|
||||||
import 'foo.dart';
|
import 'foo.dart';
|
||||||
|
import '2.drift';
|
||||||
|
|
||||||
CREATE TABLE foo (
|
CREATE TABLE foo (
|
||||||
bar INTEGER NOT NULL
|
bar INTEGER NOT NULL
|
||||||
);
|
);
|
||||||
|
''',
|
||||||
|
'a|lib/2.drift': '''
|
||||||
|
import 'bar.dart';
|
||||||
''',
|
''',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -39,7 +44,7 @@ CREATE TABLE foo (
|
||||||
backend, Uri.parse('package:a/main.drift'));
|
backend, Uri.parse('package:a/main.drift'));
|
||||||
|
|
||||||
expect(result.result.declaredTablesAndViews, ['foo']);
|
expect(result.result.declaredTablesAndViews, ['foo']);
|
||||||
expect(result.temporaryDartFile, isEmpty);
|
expect(result.temporaryDartFile, "import 'package:a/foo.dart';\n");
|
||||||
});
|
});
|
||||||
|
|
||||||
test('finds nested dart imports', () async {
|
test('finds nested dart imports', () async {
|
||||||
|
|
Loading…
Reference in New Issue