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

Function DiffComponentDefinitions

Source/componentdiff.go:712–765  ·  view source on GitHub ↗

DiffComponentDefinitions generates a diff D = B - A between component definitions A and B such that A + D = B

(A ComponentDefinition, B ComponentDefinition)

Source from the content-addressed store, hash-verified

710
711// DiffComponentDefinitions generates a diff D = B - A between component definitions A and B such that A + D = B
712func DiffComponentDefinitions(A ComponentDefinition, B ComponentDefinition) (ComponentDiff, error) {
713 var diff ComponentDiff
714
715 path := "/component"
716
717 changes, err := diffComponentAttributes(path, A, B)
718 if (err != nil) {
719 return diff, err
720 }
721
722 // TODO: check license
723 // TODO: check bindings(!?)
724
725 adds, removes, changes, err := diffGlobal(path, A.Global, B.Global)
726 if (err != nil) {
727 return diff, err
728 }
729 diff.ElementAdditions = append(diff.ElementAdditions, adds...)
730 diff.ElementRemovals = append(diff.ElementRemovals, removes...)
731 diff.AttributeChanges = append(diff.AttributeChanges, changes...)
732
733 adds, removes, changes, err = diffClasses(path, A.Classes, B.Classes)
734 if (err != nil) {
735 return diff, err
736 }
737 diff.ElementAdditions = append(diff.ElementAdditions, adds...)
738 diff.ElementRemovals = append(diff.ElementRemovals, removes...)
739 diff.AttributeChanges = append(diff.AttributeChanges, changes...)
740
741 adds, removes, changes, err = diffEnums(path, A.Enums, B.Enums)
742 if (err != nil) {
743 return diff, err
744 }
745 diff.ElementAdditions = append(diff.ElementAdditions, adds...)
746 diff.ElementRemovals = append(diff.ElementRemovals, removes...)
747 diff.AttributeChanges = append(diff.AttributeChanges, changes...)
748
749 adds, removes, changes, err = diffErrors(path + "/Errors", A.Errors.Errors, B.Errors.Errors)
750 if (err != nil) {
751 return diff, err
752 }
753 diff.ElementAdditions = append(diff.ElementAdditions, adds...)
754 diff.ElementRemovals = append(diff.ElementRemovals, removes...)
755 diff.AttributeChanges = append(diff.AttributeChanges, changes...)
756
757 adds, removes, changes, err = diffStructs(path, A.Structs, B.Structs)
758 if (err != nil) {
759 return diff, err
760 }
761 diff.ElementAdditions = append(diff.ElementAdditions, adds...)
762 diff.ElementRemovals = append(diff.ElementRemovals, removes...)
763 diff.AttributeChanges = append(diff.AttributeChanges, changes...)
764 return diff, nil
765}

Callers 1

mainFunction · 0.85

Calls 6

diffComponentAttributesFunction · 0.85
diffGlobalFunction · 0.85
diffClassesFunction · 0.85
diffEnumsFunction · 0.85
diffErrorsFunction · 0.85
diffStructsFunction · 0.85

Tested by

no test coverage detected