Skip to content

Commit a2cab30

Browse files
committed
fix(util) pass template concept
Signed-off-by: Dan Selman <[email protected]>
1 parent 5deb491 commit a2cab30

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

packages/markdown-template/src/TemplateMarkTransformer.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,16 @@ class TemplateMarkTransformer {
4343
* @param {string} templateKind - either 'clause' or 'contract'
4444
* @param {object} [options] configuration options
4545
* @param {boolean} [options.verbose] verbose output
46-
* @returns {object} the result of parsing
46+
* @param {string} [conceptFullyQualifiedName] - the fully qualified name of the template concept
47+
* @returns {object} the result of parsing
4748
*/
48-
tokensToMarkdownTemplate(tokenStream, modelManager, templateKind, options) {
49+
tokensToMarkdownTemplate(tokenStream, modelManager, templateKind, options, conceptFullyQualifiedName) {
4950
const template = tokensToUntypedTemplateMark(tokenStream, templateKind);
5051
if (options && options.verbose) {
5152
console.log('===== Untyped TemplateMark ');
5253
console.log(JSON.stringify(template,null,2));
5354
}
54-
const typedTemplate = templateMarkTyping(template, modelManager, templateKind);
55+
const typedTemplate = templateMarkTyping(template, modelManager, templateKind, conceptFullyQualifiedName);
5556
if (options && options.verbose) {
5657
console.log('===== TemplateMark ');
5758
console.log(JSON.stringify(typedTemplate,null,2));
@@ -66,9 +67,10 @@ class TemplateMarkTransformer {
6667
* @param {string} templateKind - either 'clause' or 'contract'
6768
* @param {object} [options] configuration options
6869
* @param {boolean} [options.verbose] verbose output
70+
* @param {string} [conceptFullyQualifiedName] - the fully qualified name of the template concept
6971
* @returns {object} the result of parsing
7072
*/
71-
fromMarkdownTemplate(templateInput, modelManager, templateKind, options) {
73+
fromMarkdownTemplate(templateInput, modelManager, templateKind, options, conceptFullyQualifiedName) {
7274
if (!modelManager) {
7375
throw new Error('Cannot parse without template model');
7476
}
@@ -78,7 +80,7 @@ class TemplateMarkTransformer {
7880
console.log('===== MarkdownIt Tokens ');
7981
console.log(JSON.stringify(tokenStream,null,2));
8082
}
81-
return this.tokensToMarkdownTemplate(tokenStream, modelManager, templateKind, options);
83+
return this.tokensToMarkdownTemplate(tokenStream, modelManager, templateKind, options, conceptFullyQualifiedName);
8284
}
8385

8486
/**

packages/markdown-template/src/templatemarkutil.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,12 @@ const templateMarkManager = mkTemplateMarkManager();
5656
/**
5757
* Returns the concept for the template
5858
* @param {object} introspector - the model introspector for this template
59+
* @param {string} templateKind - either 'clause' or 'contract'
5960
* @param {string} [conceptFullyQualifiedName] - the fully qualified name of the template concept
6061
* @throws {Error} if no template model is found, or multiple template models are found
6162
* @returns {ClassDeclaration} the concept for the template
6263
*/
63-
function findTemplateConcept(introspector, conceptFullyQualifiedName) {
64+
function findTemplateConcept(introspector, templateKind, conceptFullyQualifiedName) {
6465
if(conceptFullyQualifiedName) {
6566
return introspector.getClassDeclaration();
6667
}
@@ -123,11 +124,12 @@ function templateMarkTypingGen(template,introspector,model,templateKind,options)
123124
* @param {object} template the TemplateMark DOM
124125
* @param {object} modelManager - the modelManager for this template
125126
* @param {string} templateKind - either 'clause' or 'contract'
127+
* @param {string} [conceptFullyQualifiedName] - the fully qualified name of the template concept
126128
* @returns {object} the typed TemplateMark DOM
127129
*/
128-
function templateMarkTyping(template,modelManager,templateKind) {
130+
function templateMarkTyping(template,modelManager,templateKind,conceptFullyQualifiedName) {
129131
const introspector = new Introspector(modelManager);
130-
const model = findTemplateConcept(introspector, templateKind);
132+
const model = findTemplateConcept(introspector, templateKind,conceptFullyQualifiedName);
131133
return templateMarkTypingGen(template,introspector,model,templateKind);
132134
}
133135

packages/markdown-transform/src/builtinTransforms.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const transformationGraph = {
3939
templatemark: async (input, parameters, options) => {
4040
const t = new TemplateMarkTransformer();
4141
const modelManager = await ModelLoader.loadModelManager(parameters.model, options);
42-
return t.tokensToMarkdownTemplate(input, modelManager, parameters.templateKind, options);
42+
return t.tokensToMarkdownTemplate(input, modelManager, parameters.templateKind, options, parameters.conceptFullyQualifiedName);
4343
},
4444
},
4545
templatemark: {

0 commit comments

Comments
 (0)