Skip to content

Commit

Permalink
Remove unused debug console method
Browse files Browse the repository at this point in the history
  • Loading branch information
roblourens committed Feb 17, 2022
1 parent 6d7f74b commit f271bbe
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 88 deletions.
4 changes: 0 additions & 4 deletions src/vs/workbench/contrib/debug/browser/debugSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1300,8 +1300,4 @@ export class DebugSession implements IDebugSession {
appendToRepl(data: string | IExpression, severity: severity, source?: IReplElementSource): void {
this.repl.appendToRepl(this, data, severity, source);
}

logToRepl(sev: severity, args: any[], frame?: { uri: URI; line: number; column: number }) {
this.repl.logToRepl(this, sev, args, frame);
}
}
1 change: 0 additions & 1 deletion src/vs/workbench/contrib/debug/common/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,6 @@ export interface IDebugSession extends ITreeElement {
removeReplExpressions(): void;
addReplExpression(stackFrame: IStackFrame | undefined, name: string): Promise<void>;
appendToRepl(data: string | IExpression, severity: severity, source?: IReplElementSource): void;
logToRepl(sev: severity, args: any[], frame?: { uri: uri; line: number; column: number }): void;

// session events
readonly onDidEndAdapter: Event<AdapterEndEvent | undefined>;
Expand Down
85 changes: 5 additions & 80 deletions src/vs/workbench/contrib/debug/common/replModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import * as nls from 'vs/nls';
import { Emitter, Event } from 'vs/base/common/event';
import severity from 'vs/base/common/severity';
import { IReplElement, IStackFrame, IExpression, IReplElementSource, IDebugSession, IDebugConfiguration } from 'vs/workbench/contrib/debug/common/debug';
import { ExpressionContainer } from 'vs/workbench/contrib/debug/common/debugModel';
import { isString, isUndefinedOrNull, isObject } from 'vs/base/common/types';
import { basenameOrAuthority } from 'vs/base/common/resources';
import { URI } from 'vs/base/common/uri';
import { isObject, isString } from 'vs/base/common/types';
import { generateUuid } from 'vs/base/common/uuid';
import { Emitter, Event } from 'vs/base/common/event';
import * as nls from 'vs/nls';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IDebugConfiguration, IDebugSession, IExpression, IReplElement, IReplElementSource, IStackFrame } from 'vs/workbench/contrib/debug/common/debug';
import { ExpressionContainer } from 'vs/workbench/contrib/debug/common/debugModel';

const MAX_REPL_LENGTH = 10000;
let topReplElementCounter = 0;
Expand Down Expand Up @@ -289,79 +287,6 @@ export class ReplModel {
this._onDidChangeElements.fire();
}

logToRepl(session: IDebugSession, sev: severity, args: any[], frame?: { uri: URI; line: number; column: number }) {

let source: IReplElementSource | undefined;
if (frame) {
source = {
column: frame.column,
lineNumber: frame.line,
source: session.getSource({
name: basenameOrAuthority(frame.uri),
path: frame.uri.fsPath
})
};
}

// add output for each argument logged
let simpleVals: any[] = [];
for (let i = 0; i < args.length; i++) {
const a = args[i];

// undefined gets printed as 'undefined'
if (typeof a === 'undefined') {
simpleVals.push('undefined');
}

// null gets printed as 'null'
else if (a === null) {
simpleVals.push('null');
}

// objects & arrays are special because we want to inspect them in the REPL
else if (isObject(a) || Array.isArray(a)) {

// flush any existing simple values logged
if (simpleVals.length) {
this.appendToRepl(session, simpleVals.join(' '), sev, source);
simpleVals = [];
}

// show object
this.appendToRepl(session, new RawObjectReplElement(getUniqueId(), (<any>a).prototype, a, undefined, nls.localize('snapshotObj', "Only primitive values are shown for this object.")), sev, source);
}

// string: watch out for % replacement directive
// string substitution and formatting @ https://developer.chrome.com/devtools/docs/console
else if (typeof a === 'string') {
let buf = '';

for (let j = 0, len = a.length; j < len; j++) {
if (a[j] === '%' && (a[j + 1] === 's' || a[j + 1] === 'i' || a[j + 1] === 'd' || a[j + 1] === 'O')) {
i++; // read over substitution
buf += !isUndefinedOrNull(args[i]) ? args[i] : ''; // replace
j++; // read over directive
} else {
buf += a[j];
}
}

simpleVals.push(buf);
}

// number or boolean is joined together
else {
simpleVals.push(a);
}
}

// flush simple values
// always append a new line for output coming from an extension such that separate logs go to separate lines #23695
if (simpleVals.length) {
this.appendToRepl(session, simpleVals.join(' ') + '\n', sev, source);
}
}

removeReplExpressions(): void {
if (this.replElements.length > 0) {
this.replElements = [];
Expand Down
3 changes: 0 additions & 3 deletions src/vs/workbench/contrib/debug/test/browser/mockDebug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,6 @@ export class MockDebugService implements IDebugService {
throw new Error('not implemented');
}

logToRepl(session: IDebugSession, value: string): void { }

sourceIsNotAvailable(uri: uri): void { }

tryToAutoFocusStackFrame(thread: IThread): Promise<any> {
Expand Down Expand Up @@ -246,7 +244,6 @@ export class MockSession implements IDebugSession {
}

appendToRepl(data: string | IExpression, severity: Severity, source?: IReplElementSource): void { }
logToRepl(sev: Severity, args: any[], frame?: { uri: uri; line: number; column: number }) { }

configuration: IConfig = { type: 'mock', name: 'mock', request: 'launch' };
unresolvedConfiguration: IConfig = { type: 'mock', name: 'mock', request: 'launch' };
Expand Down

0 comments on commit f271bbe

Please sign in to comment.