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