MCPcopy
hub / github.com/hashicorp/hcl / JustAttributes

Method JustAttributes

merged.go:99–129  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

97}
98
99func (mb mergedBodies) JustAttributes() (Attributes, Diagnostics) {
100 attrs := make(map[string]*Attribute)
101 var diags Diagnostics
102
103 for _, body := range mb {
104 thisAttrs, thisDiags := body.JustAttributes()
105
106 if len(thisDiags) != 0 {
107 diags = append(diags, thisDiags...)
108 }
109
110 for name, attr := range thisAttrs {
111 if existing := attrs[name]; existing != nil {
112 diags = diags.Append(&Diagnostic{
113 Severity: DiagError,
114 Summary: "Duplicate argument",
115 Detail: fmt.Sprintf(
116 "Argument %q was already set at %s",
117 name, existing.NameRange.String(),
118 ),
119 Subject: &attr.NameRange,
120 })
121 continue
122 }
123
124 attrs[name] = attr
125 }
126 }
127
128 return attrs, diags
129}
130
131func (mb mergedBodies) MissingItemRange() Range {
132 if len(mb) == 0 {

Callers

nothing calls this directly

Calls 3

AppendMethod · 0.95
JustAttributesMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected