Skip to content

Commit 7482c5c

Browse files
committed
wit: remove ConstrainTo
1 parent 2f83b44 commit 7482c5c

File tree

3 files changed

+0
-66
lines changed

3 files changed

+0
-66
lines changed

wit/package.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -48,24 +48,6 @@ func (p *Package) dependsOn(dep Node) bool {
4848
return done
4949
}
5050

51-
// constrainTo destructively constrains p to node.
52-
func (p *Package) constrainTo(node Node) {
53-
p.Worlds.All()(func(name string, w *World) bool {
54-
if !DependsOn(w, node) {
55-
p.Worlds.Delete(name)
56-
return true
57-
}
58-
w.constrainTo(node)
59-
return true
60-
})
61-
p.Interfaces.All()(func(name string, i *Interface) bool {
62-
if !DependsOn(node, i) {
63-
p.Interfaces.Delete(name)
64-
}
65-
return true
66-
})
67-
}
68-
6951
func comparePackages(a, b *Package) int {
7052
switch {
7153
case a == b:

wit/resolve.go

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -33,38 +33,6 @@ func (r *Resolve) Clone() *Resolve {
3333
return &c
3434
}
3535

36-
// ConstrainTo destructively modifies the contents of r to only include
37-
// the package(s), world(s), interface(s), and type(s) necessary to
38-
// represent node. The resulting [Resolve] may be used to generate
39-
// minimal WIT to represent node.
40-
// The node argument must be a member of r.
41-
// To preserve data, call Clone first.
42-
func (r *Resolve) ConstrainTo(node Node) {
43-
r.Packages = slices.DeleteFunc(r.Packages, func(pkg *Package) bool {
44-
if !DependsOn(node, pkg) && !DependsOn(pkg, node) {
45-
return true // delete
46-
}
47-
pkg.constrainTo(node)
48-
return false
49-
})
50-
51-
r.Worlds = slices.DeleteFunc(r.Worlds, func(w *World) bool {
52-
if !DependsOn(w, node) {
53-
return true // delete
54-
}
55-
w.constrainTo(node)
56-
return false
57-
})
58-
59-
r.Interfaces = slices.DeleteFunc(r.Interfaces, func(i *Interface) bool {
60-
return !DependsOn(node, i)
61-
})
62-
63-
r.TypeDefs = slices.DeleteFunc(r.TypeDefs, func(t *TypeDef) bool {
64-
return !DependsOn(node, t)
65-
})
66-
}
67-
6836
// AllFunctions returns a [sequence] that yields each [Function] in a [Resolve].
6937
// The sequence stops if yield returns false.
7038
//

wit/world.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -134,22 +134,6 @@ func (w *World) dependsOn(dep Node) bool {
134134
return done
135135
}
136136

137-
// constrainTo destructively constrains w to node.
138-
func (w *World) constrainTo(node Node) {
139-
w.Imports.All()(func(name string, i WorldItem) bool {
140-
if !DependsOn(node, i) {
141-
w.Imports.Delete(name)
142-
}
143-
return true
144-
})
145-
w.Exports.All()(func(name string, i WorldItem) bool {
146-
if !DependsOn(node, i) {
147-
w.Exports.Delete(name)
148-
}
149-
return true
150-
})
151-
}
152-
153137
// A WorldItem is any item that can be exported from or imported into a [World],
154138
// currently either an [InterfaceRef], [TypeDef], or [Function].
155139
// Any WorldItem is also a [Node].

0 commit comments

Comments
 (0)