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

Function diffEnums

Source/componentdiff.go:352–397  ·  view source on GitHub ↗
(path string, enumsA[] ComponentDefinitionEnum, enumsB[] ComponentDefinitionEnum)

Source from the content-addressed store, hash-verified

350
351
352func diffEnums(path string, enumsA[] ComponentDefinitionEnum, enumsB[] ComponentDefinitionEnum) ([]ComponentDiffElementAdd, []ComponentDiffElementRemove, []ComponentDiffAttributeChange, error) {
353 changes := make([]ComponentDiffAttributeChange, 0)
354 adds := make([]ComponentDiffElementAdd, 0)
355 removes := make([]ComponentDiffElementRemove, 0)
356
357 for _, enumA := range(enumsA) {
358 BHasEnumA := false
359 for _, enumB := range(enumsB) {
360 if enumA.Name == enumB.Name {
361 BHasEnumA = true
362 Eadds, Eremoves, Echanges, err := diffEnum(path, enumA, enumB)
363 if (err != nil) {
364 return adds, removes, changes, err
365 }
366 adds = append(adds, Eadds...)
367 removes = append(removes, Eremoves...)
368 changes = append(changes, Echanges...)
369 break;
370 }
371 }
372 if (!BHasEnumA) {
373 var remove ComponentDiffElementRemove
374 remove.Path = path
375 remove.Removal = enumA
376 removes = append(removes, remove)
377 }
378 }
379
380 for _, enumB := range(enumsB) {
381 AHasEnumB := false
382 for _, enumA := range(enumsA) {
383 if enumB.Name == enumA.Name {
384 AHasEnumB = true
385 break;
386 }
387 }
388 if (!AHasEnumB) {
389 var add ComponentDiffElementAdd
390 add.Path = path
391 add.Addition = enumB
392 adds = append(adds, add)
393 }
394 }
395
396 return adds, removes, changes, nil
397}
398
399
400func diffError(path string, errorA ComponentDefinitionError, errorB ComponentDefinitionError) ([]ComponentDiffAttributeChange, error) {

Callers 1

DiffComponentDefinitionsFunction · 0.85

Calls 1

diffEnumFunction · 0.85

Tested by

no test coverage detected