Skip to content

Commit 24b2515

Browse files
feat(introspector): getClassDeclarations filters map declarations (#693)
* feat(maps): getClassDeclarations filters map declarations Signed-off-by: jonathan.casey <[email protected]> * feat(maps): optimize on filter Signed-off-by: jonathan.casey <[email protected]> --------- Signed-off-by: jonathan.casey <[email protected]>
1 parent fb513bf commit 24b2515

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

packages/concerto-core/lib/introspect/introspector.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ class Introspector {
5959
const modelFiles = this.modelManager.getModelFiles();
6060
for(let n=0; n < modelFiles.length; n++) {
6161
const modelFile = modelFiles[n];
62-
result = result.concat(
63-
modelFile.getAllDeclarations()
64-
.filter(declaration => !declaration.isScalarDeclaration?.()
65-
)
66-
);
62+
63+
const filteredDeclarations = modelFile.getAllDeclarations()
64+
.filter(declaration => !declaration.isMapDeclaration?.() && !declaration.isScalarDeclaration?.());
65+
66+
result = result.concat(filteredDeclarations);
6767
}
6868
return result;
6969
}

packages/concerto-core/test/introspect/introspector.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,11 @@ describe('Introspector', () => {
5656
modelManager.addCTOModel(modelBase, 'model-base.cto');
5757
const introspector = new Introspector(modelManager);
5858
let classDecl = introspector.getClassDeclarations();
59-
classDecl.length.should.equal(45);
59+
const scalarDecl = classDecl.filter(declaration => declaration.isScalarDeclaration?.());
60+
const mapDecl = classDecl.filter(declaration => declaration.isMapDeclaration?.());
61+
classDecl.length.should.equal(44);
62+
scalarDecl.length.should.equal(0);
63+
mapDecl.length.should.equal(0);
6064
});
6165
});
6266

0 commit comments

Comments
 (0)