Skip to content
Merged
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
56 changes: 28 additions & 28 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@
"node-cache": "^4.2.0",
"node-ssdp": "^4.0.0",
"pretty-bytes": "^5.6.0",
"roku-debug": "^0.15.0",
"roku-deploy": "^3.8.1",
"roku-debug": "^0.16.0",
"roku-deploy": "^3.9.2",
"roku-test-automation": "2.0.0-beta.5",
"semver": "^7.1.3",
"source-map": "^0.7.3",
Expand Down
25 changes: 16 additions & 9 deletions src/LogOutputManager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ Module.prototype.require = function hijacked(file) {
import { DeclarationProvider } from './DeclarationProvider';
import { LogDocumentLinkProvider } from './LogDocumentLinkProvider';
import { LogLine, LogOutputManager } from './LogOutputManager';
import type { BSDebugDiagnostic } from 'roku-debug';
import { DiagnosticsEvent, LaunchStartEvent, LogOutputEvent } from 'roku-debug';
import { util } from 'brighterscript';

describe('LogOutputManager ', () => {
let logOutputManagerMock: Sinon.SinonMock;
Expand Down Expand Up @@ -69,34 +72,34 @@ describe('LogOutputManager ', () => {
logOutputManagerMock.verify();
});

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

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

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

it('tests onDidReceiveDebugSessionCustomEvent - error - empty', async () => {
await logOutputManager.onDidReceiveDebugSessionCustomEvent({ event: '', body: [] });
await logOutputManager.onDidReceiveDebugSessionCustomEvent({ event: '', body: {} });
outputChannelMock.verify();
collectionMock.verify();
logOutputManagerMock.verify();
Expand All @@ -111,8 +114,12 @@ describe('LogOutputManager ', () => {

it('tests onDidReceiveDebugSessionCustomEvent - errors', async () => {
logOutputManagerMock.expects('addDiagnosticForError').once();
let compileErrors = [{ path: 'path1', message: 'message1' }];
await logOutputManager.onDidReceiveDebugSessionCustomEvent({ event: '', body: compileErrors });
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 Down
61 changes: 30 additions & 31 deletions src/LogOutputManager.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as vscode from 'vscode';
import type { DiagnosticCollection } from 'vscode';
import type { BrightScriptDebugCompileError } from 'roku-debug';
import type { BSDebugDiagnostic } from 'roku-debug';
import { isChanperfEvent, isDiagnosticsEvent, isLaunchStartEvent, isLogOutputEvent, isPopupMessageEvent, isRendezvousEvent } from 'roku-debug';
import type { DeclarationProvider } from './DeclarationProvider';
import type { LogDocumentLinkProvider } from './LogDocumentLinkProvider';
import { CustomDocumentLink } from './LogDocumentLinkProvider';
Expand Down Expand Up @@ -130,16 +131,18 @@ export class LogOutputManager {
}

public async onDidReceiveDebugSessionCustomEvent(e: { event: string; body?: any }) {
if (e.event === 'BSRendezvousEvent' || e.event === 'BSChanperfEvent') {
if (isRendezvousEvent(e) || isChanperfEvent(e)) {
// No need to handle rendezvous type events
return;
}

if (e.event === 'BSLogOutputEvent') {
this.appendLine(e.body);
} else if (e.event === 'BSPopupMessageEvent') {
if (isLogOutputEvent(e)) {
this.appendLine(e.body.line);

} else if (isPopupMessageEvent(e)) {
this.showMessage(e.body.message, e.body.severity);
} else if (e.event === 'BSLaunchStartEvent') {

} else if (isLaunchStartEvent(e)) {
this.isInMicroDebugger = false;
this.isNextBreakpointSkipped = false;
if (this.isFocusingOutputOnLaunch) {
Expand All @@ -149,14 +152,15 @@ export class LogOutputManager {
if (this.isClearingOutputOnLaunch) {
this.clearOutput();
}
} else if (e.body && Array.isArray(e.body)) {

} else if (isDiagnosticsEvent(e)) {
let errorsByPath = {};
for (const compileError of e.body) {
if (compileError.path) {
if (!errorsByPath[compileError.path]) {
errorsByPath[compileError.path] = [];
for (const diagnostic of e.body.diagnostics) {
if (diagnostic.path) {
if (!errorsByPath[diagnostic.path]) {
errorsByPath[diagnostic.path] = [];
}
errorsByPath[compileError.path].push(compileError);
errorsByPath[diagnostic.path].push(diagnostic);
}
}
for (const path in errorsByPath) {
Expand All @@ -177,8 +181,7 @@ export class LogOutputManager {
methods[severity](message);
}

public async addDiagnosticForError(path: string, compileErrors: BrightScriptDebugCompileError[]) {

public async addDiagnosticForError(path: string, diagnostics: BSDebugDiagnostic[]) {
//TODO get the actual folder
let documentUri: vscode.Uri;
let uri = vscode.Uri.file(path);
Expand All @@ -193,25 +196,21 @@ export class LogOutputManager {
// const currentDocumentUri = document.uri;
// console.log("currentDocumentUri " + currentDocumentUri);
if (documentUri !== undefined) {
let diagnostics: vscode.Diagnostic[] = [];
for (const compileError of compileErrors) {

const path: string = compileError.path;
const message: string = compileError.message;
const source: string = compileError.errorText;
const lineNumber: number = compileError.lineNumber;
const charStart: number = compileError.charStart;
const charEnd: number = compileError.charEnd;

diagnostics.push({
code: '',
message: message,
range: new vscode.Range(new vscode.Position(lineNumber, charStart), new vscode.Position(lineNumber, charEnd)),
severity: vscode.DiagnosticSeverity.Error,
source: source
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, diagnostics);
this.collection.set(documentUri, result);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/extension.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ describe('extension', () => {
});

describe('debugSessionCustomEventHandler', () => {
describe('BSChannelPublishedEvent', () => {
describe('ChannelPublishedEvent', () => {
const e = {
event: 'BSChannelPublishedEvent',
event: 'ChannelPublishedEvent',
body: {
launchConfiguration: config
}
Expand Down
Loading