Skip to content

Commit

Permalink
Merge branch 'master' into lsp-refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
TwitchBronBron authored Sep 23, 2024
2 parents d763dbe + 56dcaaa commit 373852d
Show file tree
Hide file tree
Showing 11 changed files with 131 additions and 29 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0



## [0.67.6](https://github.com/rokucommunity/brighterscript/compare/v0.67.5...v0.67.6) - 2024-09-05
### Added
- support for `roIntrinsicDouble` ([#1291](https://github.com/rokucommunity/brighterscript/pull/1291))
- support for resolving `sourceRoot` at time of config load ([#1290](https://github.com/rokucommunity/brighterscript/pull/1290))
### Changed
- document plugin naming convention ([#1284](https://github.com/rokucommunity/brighterscript/pull/1284))



## [0.67.5](https://github.com/rokucommunity/brighterscript/compare/v0.67.4...v0.67.5) - 2024-07-31
### Fixed
- templatestring support for `annotation.getArguments()` ([#1264](https://github.com/rokucommunity/brighterscript/pull/1264))
Expand Down
16 changes: 8 additions & 8 deletions benchmarks/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 19 additions & 3 deletions bsconfig.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@
"type": "object",
"patternProperties": {
"^.+$": {
"type": ["boolean", "null"]
"type": [
"boolean",
"null"
]
}
}
}
Expand Down Expand Up @@ -161,8 +164,16 @@
"type": "object",
"patternProperties": {
".{1,}": {
"type": ["number", "string"],
"enum": ["error", "warn", "info", "hint"]
"type": [
"number",
"string"
],
"enum": [
"error",
"warn",
"info",
"hint"
]
}
}
},
Expand Down Expand Up @@ -268,6 +279,11 @@
"description": "Override the root directory path where debugger should locate the source files. The location will be embedded in the source map to help debuggers locate the original source files. This only applies to files found within rootDir. This is useful when you want to preprocess files before passing them to BrighterScript, and want a debugger to open the original files. This option also affects the `SOURCE_FILE_PATH` and `SOURCE_LOCATION` source literals.",
"type": "string"
},
"resolveSourceRoot": {
"description": "Should the `sourceRoot` property be resolve to an absolute path (relative to the bsconfig it's defined in)",
"type": "boolean",
"default": false
},
"diagnosticLevel": {
"description": "Specify what diagnostic levels are printed to the console. This has no effect on what diagnostics are reported in the LanguageServer. Defaults to 'warn'",
"type": "string",
Expand Down
24 changes: 12 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "brighterscript",
"version": "0.67.5",
"version": "0.67.6",
"description": "A superset of Roku's BrightScript language.",
"scripts": {
"preversion": "npm run build && npm run lint && npm run test",
Expand Down
29 changes: 25 additions & 4 deletions scripts/scrape-roku-docs.ts
Original file line number Diff line number Diff line change
@@ -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 */
Expand Down Expand Up @@ -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,
Expand All @@ -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);
Expand All @@ -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 = {
Expand Down Expand Up @@ -797,6 +818,7 @@ function deepSearch<T = any>(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) {
Expand Down Expand Up @@ -1235,4 +1257,3 @@ interface ElementFilter {

//run the builder
new Runner().run().catch((e) => console.error(e));

5 changes: 5 additions & 0 deletions src/BsConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,11 @@ export interface BsConfig {
* have their source maps changed. This option also affects the `SOURCE_FILE_PATH` and `SOURCE_LOCATION` source literals.
*/
sourceRoot?: string;
/**
* Should the `sourceRoot` property be resolve to an absolute path (relative to the bsconfig it's defined in)
* @default false
*/
resolveSourceRoot?: boolean;
/**
* Enables generating sourcemap files, which allow debugging tools to show the original source code while running the emitted files.
* @default true
Expand Down
10 changes: 10 additions & 0 deletions src/Scope.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
19 changes: 18 additions & 1 deletion src/roku-types/data.json
Original file line number Diff line number Diff line change
@@ -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.",
Expand Down Expand Up @@ -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'.",
Expand Down
20 changes: 20 additions & 0 deletions src/util.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,26 @@ describe('util', () => {
]);
});

it('resolves sourceRoot relative to the bsconfig file', () => {
fsExtra.outputJsonSync(s`${rootDir}/folder1/parent.json`, { sourceRoot: './alpha/beta', resolveSourceRoot: true });
fsExtra.outputJsonSync(s`${rootDir}/child.json`, { extends: 'folder1/parent.json' });
expect(
util.loadConfigFile(s`${rootDir}/child.json`).sourceRoot
).to.eql(
s`${rootDir}/folder1/alpha/beta`
);
});

it('leaves sourceRoot relative when defaulted to', () => {
fsExtra.outputJsonSync(s`${rootDir}/folder1/parent.json`, { sourceRoot: './alpha/beta' });
fsExtra.outputJsonSync(s`${rootDir}/child.json`, { extends: 'folder1/parent.json' });
expect(
util.loadConfigFile(s`${rootDir}/child.json`).sourceRoot
).to.eql(
`./alpha/beta`
);
});

it('returns empty ancestors list for non-extends files', () => {
fsExtra.outputFileSync(s`${rootDir}/child.json`, `{}`);
let config = util.loadConfigFile(s`${rootDir}/child.json`);
Expand Down
4 changes: 4 additions & 0 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,9 @@ export class Util {
if (result.stagingDir) {
result.stagingDir = path.resolve(projectFileCwd, result.stagingDir);
}
if (result.sourceRoot && result.resolveSourceRoot) {
result.sourceRoot = path.resolve(projectFileCwd, result.sourceRoot);
}
return result;
}
}
Expand Down Expand Up @@ -384,6 +387,7 @@ export class Util {
autoImportComponentScript: config.autoImportComponentScript === true ? true : false,
showDiagnosticsInConsole: config.showDiagnosticsInConsole === false ? false : true,
sourceRoot: config.sourceRoot ? standardizePath(config.sourceRoot) : undefined,
resolveSourceRoot: config.resolveSourceRoot === true ? true: false,
allowBrighterScriptInBrightScript: config.allowBrighterScriptInBrightScript === true ? true : false,
emitDefinitions: config.emitDefinitions === true ? true : false,
removeParameterTypes: config.removeParameterTypes === true ? true : false,
Expand Down

0 comments on commit 373852d

Please sign in to comment.