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

Function diffEnum

Source/componentdiff.go:301–349  ·  view source on GitHub ↗
(path string, enumA ComponentDefinitionEnum, enumB ComponentDefinitionEnum)

Source from the content-addressed store, hash-verified

299}
300
301func diffEnum(path string, enumA ComponentDefinitionEnum, enumB ComponentDefinitionEnum) ([]ComponentDiffElementAdd, []ComponentDiffElementRemove, []ComponentDiffAttributeChange, error) {
302 changes := make([]ComponentDiffAttributeChange, 0)
303 adds := make([]ComponentDiffElementAdd, 0)
304 removes := make([]ComponentDiffElementRemove, 0)
305
306 pathA := path + "/enum[@name='"+ enumA.Name + "']"
307 pathB := path + "/enum[@name='"+ enumB.Name + "']"
308
309 for _, optionA := range(enumA.Options) {
310 BHasOptionA := false
311 for _, optionB := range(enumB.Options) {
312 if optionA.Name == optionB.Name {
313 BHasOptionA = true
314 if (optionA.Value != optionB.Value) {
315 var change ComponentDiffAttributeChange
316 change.Path = pathA + "/value"
317 change.OldValue = string(optionA.Value)
318 change.NewValue = string(optionB.Value)
319 changes = append(changes, change)
320 }
321 break;
322 }
323 }
324 if (!BHasOptionA) {
325 var remove ComponentDiffElementRemove
326 remove.Path = path
327 remove.Removal = optionA
328 removes = append(removes, remove)
329 }
330 }
331
332 for _, optionB := range(enumB.Options) {
333 AHasOptionB := false
334 for _, optionA := range(enumA.Options) {
335 if optionA.Name == optionB.Name {
336 AHasOptionB = true
337 break;
338 }
339 }
340 if (!AHasOptionB) {
341 var add ComponentDiffElementAdd
342 add.Path = pathB
343 add.Addition = enumB
344 adds = append(adds, add)
345 }
346 }
347
348 return adds, removes, changes, nil
349}
350
351
352func diffEnums(path string, enumsA[] ComponentDefinitionEnum, enumsB[] ComponentDefinitionEnum) ([]ComponentDiffElementAdd, []ComponentDiffElementRemove, []ComponentDiffAttributeChange, error) {

Callers 1

diffEnumsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected