File tree 2 files changed +27
-3
lines changed
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 {
106
106
'Consider adding the following to your source file:\n\n '
107
107
'library $suggest ;' );
108
108
}
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
+ }
110
121
if (! library.parts.map ((c) => c.uri).contains (part)) {
111
122
// TODO: Upgrade to error in a future breaking change?
112
123
log.warning ('Missing "part \' $part \' ;".' );
113
124
}
114
- contentBuffer.writeln ();
115
- if (_outputPartOf) contentBuffer.writeln ('part of $name ;' );
116
125
}
117
126
118
127
for (var item in generatedOutputs) {
Original file line number Diff line number Diff line change @@ -203,6 +203,21 @@ void main() {
203
203
});
204
204
205
205
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
+
206
221
test ('outputs <partId>.g.part files' , () async {
207
222
await testBuilder (
208
223
new SharedPartBuilder (
You can’t perform that action at this time.
0 commit comments