From 2d0f46b26e003701f0b69fcc7e1f3db07fc615c0 Mon Sep 17 00:00:00 2001 From: Bronley Plumb Date: Fri, 23 Aug 2024 09:53:37 -0400 Subject: [PATCH] Add support for roIntrinsicDouble (#1291) --- scripts/scrape-roku-docs.ts | 29 +++++++++++++++++++++++++---- src/Scope.spec.ts | 10 ++++++++++ src/roku-types/data.json | 19 ++++++++++++++++++- 3 files changed, 53 insertions(+), 5 deletions(-) diff --git a/scripts/scrape-roku-docs.ts b/scripts/scrape-roku-docs.ts index a3422c89f..0a3346097 100644 --- a/scripts/scrape-roku-docs.ts +++ b/scripts/scrape-roku-docs.ts @@ -1,3 +1,4 @@ +/* eslint-disable import/no-extraneous-dependencies */ /* eslint-disable @typescript-eslint/dot-notation */ /* eslint-disable @typescript-eslint/no-var-requires */ /* eslint-disable @typescript-eslint/no-require-imports */ @@ -298,7 +299,7 @@ class Runner { const arg = call.args[i]; let paramName = `param${i}`; if (isVariableExpression(arg)) { - paramName = arg.getName(ParseMode.BrightScript) + paramName = arg.getName(ParseMode.BrightScript); } signature.params.push({ name: paramName, @@ -311,7 +312,7 @@ class Runner { component.constructors.push(signature); } } else if (match[1]) { - const signature = this.getConstructorSignature(name, match[1]) + const signature = this.getConstructorSignature(name, match[1]); if (signature) { component.constructors.push(signature); @@ -329,10 +330,30 @@ class Runner { this.result.components[component?.name?.toLowerCase()] = component; } + if (!this.result.components['rointrinsicdouble']) { + this.result.components['rointrinsicdouble'] = { + availableSince: undefined, + constructors: [], + description: 'roIntrinsicDouble is the object equivalent for type \'Double\'.\n\nIt is a legacy object name, corresponding to the intrinsic Double object. Applications should use Double literal values and/or Double-typed variables directly.', + events: [], + interfaces: [ + { + name: 'ifDouble', + url: 'https://developer.roku.com/docs/references/brightscript/interfaces/ifdouble.md' + }, + { + name: 'ifToStr', + url: 'https://developer.roku.com/docs/references/brightscript/interfaces/iftostr.md' + } + ], + name: 'roIntrinsicDouble', + url: 'https://developer.roku.com/docs/references/brightscript/components/rodouble.md' + }; + } } private getConstructorSignature(componentName: string, sourceCode: string) { - const foundParamTexts = this.findParamTexts(sourceCode) + const foundParamTexts = this.findParamTexts(sourceCode); if (foundParamTexts && foundParamTexts[0].toLowerCase() === componentName.toLowerCase()) { const signature = { @@ -797,6 +818,7 @@ function deepSearch(object, key, predicate): T { return object; } + // eslint-disable-next-line @typescript-eslint/prefer-for-of for (let i = 0; i < Object.keys(object).length; i++) { let value = object[Object.keys(object)[i]]; if (typeof value === 'object' && value) { @@ -1235,4 +1257,3 @@ interface ElementFilter { //run the builder new Runner().run().catch((e) => console.error(e)); - diff --git a/src/Scope.spec.ts b/src/Scope.spec.ts index bce1d0f3a..3e5a5beb5 100644 --- a/src/Scope.spec.ts +++ b/src/Scope.spec.ts @@ -709,6 +709,16 @@ describe('Scope', () => { expectZeroDiagnostics(program); }); + it('recognizes roIntrinsicDouble', () => { + program.setFile(`source/file.brs`, ` + sub main() + intrinsicDouble = CreateObject("roIntrinsicDouble") + end sub + `); + program.validate(); + expectZeroDiagnostics(program); + }); + it('catches invalid BrightScript components', () => { program.setFile(`source/file.brs`, ` sub main() diff --git a/src/roku-types/data.json b/src/roku-types/data.json index 7b36b51d9..c0c0557c0 100644 --- a/src/roku-types/data.json +++ b/src/roku-types/data.json @@ -1,5 +1,5 @@ { - "generatedDate": "2022-11-02T15:29:46.390Z", + "generatedDate": "2024-08-23T13:39:25.188Z", "nodes": { "animation": { "description": "Extends [**AnimationBase**](https://developer.roku.com/docs/references/scenegraph/abstract-nodes/animationbase.md\n\nThe Animation node class provides animations of renderable nodes, by applying interpolator functions to the values in specified renderable node fields. For an animation to take effect, an Animation node definition must include a child field interpolator node ([FloatFieldInterpolator](https://developer.roku.com/docs/references/scenegraph/animation-nodes/floatfieldinterpolator.md\"FloatFieldInterpolator\"), [Vector2DFieldInterpolator](https://developer.roku.com/docs/references/scenegraph/animation-nodes/vector2dfieldinterpolator.md\"Vector2DFieldInterpolator\"), [ColorFieldInterpolator](https://developer.roku.com/docs/references/scenegraph/animation-nodes/colorfieldinterpolator.md\"ColorFieldInterpolator\")) definition for each renderable node field that is animated.\n\nThe Animation node class provides a simple linear interpolator function, where the animation takes place smoothly and simply from beginning to end. The Animation node class also provides several more complex interpolator functions to allow custom animation effects. For example, you can move a graphic image around the screen at differing speeds and curved trajectories at different times in the animation by specifying the appropriate function in the easeFunction field (quadratic and exponential are two examples of functions that can be specified). The interpolator functions are divided into two parts: the beginning of the animation (ease-in), and the end of the animation (ease-out). You can apply a specified interpolator function to either or both ease-in and ease-out, or specify no function for either or both (which is the linear function). You can also change the portion of the animation that is ease-in and ease-out to arbitrary fractional values for a quadratic interpolator function applied to both ease-in and ease-out.", @@ -6682,6 +6682,23 @@ "name": "roInt", "url": "https://developer.roku.com/docs/references/brightscript/components/roint.md" }, + "rointrinsicdouble": { + "constructors": [], + "description": "roIntrinsicDouble is the object equivalent for type 'Double'.\n\nIt is a legacy object name, corresponding to the intrinsic Double object. Applications should use Double literal values and/or Double-typed variables directly.", + "events": [], + "interfaces": [ + { + "name": "ifDouble", + "url": "https://developer.roku.com/docs/references/brightscript/interfaces/ifdouble.md" + }, + { + "name": "ifToStr", + "url": "https://developer.roku.com/docs/references/brightscript/interfaces/iftostr.md" + } + ], + "name": "roIntrinsicDouble", + "url": "https://developer.roku.com/docs/references/brightscript/components/rodouble.md" + }, "roinvalid": { "constructors": [], "description": "roInvalid is the object equivalent for intrinsic type 'Invalid'.",