@@ -321,23 +321,15 @@ func (*Interface) WITKind() string { return "interface" }
321
321
//
322
322
// [WIT]: https://github.com/WebAssembly/component-model/blob/main/design/mvp/WIT.md
323
323
func (i * Interface ) WIT (ctx Node , name string ) string {
324
+ // filter, _ := ctx.(*witFilter)
325
+
324
326
if i .Name != nil && name == "" {
325
327
name = * i .Name
326
328
}
327
329
328
330
var b strings.Builder
329
331
330
332
switch ctx := ctx .(type ) {
331
- case * Package :
332
- b .WriteString (i .Docs .WIT (ctx , "" ))
333
- if i .Stability != nil {
334
- b .WriteString (i .Stability .WIT (ctx , "" ))
335
- b .WriteRune ('\n' )
336
- }
337
- b .WriteString ("interface " )
338
- b .WriteString (escape (name ))
339
- b .WriteRune (' ' )
340
-
341
333
case worldImport :
342
334
rname := relativeName (i , ctx .Package )
343
335
if rname != "" {
@@ -361,13 +353,26 @@ func (i *Interface) WIT(ctx Node, name string) string {
361
353
b .WriteString ("export " )
362
354
b .WriteString (escape (name ))
363
355
b .WriteString (": interface " )
356
+
357
+ default : // e.g. *Package
358
+ b .WriteString (i .Docs .WIT (ctx , "" ))
359
+ if i .Stability != nil {
360
+ b .WriteString (i .Stability .WIT (ctx , "" ))
361
+ b .WriteRune ('\n' )
362
+ }
363
+ b .WriteString ("interface " )
364
+ b .WriteString (escape (name ))
365
+ b .WriteRune (' ' )
364
366
}
365
367
366
368
b .WriteRune ('{' )
367
369
n := 0
368
370
369
371
// Emit use statements first
370
372
i .TypeDefs .All ()(func (name string , td * TypeDef ) bool {
373
+ // if filter.filter(td) {
374
+ // return true
375
+ // }
371
376
if td .Root ().Owner == td .Owner {
372
377
return true // Skip declarations
373
378
}
@@ -382,6 +387,9 @@ func (i *Interface) WIT(ctx Node, name string) string {
382
387
383
388
// Declarations
384
389
i .TypeDefs .All ()(func (name string , td * TypeDef ) bool {
390
+ // if filter.filter(td) {
391
+ // return true
392
+ // }
385
393
if td .Root ().Owner != td .Owner {
386
394
return true // Skip use statements
387
395
}
@@ -396,6 +404,9 @@ func (i *Interface) WIT(ctx Node, name string) string {
396
404
397
405
// Functions
398
406
i .Functions .All ()(func (name string , f * Function ) bool {
407
+ // if filter.filter(f) {
408
+ // return true
409
+ // }
399
410
if ! f .IsFreestanding () {
400
411
return true
401
412
}
@@ -1126,9 +1137,9 @@ func (p *Package) WIT(ctx Node, name string) string {
1126
1137
}
1127
1138
b .WriteRune ('\n' )
1128
1139
if multi {
1129
- b .WriteString (indent (face .WIT (p , name )))
1140
+ b .WriteString (indent (face .WIT (ctx , name )))
1130
1141
} else {
1131
- b .WriteString (face .WIT (p , name ))
1142
+ b .WriteString (face .WIT (ctx , name ))
1132
1143
}
1133
1144
b .WriteRune ('\n' )
1134
1145
i ++
@@ -1140,9 +1151,9 @@ func (p *Package) WIT(ctx Node, name string) string {
1140
1151
}
1141
1152
b .WriteRune ('\n' )
1142
1153
if multi {
1143
- b .WriteString (indent (w .WIT (filter , name )))
1154
+ b .WriteString (indent (w .WIT (ctx , name )))
1144
1155
} else {
1145
- b .WriteString (w .WIT (filter , name ))
1156
+ b .WriteString (w .WIT (ctx , name ))
1146
1157
}
1147
1158
b .WriteRune ('\n' )
1148
1159
i ++
0 commit comments