Skip to content

Commit

Permalink
feat(introspector): getClassDeclarations filters map declarations (#693)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
jonathan-casey authored Aug 28, 2023
1 parent fb513bf commit 24b2515
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
10 changes: 5 additions & 5 deletions packages/concerto-core/lib/introspect/introspector.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ class Introspector {
const modelFiles = this.modelManager.getModelFiles();
for(let n=0; n < modelFiles.length; n++) {
const modelFile = modelFiles[n];
result = result.concat(
modelFile.getAllDeclarations()
.filter(declaration => !declaration.isScalarDeclaration?.()
)
);

const filteredDeclarations = modelFile.getAllDeclarations()
.filter(declaration => !declaration.isMapDeclaration?.() && !declaration.isScalarDeclaration?.());

result = result.concat(filteredDeclarations);
}
return result;
}
Expand Down
6 changes: 5 additions & 1 deletion packages/concerto-core/test/introspect/introspector.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ describe('Introspector', () => {
modelManager.addCTOModel(modelBase, 'model-base.cto');
const introspector = new Introspector(modelManager);
let classDecl = introspector.getClassDeclarations();
classDecl.length.should.equal(45);
const scalarDecl = classDecl.filter(declaration => declaration.isScalarDeclaration?.());
const mapDecl = classDecl.filter(declaration => declaration.isMapDeclaration?.());
classDecl.length.should.equal(44);
scalarDecl.length.should.equal(0);
mapDecl.length.should.equal(0);
});
});

Expand Down

0 comments on commit 24b2515

Please sign in to comment.