Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wip #137

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft

wip #137

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
"activityBar.background": "#143141",
"titleBar.activeBackground": "#1D445B",
"titleBar.activeForeground": "#F7FBFD"
}
},
"brightscript.bsdk": "node_modules/brighterscript"
}
1 change: 1 addition & 0 deletions bsc-plugin/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ module.exports = {
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 'off',
'@typescript-eslint/no-unnecessary-condition': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
Expand Down
12 changes: 5 additions & 7 deletions bsc-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,21 @@
"dependencies": {
"@types/node": "^14.14.16",
"source-map": "^0.7.3",
"stringify-object": "^3.3.0",
"vscode-languageserver": "~6.1.1",
"vscode-languageserver-protocol": "~3.15.3"
"stringify-object": "^3.3.0"
},
"devDependencies": {
"@types/chai": "^4.1.2",
"@types/expect": "^24.3.0",
"@types/fs-extra": "^5.0.1",
"@types/mocha": "^5.2.7",
"@types/sinon": "^9.0.4",
"@typescript-eslint/eslint-plugin": "^4.4.1",
"@typescript-eslint/parser": "^4.4.1",
"brighterscript": "^0.39.0",
"@typescript-eslint/eslint-plugin": "^5.5.0",
"@typescript-eslint/parser": "^5.5.0",
"brighterscript": "^1.0.0-alpha.12",
"chai": "^4.2.0",
"chai-files": "^1.4.0",
"chai-subset": "^1.6.0",
"eslint": "^7.11.0",
"eslint": "^8.3.0",
"eslint-plugin-github": "^4.1.1",
"eslint-plugin-no-only-tests": "^2.4.0",
"minimatch": "^3.0.4",
Expand Down
2 changes: 0 additions & 2 deletions bsc-plugin/src/lib/rooibos/CodeCoverageProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,4 @@ export class CodeCoverageProcessor {
//`Writing to ${file.fullPath}`);
// file.saveFileContents();
}


}
6 changes: 3 additions & 3 deletions bsc-plugin/src/lib/rooibos/FileFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ export class FileFactory {
let destPath = path.join(this.targetPath, `${fileName}.bs`);
let entry = { src: sourcePath, dest: destPath };

program.addOrReplaceFile(entry, fileContents);
program.setFile(entry, fileContents);
}

let sourcePath = path.resolve(path.join(this.sourcePath, `RooibosScene.xml`));
let destPath = path.join(this.targetCompsPath, `RooibosScene.xml`);
let entry = { src: sourcePath, dest: destPath };
program.addOrReplaceFile(entry, this.createTestXML('TestsScene', 'Scene'));
program.setFile(entry, this.createTestXML('TestsScene', 'Scene'));
}

public createTestXML(name: string, baseName: string, useBs = true): string {
Expand Down Expand Up @@ -99,7 +99,7 @@ ${scriptImports.join('\n')}

public addFile(program, projectPath: string, contents: string) {
try {
return program.addOrReplaceFile({ src: path.resolve(projectPath), dest: projectPath }, contents);
return program.setFile({ src: path.resolve(projectPath), dest: projectPath }, contents);
} catch (error) {
console.error(`Error adding framework file: ${projectPath} : ${error.message}`);
}
Expand Down
2 changes: 1 addition & 1 deletion bsc-plugin/src/lib/rooibos/RawCodeStatement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class RawCodeStatement extends Statement {
return [new SourceNode(
this.range.start.line + 1,
this.range.start.character,
this.sourceFile ? this.sourceFile.pathAbsolute : state.srcPath,
this.sourceFile ? this.sourceFile.srcPath : state.srcPath,
this.source
)];
}
Expand Down
6 changes: 3 additions & 3 deletions bsc-plugin/src/lib/rooibos/RooibosSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ export class RooibosSession {
}
if (!mainFunc) {
diagnosticWarnNoMainFound(files[0]);
this._builder.program.addOrReplaceFile('source/rooibosMain.brs', `function main()
this._builder.program.setFile('source/rooibosMain.brs', `function main()
Rooibos_init()
end function`);
}
}

public addTestRunnerMetadata() {
let runtimeConfig = this._builder.program.getFileByPkgPath('source/rooibos/RuntimeConfig.bs');
let runtimeConfig = this._builder.program.getFile('source/rooibos/RuntimeConfig.bs');
if (runtimeConfig) {
let classStatement = ((runtimeConfig as BrsFile).ast.statements[0] as NamespaceStatement).body.statements[0] as ClassStatement;
this.updateRunTimeConfigFunction(classStatement);
Expand Down Expand Up @@ -139,7 +139,7 @@ end function`);
let xmlText = this.getNodeTestXmlText(suite);
let bsPath = path.join(p, `${suite.generatedNodeName}.bs`);
this.fileFactory.addFile(program, path.join(p, `${suite.generatedNodeName}.xml`), xmlText);
let bsFile = program.getFileByPkgPath(bsPath);
let bsFile = program.getFile(bsPath);
if (bsFile) {
(bsFile as BrsFile).parser.statements.push();
bsFile.needsTranspiled = true;
Expand Down
4 changes: 2 additions & 2 deletions bsc-plugin/src/lib/rooibos/TestSuite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ export class TestBlock {
return this.annotation.file;
}
public get pkgPath(): string {
return this.file.pkgPath;
return this.file.pkgPath.replace('pkg:/', '');
}

public get filePath(): string {
return this.file.pathAbsolute;
return this.file.srcPath;
}

public get name(): string {
Expand Down
6 changes: 3 additions & 3 deletions bsc-plugin/src/lib/rooibos/TestSuiteBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class TestSuiteBuilder {

public processFile(file: BrsFile): TestSuite[] {
this.file = file;
let suites = [];
let suites = [] as TestSuite[];
try {
for (let cs of file.parser.references.classStatements) {

Expand Down Expand Up @@ -68,8 +68,8 @@ export class TestSuiteBuilder {
let oldSuite = this.session.sessionInfo.testSuites.get(annotation.name);
let suite = this.processClass(annotation, s);
let isDuplicate = false;
if ((oldSuite && oldSuite.file.pathAbsolute !==
file.pathAbsolute)) {
if ((oldSuite && oldSuite.file.srcPath !==
file.srcPath)) {
oldSuite.isValid = false;
suite.isValid = false;
diagnosticDuplicateSuite(file, oldSuite.classStatement, oldSuite.annotation);
Expand Down
Loading