Skip to content
This repository has been archived by the owner on Oct 2, 2021. It is now read-only.

Commit

Permalink
Fix #131
Browse files Browse the repository at this point in the history
  • Loading branch information
roblourens committed Dec 3, 2016
1 parent d2e57d4 commit 674fd27
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
11 changes: 4 additions & 7 deletions src/chrome/chromeDebugAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import Crdp from '../../crdp/crdp';
import {PropertyContainer, ScopeContainer, IVariableContainer, ExceptionContainer, isIndexedPropName} from './variables';
import * as Variables from './variables';

import {formatConsoleMessage} from './consoleHelper';
import * as errors from '../errors';
import * as utils from '../utils';
import * as logger from '../logger';
Expand Down Expand Up @@ -535,12 +534,10 @@ export abstract class ChromeDebugAdapter implements IDebugAdapter {
}

protected onConsoleAPICalled(params: Crdp.Runtime.ConsoleAPICalledEvent): void {
const formattedMessage = formatConsoleMessage(params);
if (formattedMessage) {
this._session.sendEvent(new OutputEvent(
formattedMessage.text + '\n',
formattedMessage.isError ? 'stderr' : 'stdout'));
}
const e: DebugProtocol.OutputEvent = new OutputEvent('', 'stdout');
e.body.variablesReference = this._variableHandles.create(new Variables.LoggedObjects(params.args));

this._session.sendEvent(e);
}

/**
Expand Down
18 changes: 15 additions & 3 deletions src/chrome/variables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,24 @@ import * as DebugProtocol from 'vscode-debugadapter';

import {ChromeDebugAdapter} from './chromeDebugAdapter';
import Crdp from '../../crdp/crdp';
import * as utils from '../utils';

export interface IVariableContainer {
objectId: string;
expand(adapter: ChromeDebugAdapter, filter?: string, start?: number, count?: number): Promise<DebugProtocol.Variable[]>;
setValue(adapter: ChromeDebugAdapter, name: string, value: string): Promise<string>;
}

export abstract class BaseVariableContainer implements IVariableContainer {
constructor(public objectId: string, protected evaluateName?: string) {
constructor(protected objectId: string, protected evaluateName?: string) {
}

public expand(adapter: ChromeDebugAdapter, filter?: string, start?: number, count?: number): Promise<DebugProtocol.Variable[]> {
return adapter.getVariablesForObjectId(this.objectId, this.evaluateName, filter, start, count);
}

public abstract setValue(adapter: ChromeDebugAdapter, name: string, value: string): Promise<string>;
public setValue(adapter: ChromeDebugAdapter, name: string, value: string): Promise<string> {
return utils.errP('setValue not supported by this variable type');
}
}

export class PropertyContainer extends BaseVariableContainer {
Expand All @@ -30,6 +32,16 @@ export class PropertyContainer extends BaseVariableContainer {
}
}

export class LoggedObjects extends BaseVariableContainer {
constructor(private args: Crdp.Runtime.RemoteObject[]) {
super(undefined);
}

public expand(adapter: ChromeDebugAdapter, filter?: string, start?: number, count?: number): Promise<DebugProtocol.Variable[]> {
return Promise.all(this.args.map(arg => adapter.remoteObjectToVariable('', arg)));
}
}

export class ScopeContainer extends BaseVariableContainer {
private _thisObj: Crdp.Runtime.RemoteObject;
private _returnValue: Crdp.Runtime.RemoteObject;
Expand Down

0 comments on commit 674fd27

Please sign in to comment.