From 0f178f1d74e17b15cec0fc98a12ccb2acaec937a Mon Sep 17 00:00:00 2001 From: anika-ahluwalia Date: Sat, 30 May 2020 12:52:40 -0500 Subject: generating suggestions for methods --- src/client/util/Scripting.ts | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'src/client/util/Scripting.ts') diff --git a/src/client/util/Scripting.ts b/src/client/util/Scripting.ts index ab577315c..817e6b29d 100644 --- a/src/client/util/Scripting.ts +++ b/src/client/util/Scripting.ts @@ -49,12 +49,25 @@ export function isCompileError(toBeDetermined: CompileResult): toBeDetermined is export namespace Scripting { export function addGlobal(global: { name: string }): void; export function addGlobal(name: string, global: any): void; - export function addGlobal(nameOrGlobal: any, global?: any) { - let n: string; + + export function addGlobal(global: { name: string }, decription?: string, params?: any): void; + + export function addGlobal(nameOrGlobal: any, global?: any, params?: any) { + let n: any; let obj: any; - if (global !== undefined && typeof nameOrGlobal === "string") { - n = nameOrGlobal; - obj = global; + + if (global !== undefined) { + if (typeof nameOrGlobal === "string") { + n = nameOrGlobal; + obj = global; + } else { + n = nameOrGlobal.name; + obj = [nameOrGlobal]; + obj.push(global); + if (params) { + obj.push(params); + } + } } else if (nameOrGlobal && typeof nameOrGlobal.name === "string") { n = nameOrGlobal.name; obj = nameOrGlobal; @@ -87,6 +100,10 @@ export namespace Scripting { export function getGlobals() { return Object.keys(scriptingGlobals); } + + export function getGlobalObj() { + return _scriptingGlobals; + } } export function scriptingGlobal(constructor: { new(...args: any[]): any }) { -- cgit v1.2.3-70-g09d2