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

Function diffClasses

Source/componentdiff.go:254–299  ·  view source on GitHub ↗
(path string, classesA[] ComponentDefinitionClass, classesB[] ComponentDefinitionClass)

Source from the content-addressed store, hash-verified

252
253
254func diffClasses(path string, classesA[] ComponentDefinitionClass, classesB[] ComponentDefinitionClass) ([]ComponentDiffElementAdd, []ComponentDiffElementRemove, []ComponentDiffAttributeChange, error) {
255 changes := make([]ComponentDiffAttributeChange, 0)
256 adds := make([]ComponentDiffElementAdd, 0)
257 removes := make([]ComponentDiffElementRemove, 0)
258
259 for _, classA := range(classesA) {
260 BHasClassA := false
261 for _, classB := range(classesB) {
262 if classA.ClassName == classB.ClassName {
263 BHasClassA = true
264 Cadds, Cremoves, Cchanges, err := diffClass(path, classA, classB)
265 if (err != nil) {
266 return adds, removes, changes, err
267 }
268 adds = append(adds, Cadds...)
269 removes = append(removes, Cremoves...)
270 changes = append(changes, Cchanges...)
271 break;
272 }
273 }
274 if (!BHasClassA) {
275 var remove ComponentDiffElementRemove
276 remove.Path = path
277 remove.Removal = classA
278 removes = append(removes, remove)
279 }
280 }
281
282 for _, classB := range(classesB) {
283 AHasClassB := false
284 for _, classA := range(classesA) {
285 if classB.ClassName == classA.ClassName {
286 AHasClassB = true
287 break;
288 }
289 }
290 if (!AHasClassB) {
291 var add ComponentDiffElementAdd
292 add.Path = path
293 add.Addition = classB
294 adds = append(adds, add)
295 }
296 }
297
298 return adds, removes, changes, nil
299}
300
301func diffEnum(path string, enumA ComponentDefinitionEnum, enumB ComponentDefinitionEnum) ([]ComponentDiffElementAdd, []ComponentDiffElementRemove, []ComponentDiffAttributeChange, error) {
302 changes := make([]ComponentDiffAttributeChange, 0)

Callers 1

DiffComponentDefinitionsFunction · 0.85

Calls 1

diffClassFunction · 0.85

Tested by

no test coverage detected