Skip to content

Commit

Permalink
Conflict resoluiton
Browse files Browse the repository at this point in the history
  • Loading branch information
fumer-fubotv committed Oct 13, 2023
2 parents ab5629e + 2c9fadc commit a83dc75
Show file tree
Hide file tree
Showing 9 changed files with 230 additions and 158 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2793,19 +2793,19 @@
},
{
"command": "extension.brightscript.rokuDeviceView.pauseScreenshotCapture",
"title": "Pause Screenshot Capture",
"title": "Device View: Pause Screenshot Capture",
"category": "BrighterScript",
"icon": "$(debug-pause)"
},
{
"command": "extension.brightscript.rokuDeviceView.resumeScreenshotCapture",
"title": "Resume Screenshot Capture",
"title": "Device View: Resume Screenshot Capture",
"category": "BrighterScript",
"icon": "$(debug-start)"
},
{
"command": "extension.brightscript.rokuDeviceView.refreshScreenshot",
"title": "Refresh Screenshot",
"title": "Device View: Refresh Screenshot",
"category": "BrighterScript",
"icon": "$(refresh)"
},
Expand Down
41 changes: 40 additions & 1 deletion src/BrightScriptCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ export class BrightScriptCommands {
let config = vscode.workspace.getConfiguration('brightscript.remoteControl', null);
this.host = config.get('host');
// eslint-disable-next-line no-template-curly-in-string
if (this.host === '${promptForHost}') {
if (!this.host || this.host === '${promptForHost}') {
this.host = await vscode.window.showInputBox({
placeHolder: 'The IP address of your Roku device',
value: ''
Expand All @@ -440,6 +440,45 @@ export class BrightScriptCommands {
console.error('Error doing dns lookup for host ', this.host, e);
}
}
return this.host;
}

public async getRemotePassword() {

Check failure on line 446 in src/BrightScriptCommands.ts

View workflow job for this annotation

GitHub Actions / ci (ubuntu-latest)

Duplicate function implementation.
this.password = await this.context.workspaceState.get('remotePassword');
if (!this.password) {
let config = vscode.workspace.getConfiguration('brightscript.remoteControl', null);
this.password = config.get('password');
// eslint-disable-next-line no-template-curly-in-string
if (!this.password || this.password === '${promptForPassword}') {
this.password = await vscode.window.showInputBox({
placeHolder: 'The developer account password for your Roku device',
value: ''
});
}
}
if (!this.password) {
throw new Error(`Can't send command: password is required.`);
} else {
await this.context.workspaceState.update('remotePassword', this.password);
}
return this.password;
}

public async getWorkspacePath() {

Check failure on line 467 in src/BrightScriptCommands.ts

View workflow job for this annotation

GitHub Actions / ci (ubuntu-latest)

Duplicate function implementation.
this.workspacePath = await this.context.workspaceState.get('workspacePath');
//let folderUri: vscode.Uri;
if (!this.workspacePath) {
if (vscode.workspace.workspaceFolders.length === 1) {
this.workspacePath = vscode.workspace.workspaceFolders[0].uri.fsPath;
} else {
//there are multiple workspaces, ask the user to specify which one they want to use
let workspaceFolder = await vscode.window.showWorkspaceFolderPick();
if (workspaceFolder) {
this.workspacePath = workspaceFolder.uri.fsPath;
}
}
}
return this.workspacePath;
}

public async getRemotePassword() {

Check failure on line 484 in src/BrightScriptCommands.ts

View workflow job for this annotation

GitHub Actions / ci (ubuntu-latest)

Duplicate function implementation.
Expand Down
4 changes: 3 additions & 1 deletion src/DebugConfigurationProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ export class BrightScriptDebugConfigurationProvider implements DebugConfiguratio
// Create the Quick Picker option items
for (const key of Object.keys(activeDevices)) {
let device = activeDevices[key];
let itemText = `${device.ip} | ${device.deviceInfo['default-device-name']} - ${device.deviceInfo['model-number']}`;
let itemText = `${device.ip} | ${device.deviceInfo['user-device-name']} - ${device.deviceInfo['serial-number']} - ${device.deviceInfo['model-number']}`;

if (this.activeDeviceManager.lastUsedDevice && device.deviceInfo['default-device-name'] === this.activeDeviceManager.lastUsedDevice) {
items.unshift(itemText);
Expand Down Expand Up @@ -477,6 +477,8 @@ export class BrightScriptDebugConfigurationProvider implements DebugConfiguratio
config.password = await this.openInputBox('The developer account password for your Roku device.');
if (!config.password) {
throw new Error('Debug session terminated: password is required.');
} else {
await this.context.workspaceState.update('remotePassword', config.password);
}
}

Expand Down
38 changes: 0 additions & 38 deletions src/LogOutputManager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,18 @@ import { util } from 'brighterscript';
describe('LogOutputManager ', () => {
let logOutputManagerMock: Sinon.SinonMock;
let logOutputManager: LogOutputManager;
let languagesMock: Sinon.SinonMock;
let outputChannelMock: Sinon.SinonMock;
let logDocumentLinkProviderMock: Sinon.SinonMock;
let collectionMock: Sinon.SinonMock;
let declarationProviderMock: Sinon.SinonMock;

beforeEach(() => {
sinon.restore();
const outputChannel = new vscode.OutputChannel();
const debugCollection = new vscode.DebugCollection();
const logDocumentLinkProvider = new LogDocumentLinkProvider();
const declarationProvider = new DeclarationProvider();
outputChannelMock = sinon.mock(outputChannel);
logDocumentLinkProviderMock = sinon.mock(logDocumentLinkProvider);
collectionMock = sinon.mock(debugCollection);
declarationProviderMock = sinon.mock(declarationProvider);
languagesMock = sinon.mock(vscode.languages);
languagesMock.expects('createDiagnosticCollection').returns(debugCollection);
collectionMock.expects('clear');
logOutputManager = new LogOutputManager(outputChannel, vscode.context, logDocumentLinkProvider, declarationProvider);
logOutputManagerMock = sinon.mock(logOutputManager);
});
Expand All @@ -55,73 +48,49 @@ describe('LogOutputManager ', () => {
});

it('tests onDidStartDebugSession clear flag', () => {
collectionMock.expects('clear').once();
logOutputManager.isClearingConsoleOnChannelStart = true;
logOutputManager.onDidStartDebugSession();
outputChannelMock.verify();
collectionMock.verify();
logOutputManagerMock.verify();
});

it('tests onDidStartDebugSession no clear flag', () => {
collectionMock.expects('clear').never();
logOutputManager.isClearingConsoleOnChannelStart = false;
logOutputManager.onDidStartDebugSession();
outputChannelMock.verify();
collectionMock.verify();
logOutputManagerMock.verify();
});

it('tests onDidReceiveDebugSessionCustomEvent - LaunchStartEvent - clear flag', async () => {
collectionMock.expects('clear').once();
logOutputManager.isClearingOutputOnLaunch = true;
await logOutputManager.onDidReceiveDebugSessionCustomEvent({ event: 'LaunchStartEvent' });
outputChannelMock.verify();
collectionMock.verify();
logOutputManagerMock.verify();
});

it('tests onDidReceiveDebugSessionCustomEvent - LaunchStartEvent - no clear flag', async () => {
collectionMock.expects('clear').never();
logOutputManager.isClearingOutputOnLaunch = false;
await logOutputManager.onDidReceiveDebugSessionCustomEvent(new LaunchStartEvent({} as any));
outputChannelMock.verify();
collectionMock.verify();
logOutputManagerMock.verify();
});

it('tests onDidReceiveDebugSessionCustomEvent - LogOutputEvent', async () => {
outputChannelMock.expects('appendLine').once();
await logOutputManager.onDidReceiveDebugSessionCustomEvent(new LogOutputEvent('test 1'));
outputChannelMock.verify();
collectionMock.verify();
logOutputManagerMock.verify();
});

it('tests onDidReceiveDebugSessionCustomEvent - error - empty', async () => {
await logOutputManager.onDidReceiveDebugSessionCustomEvent({ event: '', body: {} });
outputChannelMock.verify();
collectionMock.verify();
logOutputManagerMock.verify();
});

it('tests onDidReceiveDebugSessionCustomEvent - error - undefined', async () => {
await logOutputManager.onDidReceiveDebugSessionCustomEvent({ event: '' });
outputChannelMock.verify();
collectionMock.verify();
logOutputManagerMock.verify();
});

it('tests onDidReceiveDebugSessionCustomEvent - errors', async () => {
logOutputManagerMock.expects('addDiagnosticForError').once();
let compileErrors: BSDebugDiagnostic[] = [{
path: 'path1',
message: 'message1',
range: util.createRange(1, 2, 3, 4)
}];
await logOutputManager.onDidReceiveDebugSessionCustomEvent(new DiagnosticsEvent(compileErrors));
outputChannelMock.verify();
collectionMock.verify();
logOutputManagerMock.verify();
});

Expand All @@ -130,13 +99,11 @@ describe('LogOutputManager ', () => {
logOutputManager.appendLine('test1', true);
logOutputManager.appendLine('test2', true);
logOutputManager.appendLine('test3', true);
collectionMock.expects('clear').once();
outputChannelMock.expects('clear').once();

logOutputManager.clearOutput();

outputChannelMock.verify();
collectionMock.verify();
});

it('tests output indexes are cleared', () => {
Expand All @@ -151,7 +118,6 @@ describe('LogOutputManager ', () => {
logOutputManager.markOutput();

logOutputManagerMock.verify();
collectionMock.verify();

logOutputManagerMock = sinon.mock(logOutputManager);
logOutputManager.clearOutput();
Expand All @@ -164,7 +130,6 @@ describe('LogOutputManager ', () => {
logOutputManager.markOutput();

logOutputManagerMock.verify();
collectionMock.verify();

});
});
Expand All @@ -175,7 +140,6 @@ describe('LogOutputManager ', () => {
.withExactArgs('test1').once();
logOutputManager.appendLine('test1', true);
outputChannelMock.verify();
collectionMock.verify();
});

it('splits multiple lines', () => {
Expand All @@ -187,7 +151,6 @@ describe('LogOutputManager ', () => {
logOutputManager.appendLine('test1\ntest2', true);

outputChannelMock.verify();
collectionMock.verify();
});
});

Expand All @@ -204,7 +167,6 @@ describe('LogOutputManager ', () => {
logOutputManager.markOutput();

logOutputManagerMock.verify();
collectionMock.verify();
});
});

Expand Down
53 changes: 0 additions & 53 deletions src/LogOutputManager.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as vscode from 'vscode';
import type { DiagnosticCollection } from 'vscode';
import type { BSDebugDiagnostic } from 'roku-debug';
import { isChanperfEvent, isDiagnosticsEvent, isLaunchStartEvent, isLogOutputEvent, isPopupMessageEvent, isRendezvousEvent } from 'roku-debug';
import type { DeclarationProvider } from './DeclarationProvider';
Expand All @@ -24,7 +23,6 @@ export class LogOutputManager {
docLinkProvider,
private declarationProvider: DeclarationProvider
) {
this.collection = vscode.languages.createDiagnosticCollection('BrightScript');
this.outputChannel = outputChannel;
this.docLinkProvider = docLinkProvider;

Expand Down Expand Up @@ -103,7 +101,6 @@ export class LogOutputManager {
public isClearingOutputOnLaunch: boolean;
public isClearingConsoleOnChannelStart: boolean;
public hyperlinkFormat: string;
private collection: DiagnosticCollection;
private outputChannel: vscode.OutputChannel;
private docLinkProvider: LogDocumentLinkProvider;
private debugStartRegex: RegExp;
Expand Down Expand Up @@ -247,22 +244,6 @@ export class LogOutputManager {
this.clearOutput();
}

} else if (isDiagnosticsEvent(e)) {
let errorsByPath = {};
for (const diagnostic of e.body.diagnostics) {
if (diagnostic.path) {
if (!errorsByPath[diagnostic.path]) {
errorsByPath[diagnostic.path] = [];
}
errorsByPath[diagnostic.path].push(diagnostic);
}
}
for (const path in errorsByPath) {
if (errorsByPath.hasOwnProperty(path)) {
const errors = errorsByPath[path];
await this.addDiagnosticForError(path, errors);
}
}
}
}

Expand Down Expand Up @@ -299,39 +280,6 @@ export class LogOutputManager {
methods[severity](message);
}

public async addDiagnosticForError(path: string, diagnostics: BSDebugDiagnostic[]) {
//TODO get the actual folder
let documentUri: vscode.Uri;
let uri = vscode.Uri.file(path);
let doc = await vscode.workspace.openTextDocument(uri); // calls back
if (doc !== undefined) {
documentUri = doc.uri;
}
// console.log("got " + documentUri);

//debug crap - for some reason - using this URI works - using the one from the path does not :()
// const document = vscode.window.activeTextEditor.document;
// const currentDocumentUri = document.uri;
// console.log("currentDocumentUri " + currentDocumentUri);
if (documentUri !== undefined) {
let result: vscode.Diagnostic[] = [];
for (const diagnostic of diagnostics) {
result.push({
code: diagnostic.code,
message: diagnostic.message,
source: diagnostic.source,
severity: diagnostic.severity,
tags: diagnostic.tags,
range: new vscode.Range(
new vscode.Position(diagnostic.range.start.line, diagnostic.range.start.character),
new vscode.Position(diagnostic.range.end.line, diagnostic.range.end.character)
)
});
}
this.collection.set(documentUri, result);
}
}

/**
* Log output methods
*/
Expand Down Expand Up @@ -487,7 +435,6 @@ export class LogOutputManager {
this.allLogLines = [];
this.displayedLogLines = [];
this.outputChannel.clear();
this.collection.clear();
this.docLinkProvider.resetCustomLinks();
}

Expand Down
Loading

0 comments on commit a83dc75

Please sign in to comment.