File tree Expand file tree Collapse file tree 2 files changed +27
-3
lines changed Expand file tree Collapse file tree 2 files changed +27
-3
lines changed Original file line number Diff line number Diff line change @@ -106,13 +106,22 @@ class _Builder extends Builder {
106106 'Consider adding the following to your source file:\n\n '
107107 'library $suggest ;' );
108108 }
109- final part = computePartUrl (buildStep.inputId, outputId);
109+ contentBuffer.writeln ();
110+
111+ String part;
112+ if (_outputPartOf) {
113+ contentBuffer.writeln ('part of $name ;' );
114+ part = computePartUrl (buildStep.inputId, outputId);
115+ } else {
116+ assert (_generatedExtension.endsWith ('.g.part' ),
117+ 'in the SharedPartBuilder flow' );
118+ var finalPartId = buildStep.inputId.changeExtension ('.g.dart' );
119+ part = computePartUrl (buildStep.inputId, finalPartId);
120+ }
110121 if (! library.parts.map ((c) => c.uri).contains (part)) {
111122 // TODO: Upgrade to error in a future breaking change?
112123 log.warning ('Missing "part \' $part \' ;".' );
113124 }
114- contentBuffer.writeln ();
115- if (_outputPartOf) contentBuffer.writeln ('part of $name ;' );
116125 }
117126
118127 for (var item in generatedOutputs) {
Original file line number Diff line number Diff line change @@ -203,6 +203,21 @@ void main() {
203203 });
204204
205205 group ('SharedPartBuilder' , () {
206+ test ('warns about missing part' , () async {
207+ var srcs = _createPackageStub (testLibContent: _testLibContentNoPart);
208+ var builder =
209+ new SharedPartBuilder ([const CommentGenerator ()], 'comment' );
210+ var logs = < String > [];
211+ await testBuilder (
212+ builder,
213+ srcs,
214+ onLog: (log) {
215+ logs.add (log.message);
216+ },
217+ );
218+ expect (logs, ['Missing "part \' test_lib.g.dart\' ;".' ]);
219+ });
220+
206221 test ('outputs <partId>.g.part files' , () async {
207222 await testBuilder (
208223 new SharedPartBuilder (
You can’t perform that action at this time.
0 commit comments