Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion packages/custom-functions-metadata/src/parseTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export interface IFunctionOptions {
excludeFromAutoComplete?: boolean;
linkedEntityLoadService?: boolean;
capturesCallingObject?: boolean;
supportSync?: boolean;
}

export interface IFunctionParameter {
Expand Down Expand Up @@ -132,6 +133,7 @@ const REQUIRESADDRESS = "requiresaddress";
const REQUIRESPARAMETERADDRESSES = "requiresparameteraddresses";
const STREAMING = "streaming";
const VOLATILE = "volatile";
const SUPPORT_SYNC = "supportsync";

const TYPE_MAPPINGS = {
[ts.SyntaxKind.NumberKeyword]: "number",
Expand Down Expand Up @@ -462,7 +464,8 @@ export function parseTree(sourceCode: string, sourceFileName: string): IParseTre
!options.requiresStreamParameterAddresses &&
!options.excludeFromAutoComplete &&
!options.linkedEntityLoadService &&
!options.capturesCallingObject
!options.capturesCallingObject &&
!options.supportSync
) {
delete functionMetadata.options;
} else {
Expand Down Expand Up @@ -505,6 +508,10 @@ export function parseTree(sourceCode: string, sourceFileName: string): IParseTre
if (!options.capturesCallingObject) {
delete options.capturesCallingObject;
}

if (!options.supportSync) {
delete options.supportSync;
}
}

if (!functionMetadata.helpUrl) {
Expand Down Expand Up @@ -667,6 +674,7 @@ function getOptions(
excludeFromAutoComplete: isExcludedFromAutoComplete(func),
linkedEntityLoadService: isLinkedEntityLoadService(func),
capturesCallingObject: capturesCallingObject(func),
supportSync: supportSync(func),
};

if (isAddressRequired(func) || isRequiresParameterAddresses(func)) {
Expand Down Expand Up @@ -1062,6 +1070,14 @@ function capturesCallingObject(node: ts.Node): boolean {
return hasTag(node, CAPTURESCALLINGOBJECT);
}

/**
* Returns true if sync tag found in comments
* @param node jsDocs node
*/
function supportSync(node: ts.Node): boolean {
return hasTag(node, SUPPORT_SYNC);
}

function containsTag(tag: ts.JSDocTag, tagName: string): boolean {
return (tag.tagName.escapedText as string).toLowerCase() === tagName;
}
Expand Down
Loading