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

Function diffClass

Source/componentdiff.go:188–251  ·  view source on GitHub ↗
(path string, classA ComponentDefinitionClass, classB ComponentDefinitionClass)

Source from the content-addressed store, hash-verified

186}
187
188func diffClass(path string, classA ComponentDefinitionClass, classB ComponentDefinitionClass) ([]ComponentDiffElementAdd, []ComponentDiffElementRemove, []ComponentDiffAttributeChange, error) {
189 changes := make([]ComponentDiffAttributeChange, 0)
190 adds := make([]ComponentDiffElementAdd, 0)
191 removes := make([]ComponentDiffElementRemove, 0)
192
193 pathA := path + "/class[@name='"+ classA.ClassName + "']"
194 pathB := path + "/class[@name='"+ classB.ClassName + "']"
195 if (classA.ClassDescription != classB.ClassDescription) {
196 var change ComponentDiffAttributeChange
197 change.Path = pathA + "/description"
198 change.OldValue = classA.ClassDescription
199 change.NewValue = classB.ClassDescription
200 changes = append(changes, change)
201 }
202
203 if (classA.ParentClass != classB.ParentClass) {
204 var change ComponentDiffAttributeChange
205 change.Path = pathA + "/parent"
206 change.OldValue = classA.ParentClass
207 change.NewValue = classB.ParentClass
208 changes = append(changes, change)
209 }
210
211 for _, methodA := range(classA.Methods) {
212 BHasMethodA := false
213 for _, methodB := range(classB.Methods) {
214 if methodA.MethodName == methodB.MethodName {
215 BHasMethodA = true
216 Madds, Mremoves, Mchanges, err := diffMethod(pathA, methodA, methodB)
217 if (err != nil) {
218 return adds, removes, changes, err
219 }
220 adds = append(adds, Madds...)
221 removes = append(removes, Mremoves...)
222 changes = append(changes, Mchanges...)
223 break;
224 }
225 }
226 if (!BHasMethodA) {
227 var remove ComponentDiffElementRemove
228 remove.Path = path
229 remove.Removal = methodA
230 removes = append(removes, remove)
231 }
232 }
233
234 for _, methodB := range(classB.Methods) {
235 AHasMethodB := false
236 for _, methodA := range(classA.Methods) {
237 if methodA.MethodName == methodB.MethodName {
238 AHasMethodB = true
239 break;
240 }
241 }
242 if (!AHasMethodB) {
243 var add ComponentDiffElementAdd
244 add.Path = pathB
245 add.Addition = methodB

Callers 1

diffClassesFunction · 0.85

Calls 1

diffMethodFunction · 0.85

Tested by

no test coverage detected