MCPcopy Create free account
hub / github.com/Autodesk/AutomaticComponentToolkit / diffMethod

Function diffMethod

Source/componentdiff.go:132–186  ·  view source on GitHub ↗
(path string, methodA ComponentDefinitionMethod, methodB ComponentDefinitionMethod)

Source from the content-addressed store, hash-verified

130}
131
132func diffMethod(path string, methodA ComponentDefinitionMethod, methodB ComponentDefinitionMethod) ([]ComponentDiffElementAdd, []ComponentDiffElementRemove, []ComponentDiffAttributeChange, error) {
133 changes := make([]ComponentDiffAttributeChange, 0)
134 adds := make([]ComponentDiffElementAdd, 0)
135 removes := make([]ComponentDiffElementRemove, 0)
136
137 pathA := path + "/method[@name='" + methodA.MethodName + "']"
138 pathB := path + "/method[@name='" + methodB.MethodName + "']"
139 if (methodA.MethodDescription != methodB.MethodDescription) {
140 var change ComponentDiffAttributeChange
141 change.Path = pathA + "/description"
142 change.OldValue = methodA.MethodDescription
143 change.NewValue = methodB.MethodDescription
144 changes = append(changes, change)
145 }
146
147 IFirstChangedParam := len(methodA.Params)
148 for iA, paramA := range(methodA.Params) {
149 BHasParamA := false
150 if (iA < IFirstChangedParam) && (iA < len(methodB.Params)) {
151 paramB := methodB.Params[iA]
152 if (paramA.ParamName == paramB.ParamName) {
153 Pchanges, err := diffParam(pathA, paramA, paramB)
154 if (err != nil) {
155 return adds, removes, changes, err
156 }
157 changes = append(changes, Pchanges...)
158 BHasParamA = true
159 }
160 }
161 if (!BHasParamA) {
162 IFirstChangedParam = iA
163 var remove ComponentDiffElementRemove
164 remove.Path = pathA
165 remove.Removal = paramA
166 removes = append(removes, remove)
167 }
168 }
169
170 for iB, paramB := range(methodB.Params) {
171 AHasParamB := false
172 if (iB < IFirstChangedParam) && (iB < len(methodA.Params)) {
173 paramA := methodA.Params[iB]
174 if (paramA.ParamName == paramB.ParamName) {
175 AHasParamB = true
176 }
177 }
178 if (!AHasParamB) {
179 var add ComponentDiffElementAdd
180 add.Path = pathB
181 add.Addition = paramB
182 adds = append(adds, add)
183 }
184 }
185 return adds, removes, changes, nil
186}
187
188func diffClass(path string, classA ComponentDefinitionClass, classB ComponentDefinitionClass) ([]ComponentDiffElementAdd, []ComponentDiffElementRemove, []ComponentDiffAttributeChange, error) {
189 changes := make([]ComponentDiffAttributeChange, 0)

Callers 2

diffClassFunction · 0.85
diffGlobalFunction · 0.85

Calls 1

diffParamFunction · 0.85

Tested by

no test coverage detected