diff --git a/benchmarks/targets/validate.js b/benchmarks/targets/validate.js index 982daa879..83af3139b 100644 --- a/benchmarks/targets/validate.js +++ b/benchmarks/targets/validate.js @@ -15,14 +15,18 @@ module.exports = async (suite, name, brighterscript, projectPath) => { throw new Error('No files found in program'); } - suite.add(name, async (deferred) => { + suite.add(name, (deferred) => { const scopes = Object.values(builder.program.scopes); //mark all scopes as invalid so they'll re-validate for (let scope of scopes) { scope.invalidate(); } - await builder.program.validate(); - deferred.resolve(); + let promise = builder.program.validate(); + if (promise) { + promise.then(() => deferred.resolve()); + } else { + deferred.resolve(); + } }, { 'defer': true }); diff --git a/scripts/compile-doc-examples.ts b/scripts/compile-doc-examples.ts index e7f7fcf21..e502182f5 100644 --- a/scripts/compile-doc-examples.ts +++ b/scripts/compile-doc-examples.ts @@ -8,46 +8,46 @@ class DocCompiler { private docsFolder = path.resolve(path.join(__dirname, '..', 'docs')); public async run() { - var docs = glob.sync('**/*.md', { + let docs = glob.sync('**/*.md', { cwd: this.docsFolder, absolute: true }); for (let docPath of docs) { console.log('\n', docPath); - await this.processDoc(docPath); + this.processDoc(docPath); } } private lines: string[]; private index: number; - public async processDoc(docPath: string) { + public processDoc(docPath: string) { let contents = fsExtra.readFileSync(docPath).toString(); this.lines = util.splitIntoLines(contents); this.index = 0; while (this.index < this.lines.length) { let line = this.lines[this.index]; if (line.includes('```')) { - await this.processCodeBlock(); + this.processCodeBlock(); } this.index++; } - var result = this.lines.join('\n'); + let result = this.lines.join('\n'); fsExtra.writeFileSync(docPath, result); delete this.lines; this.index = -1; } - public async processCodeBlock() { - var sourceLines = [] as string[]; - var sourceStartIndex = this.index + 1; - var sourceStopIndex: number; + public processCodeBlock() { + let sourceLines = [] as string[]; + let sourceStartIndex = this.index + 1; + let sourceStopIndex: number; //find the rest of the source code block //+1 to step past the opening ``` - for (var i = this.index + 1; i < this.lines.length; i++) { + for (let i = this.index + 1; i < this.lines.length; i++) { let line = this.lines[i]; if (line.includes('```')) { sourceStopIndex = i - 1; @@ -59,11 +59,11 @@ class DocCompiler { let sourceCode = sourceLines.join('\n'); - var transpiledStartIndex: number; - var transpiledStopIndex: number; + let transpiledStartIndex: number; + let transpiledStopIndex: number; //find the transpiled code block (there must be one after every //+2 to step past the last line of code, and the final ``` - outer: for (var i = sourceStopIndex + 2; i < this.lines.length; i++) { + outer: for (let i = sourceStopIndex + 2; i < this.lines.length; i++) { let line = this.lines[i]; //the next code block MUST be a brightscript block. hard-fail if it isn't if (line.includes('```')) { @@ -88,9 +88,9 @@ class DocCompiler { //now that we have the range for the transpiled code, we need to transpile the source code if (transpiledStartIndex && transpiledStopIndex && sourceCode) { console.log(`Transpiling code block at lines ${sourceStartIndex}-${sourceStopIndex}`); - var transpiledCode = await this.transpile(sourceCode); + const transpiledCode = this.transpile(sourceCode); let transpiledLines = transpiledCode.split('\n'); - let originalTranspiledLineCount = transpiledStopIndex - transpiledStartIndex + let originalTranspiledLineCount = transpiledStopIndex - transpiledStartIndex; //replace the old transpiled lines with the new ones this.lines.splice( @@ -103,15 +103,15 @@ class DocCompiler { } } - public async transpile(code: string) { - var program = new Program({ + public transpile(code: string) { + const program = new Program({ rootDir: `${__dirname}/rootDir`, files: [ 'source/main.brs' ] }); - var file = await program.addOrReplaceFile({ src: `${__dirname}/rootDir/source/main.bs`, dest: 'source/main.bs' }, code) - await program.validate(); + const file = program.addOrReplaceFile({ src: `${__dirname}/rootDir/source/main.bs`, dest: 'source/main.bs' }, code); + program.validate(); let tranpileResult = file.transpile(); return tranpileResult.code; } diff --git a/src/FunctionScope.spec.ts b/src/FunctionScope.spec.ts index ef1cebf1c..99f632d63 100644 --- a/src/FunctionScope.spec.ts +++ b/src/FunctionScope.spec.ts @@ -22,8 +22,8 @@ describe('FunctionScope', () => { expect(variables).to.be.lengthOf(0); }); - it('returns variables defined above the specified line number', async () => { - let file = await program.addOrReplaceFile({ src: `${rootDir}/source/main.brs`, dest: 'source/main.brs' }, ` + it('returns variables defined above the specified line number', () => { + let file = program.addOrReplaceFile({ src: `${rootDir}/source/main.brs`, dest: 'source/main.brs' }, ` sub main() var1 = 1 var2 = 2 diff --git a/src/LanguageServer.spec.ts b/src/LanguageServer.spec.ts index 0910526db..79f84d584 100644 --- a/src/LanguageServer.spec.ts +++ b/src/LanguageServer.spec.ts @@ -103,7 +103,7 @@ describe('LanguageServer', () => { server.dispose(); }); - async function addXmlFile(name: string, additionalXmlContents = '') { + function addXmlFile(name: string, additionalXmlContents = '') { const filePath = `components/${name}.xml`; const contents = ` @@ -111,12 +111,12 @@ describe('LanguageServer', () => { ${additionalXmlContents}