diff --git a/packages/concerto-analysis/src/compare-config.ts b/packages/concerto-analysis/src/compare-config.ts index 511f660dc..25581c9c5 100644 --- a/packages/concerto-analysis/src/compare-config.ts +++ b/packages/concerto-analysis/src/compare-config.ts @@ -53,6 +53,8 @@ export const defaultCompareConfig: CompareConfig = { 'optional-property-added': CompareResult.PATCH, 'required-property-removed': CompareResult.MAJOR, 'optional-property-removed': CompareResult.MAJOR, + 'class-declaration-abstract-to-concrete': CompareResult.MINOR, + 'class-declaration-concrete-to-abstract': CompareResult.MAJOR, 'namespace-changed': CompareResult.ERROR, 'enum-value-added': CompareResult.PATCH, 'enum-value-removed': CompareResult.MAJOR, diff --git a/packages/concerto-analysis/src/comparers/class-declarations.ts b/packages/concerto-analysis/src/comparers/class-declarations.ts index 9da52b59b..a00190a70 100644 --- a/packages/concerto-analysis/src/comparers/class-declarations.ts +++ b/packages/concerto-analysis/src/comparers/class-declarations.ts @@ -54,11 +54,25 @@ const classDeclarationTypeChanged: ComparerFactory = (context) => ({ if (aType === bType) { return; } - context.report({ - key: 'class-declaration-type-changed', - message: `The ${aType} "${a.getName()}" changed type from ${aType} to ${bType}`, - element: a - }); + if(aType !== bType){ + context.report({ + key: `class-declaration-type-changed`, + message: `The ${aType} "${a.getName()}" changed from ${aType} to ${bType}`, + element: a + }); + } + + //add Logic for abstractness changes + const isAbstract = (declaration) => declaration.isAbstract(); + if (isAbstract(a) !== isAbstract(b)) { + const changeType = isAbstract(a) ? 'abstract to concrete' : 'concrete to abstract'; + const changeKey =isAbstract(a) ? `class-declaration-abstract-to-concrete` : `class-declaration-concrete-to-abstract`; + context.report({ + key: changeKey, + message: `The class "${a.getName()}" changed from ${changeType}.`, + element: a + }); + } } });