Skip to content

Commit 19dc845

Browse files
committed
Suppress warnings about empty sections on base clusters or derived clusters
1 parent ae0e427 commit 19dc845

3 files changed

Lines changed: 20 additions & 1 deletion

File tree

matter/spec/attributes.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"log/slog"
55

66
"github.com/project-chip/alchemy/asciidoc"
7+
"github.com/project-chip/alchemy/internal/log"
78
"github.com/project-chip/alchemy/matter"
89
"github.com/project-chip/alchemy/matter/types"
910
)
@@ -13,6 +14,9 @@ func toAttributes(spec *Specification, d *Doc, section *asciidoc.Section, cluste
1314
ti, err = parseFirstTable(d, section)
1415
if err != nil {
1516
if err == ErrNoTableFound {
17+
if !isBaseOrDerivedCluster(cluster) {
18+
slog.Warn("no table found for attributes", slog.String("name", cluster.Name), log.Element("source", d.Path, section))
19+
}
1620
err = nil
1721
}
1822
return

matter/spec/bitmap.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ func toBitmap(d *Doc, section *asciidoc.Section, pc *parseContext, parent types.
3131

3232
if err != nil {
3333
if err == ErrNoTableFound {
34-
slog.Warn("no table found for bitmap", log.Element("source", d.Path, section), slog.String("name", bm.Name))
34+
if !isBaseOrDerivedCluster(parent) {
35+
slog.Warn("no table found for bitmap", log.Element("source", d.Path, section), slog.String("name", bm.Name))
36+
}
3537
err = nil
3638
} else {
3739
return nil, newGenericParseError(section, "failed reading bitmap %s: %w", name, err)

matter/spec/cluster.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,19 @@ func clusterNamesEquivalent(name1 string, name2 string) bool {
232232
return strings.EqualFold(name1, name2)
233233
}
234234

235+
func isBaseOrDerivedCluster(e types.Entity) bool {
236+
switch e := e.(type) {
237+
case *matter.Cluster:
238+
if text.HasCaseInsensitiveSuffix(e.Name, " Base") {
239+
return true
240+
}
241+
if e.Hierarchy != "Base" {
242+
return true
243+
}
244+
}
245+
return false
246+
}
247+
235248
func readClusterClassification(doc *Doc, name string, classification *matter.ClusterClassification, s *asciidoc.Section) error {
236249
ti, err := parseFirstTable(doc, s)
237250
if err != nil {

0 commit comments

Comments
 (0)