Skip to content

Commit aee086a

Browse files
committed
change name to @sync; fix test bug
1 parent a55da9a commit aee086a

File tree

7 files changed

+21
-13
lines changed

7 files changed

+21
-13
lines changed

packages/custom-functions-metadata/src/parseTree.ts

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export interface IFunctionOptions {
3030
excludeFromAutoComplete?: boolean;
3131
linkedEntityLoadService?: boolean;
3232
capturesCallingObject?: boolean;
33-
syncSupport?: boolean
33+
sync?: boolean
3434
}
3535

3636
export interface IFunctionParameter {
@@ -133,7 +133,7 @@ const REQUIRESADDRESS = "requiresaddress";
133133
const REQUIRESPARAMETERADDRESSES = "requiresparameteraddresses";
134134
const STREAMING = "streaming";
135135
const VOLATILE = "volatile";
136-
const SYNCSUPPORT = "syncsupport";
136+
const SYNC = "sync";
137137

138138
const TYPE_MAPPINGS = {
139139
[ts.SyntaxKind.NumberKeyword]: "number",
@@ -465,7 +465,7 @@ export function parseTree(sourceCode: string, sourceFileName: string): IParseTre
465465
!options.excludeFromAutoComplete &&
466466
!options.linkedEntityLoadService &&
467467
!options.capturesCallingObject &&
468-
!options.syncSupport
468+
!options.sync
469469
) {
470470
delete functionMetadata.options;
471471
} else {
@@ -509,8 +509,8 @@ export function parseTree(sourceCode: string, sourceFileName: string): IParseTre
509509
delete options.capturesCallingObject;
510510
}
511511

512-
if (!options.syncSupport) {
513-
delete options.syncSupport;
512+
if (!options.sync) {
513+
delete options.sync;
514514
}
515515
}
516516

@@ -674,7 +674,7 @@ function getOptions(
674674
excludeFromAutoComplete: isExcludedFromAutoComplete(func),
675675
linkedEntityLoadService: isLinkedEntityLoadService(func),
676676
capturesCallingObject: capturesCallingObject(func),
677-
syncSupport: isSyncSupport(func),
677+
sync: isSync(func),
678678
};
679679

680680
if (isAddressRequired(func) || isRequiresParameterAddresses(func)) {
@@ -689,6 +689,14 @@ function getOptions(
689689
}
690690
}
691691

692+
if (isSync(func)) {
693+
if (!isInvocationFunction) {
694+
const functionPosition = getPosition(func, func.parameters.end);
695+
const errorString = `Since @sync is present, the last function parameter should be of type CustomFunctions.Invocation :`;
696+
extra.errors.push(logError(errorString, functionPosition));
697+
}
698+
}
699+
692700
if (
693701
optionsItem.linkedEntityLoadService &&
694702
(optionsItem.excludeFromAutoComplete ||
@@ -1071,11 +1079,11 @@ function capturesCallingObject(node: ts.Node): boolean {
10711079
}
10721080

10731081
/**
1074-
* Returns true if syncSupport tag found in comments
1082+
* Returns true if sync tag found in comments
10751083
* @param node jsDocs node
10761084
*/
1077-
function isSyncSupport(node: ts.Node): boolean {
1078-
return hasTag(node, SYNCSUPPORT);
1085+
function isSync(node: ts.Node): boolean {
1086+
return hasTag(node, SYNC);
10791087
}
10801088

10811089
function containsTag(tag: ts.JSDocTag, tagName: string): boolean {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Since @sync is present, the last function parameter should be of type CustomFunctions.Invocation : (10,40)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Since @sync is present, the last function parameter should be of type CustomFunctions.Invocation : (10,48)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Test missing invocation parameter type
66
* @param x {string} string
77
* @customfunction
8-
* @syncSupport
8+
* @sync
99
*/
1010
function customFunctionInvocationTest(x) {
1111
// Empty
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Test missing invocation parameter type
66
* @param x string
77
* @customfunction
8-
* @syncSupport
8+
* @sync
99
*/
1010
function customFunctionInvocationTest(x: string) {
1111
// Empty

packages/custom-functions-metadata/test/cases/error-syncsupport-missing-invocation-parameter/expected.js.errors.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

packages/custom-functions-metadata/test/cases/error-syncsupport-missing-invocation-parameter/expected.ts.errors.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)