debug: use Set and Map
This commit is contained in:
parent
ebaed955b9
commit
140f1ec0a3
5 changed files with 47 additions and 51 deletions
|
@ -91,7 +91,7 @@ export class OutputNameValueElement extends AbstractOutputElement implements deb
|
|||
|
||||
export class ExpressionContainer implements debug.IExpressionContainer {
|
||||
|
||||
public static allValues: { [id: string]: string } = {};
|
||||
public static allValues: Map<string, string> = new Map<string, string>();
|
||||
// Use chunks to support variable paging #9537
|
||||
private static BASE_CHUNK_SIZE = 100;
|
||||
|
||||
|
@ -174,9 +174,9 @@ export class ExpressionContainer implements debug.IExpressionContainer {
|
|||
|
||||
public set value(value: string) {
|
||||
this._value = value;
|
||||
this.valueChanged = ExpressionContainer.allValues[this.getId()] &&
|
||||
ExpressionContainer.allValues[this.getId()] !== Expression.DEFAULT_VALUE && ExpressionContainer.allValues[this.getId()] !== value;
|
||||
ExpressionContainer.allValues[this.getId()] = value;
|
||||
this.valueChanged = ExpressionContainer.allValues.get(this.getId()) &&
|
||||
ExpressionContainer.allValues.get(this.getId()) !== Expression.DEFAULT_VALUE && ExpressionContainer.allValues.get(this.getId()) !== value;
|
||||
ExpressionContainer.allValues.set(this.getId(), value);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -551,7 +551,7 @@ export class Process implements debug.IProcess {
|
|||
|
||||
if (removeThreads) {
|
||||
this.threads.clear();
|
||||
ExpressionContainer.allValues = {};
|
||||
ExpressionContainer.allValues.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,12 +17,12 @@ export class ReplHistory {
|
|||
|
||||
private historyPointer: number;
|
||||
private currentExpressionStoredMarkers: boolean;
|
||||
private historyOverwrites: { [position: string]: string; };
|
||||
private historyOverwrites: Map<string, string>;
|
||||
|
||||
constructor(private history: string[]) {
|
||||
this.historyPointer = this.history.length;
|
||||
this.currentExpressionStoredMarkers = false;
|
||||
this.historyOverwrites = {};
|
||||
this.historyOverwrites = new Map<string, string>();
|
||||
}
|
||||
|
||||
public next(): string {
|
||||
|
@ -48,8 +48,8 @@ export class ReplHistory {
|
|||
this.historyPointer = newPointer;
|
||||
|
||||
// check for overwrite
|
||||
if (this.historyOverwrites && this.historyOverwrites[newPointer.toString()]) {
|
||||
return this.historyOverwrites[newPointer.toString()];
|
||||
if (this.historyOverwrites.has(newPointer.toString())) {
|
||||
return this.historyOverwrites.get(newPointer.toString());
|
||||
}
|
||||
|
||||
return this.history[newPointer];
|
||||
|
@ -78,11 +78,7 @@ export class ReplHistory {
|
|||
|
||||
// keep edits that are made to history items up until the user actually evaluates a expression
|
||||
else {
|
||||
if (!this.historyOverwrites) {
|
||||
this.historyOverwrites = {};
|
||||
}
|
||||
|
||||
this.historyOverwrites[previousPointer.toString()] = expression;
|
||||
this.historyOverwrites.set(previousPointer.toString(), expression);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -104,7 +100,7 @@ export class ReplHistory {
|
|||
this.currentExpressionStoredMarkers = false;
|
||||
|
||||
// reset overwrites
|
||||
this.historyOverwrites = null;
|
||||
this.historyOverwrites.clear();
|
||||
}
|
||||
|
||||
public save(): string[] {
|
||||
|
|
|
@ -193,7 +193,7 @@ jsonRegistry.registerSchema(schemaId, schema);
|
|||
|
||||
export class ConfigurationManager implements debug.IConfigurationManager {
|
||||
private adapters: Adapter[];
|
||||
private allModeIdsForBreakpoints: { [key: string]: boolean };
|
||||
private breakpointModeIdsSet: Set<string>;
|
||||
|
||||
constructor(
|
||||
@IWorkspaceContextService private contextService: IWorkspaceContextService,
|
||||
|
@ -208,7 +208,7 @@ export class ConfigurationManager implements debug.IConfigurationManager {
|
|||
) {
|
||||
this.adapters = [];
|
||||
this.registerListeners();
|
||||
this.allModeIdsForBreakpoints = {};
|
||||
this.breakpointModeIdsSet = new Set<string>();
|
||||
}
|
||||
|
||||
private registerListeners(): void {
|
||||
|
@ -220,7 +220,7 @@ export class ConfigurationManager implements debug.IConfigurationManager {
|
|||
}
|
||||
if (rawAdapter.enableBreakpointsFor) {
|
||||
rawAdapter.enableBreakpointsFor.languageIds.forEach(modeId => {
|
||||
this.allModeIdsForBreakpoints[modeId] = true;
|
||||
this.breakpointModeIdsSet.add(modeId);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -250,7 +250,7 @@ export class ConfigurationManager implements debug.IConfigurationManager {
|
|||
breakpointsExtPoint.setHandler(extensions => {
|
||||
extensions.forEach(ext => {
|
||||
ext.value.forEach(breakpoints => {
|
||||
this.allModeIdsForBreakpoints[breakpoints.language] = true;
|
||||
this.breakpointModeIdsSet.add(breakpoints.language);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -386,6 +386,6 @@ export class ConfigurationManager implements debug.IConfigurationManager {
|
|||
const mode = model ? model.getMode() : null;
|
||||
const modeId = mode ? mode.getId() : null;
|
||||
|
||||
return !!this.allModeIdsForBreakpoints[modeId];
|
||||
return this.breakpointModeIdsSet.has(modeId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ const DEBUG_SELECTED_CONFIG_NAME_KEY = 'debug.selectedconfigname';
|
|||
export class DebugService implements debug.IDebugService {
|
||||
public _serviceBrand: any;
|
||||
|
||||
private sessionStates: { [id: string]: debug.State };
|
||||
private sessionStates: Map<string, debug.State>;
|
||||
private _onDidChangeState: Emitter<void>;
|
||||
private model: Model;
|
||||
private viewModel: ViewModel;
|
||||
|
@ -67,9 +67,9 @@ export class DebugService implements debug.IDebugService {
|
|||
private customTelemetryService: ITelemetryService;
|
||||
private lastTaskEvent: TaskEvent;
|
||||
private toDispose: lifecycle.IDisposable[];
|
||||
private toDisposeOnSessionEnd: { [id: string]: lifecycle.IDisposable[] };
|
||||
private toDisposeOnSessionEnd: Map<string, lifecycle.IDisposable[]>;
|
||||
private inDebugMode: IContextKey<boolean>;
|
||||
private breakpointsToSendOnResourceSaved: { [uri: string]: boolean };
|
||||
private breakpointsToSendOnResourceSaved: Set<string>;
|
||||
|
||||
constructor(
|
||||
@IStorageService private storageService: IStorageService,
|
||||
|
@ -93,10 +93,10 @@ export class DebugService implements debug.IDebugService {
|
|||
@IConfigurationService private configurationService: IConfigurationService
|
||||
) {
|
||||
this.toDispose = [];
|
||||
this.toDisposeOnSessionEnd = {};
|
||||
this.breakpointsToSendOnResourceSaved = {};
|
||||
this.toDisposeOnSessionEnd = new Map<string, lifecycle.IDisposable[]>();
|
||||
this.breakpointsToSendOnResourceSaved = new Set<string>();
|
||||
this._onDidChangeState = new Emitter<void>();
|
||||
this.sessionStates = {};
|
||||
this.sessionStates = new Map<string, debug.State>();
|
||||
|
||||
this.configurationManager = this.instantiationService.createInstance(ConfigurationManager);
|
||||
this.inDebugMode = debug.CONTEXT_IN_DEBUG_MODE.bindTo(contextKeyService);
|
||||
|
@ -236,8 +236,8 @@ export class DebugService implements debug.IDebugService {
|
|||
}
|
||||
|
||||
private registerSessionListeners(process: Process, session: RawDebugSession): void {
|
||||
this.toDisposeOnSessionEnd[session.getId()].push(session);
|
||||
this.toDisposeOnSessionEnd[session.getId()].push(session.onDidInitialize(event => {
|
||||
this.toDisposeOnSessionEnd.get(session.getId()).push(session);
|
||||
this.toDisposeOnSessionEnd.get(session.getId()).push(session.onDidInitialize(event => {
|
||||
aria.status(nls.localize('debuggingStarted', "Debugging started."));
|
||||
const sendConfigurationDone = () => {
|
||||
if (session && session.configuration.capabilities.supportsConfigurationDoneRequest) {
|
||||
|
@ -255,7 +255,7 @@ export class DebugService implements debug.IDebugService {
|
|||
.done(() => this.fetchThreads(session), errors.onUnexpectedError);
|
||||
}));
|
||||
|
||||
this.toDisposeOnSessionEnd[session.getId()].push(session.onDidStop(event => {
|
||||
this.toDisposeOnSessionEnd.get(session.getId()).push(session.onDidStop(event => {
|
||||
this.setStateAndEmit(session.getId(), debug.State.Stopped);
|
||||
const threadId = event.body.threadId;
|
||||
|
||||
|
@ -290,7 +290,7 @@ export class DebugService implements debug.IDebugService {
|
|||
}, errors.onUnexpectedError);
|
||||
}));
|
||||
|
||||
this.toDisposeOnSessionEnd[session.getId()].push(session.onDidThread(event => {
|
||||
this.toDisposeOnSessionEnd.get(session.getId()).push(session.onDidThread(event => {
|
||||
if (event.body.reason === 'started') {
|
||||
this.fetchThreads(session).done(undefined, errors.onUnexpectedError);
|
||||
} else if (event.body.reason === 'exited') {
|
||||
|
@ -298,7 +298,7 @@ export class DebugService implements debug.IDebugService {
|
|||
}
|
||||
}));
|
||||
|
||||
this.toDisposeOnSessionEnd[session.getId()].push(session.onDidTerminateDebugee(event => {
|
||||
this.toDisposeOnSessionEnd.get(session.getId()).push(session.onDidTerminateDebugee(event => {
|
||||
aria.status(nls.localize('debuggingStopped', "Debugging stopped."));
|
||||
if (session && session.getId() === event.body.sessionId) {
|
||||
if (event.body && typeof event.body.restart === 'boolean' && event.body.restart) {
|
||||
|
@ -309,7 +309,7 @@ export class DebugService implements debug.IDebugService {
|
|||
}
|
||||
}));
|
||||
|
||||
this.toDisposeOnSessionEnd[session.getId()].push(session.onDidContinued(event => {
|
||||
this.toDisposeOnSessionEnd.get(session.getId()).push(session.onDidContinued(event => {
|
||||
const threadId = event.body.allThreadsContinued ? undefined : event.body.threadId;
|
||||
this.model.clearThreads(session.getId(), false, threadId);
|
||||
if (this.viewModel.focusedProcess.getId() === session.getId()) {
|
||||
|
@ -318,7 +318,7 @@ export class DebugService implements debug.IDebugService {
|
|||
this.setStateAndEmit(session.getId(), session.requestType === debug.SessionRequestType.LAUNCH_NO_DEBUG ? debug.State.RunningNoDebug : debug.State.Running);
|
||||
}));
|
||||
|
||||
this.toDisposeOnSessionEnd[session.getId()].push(session.onDidOutput(event => {
|
||||
this.toDisposeOnSessionEnd.get(session.getId()).push(session.onDidOutput(event => {
|
||||
if (!event.body) {
|
||||
return;
|
||||
}
|
||||
|
@ -344,7 +344,7 @@ export class DebugService implements debug.IDebugService {
|
|||
}
|
||||
}));
|
||||
|
||||
this.toDisposeOnSessionEnd[session.getId()].push(session.onDidBreakpoint(event => {
|
||||
this.toDisposeOnSessionEnd.get(session.getId()).push(session.onDidBreakpoint(event => {
|
||||
const id = event.body && event.body.breakpoint ? event.body.breakpoint.id : undefined;
|
||||
const breakpoint = this.model.getBreakpoints().filter(bp => bp.idFromAdapter === id).pop();
|
||||
if (breakpoint) {
|
||||
|
@ -357,9 +357,9 @@ export class DebugService implements debug.IDebugService {
|
|||
}
|
||||
}));
|
||||
|
||||
this.toDisposeOnSessionEnd[session.getId()].push(session.onDidExitAdapter(event => {
|
||||
this.toDisposeOnSessionEnd.get(session.getId()).push(session.onDidExitAdapter(event => {
|
||||
// 'Run without debugging' mode VSCode must terminate the extension host. More details: #3905
|
||||
if (session && session.configuration.type === 'extensionHost' && this.sessionStates[session.getId()] === debug.State.RunningNoDebug) {
|
||||
if (session && session.configuration.type === 'extensionHost' && this.sessionStates.get(session.getId()) === debug.State.RunningNoDebug) {
|
||||
this.windowsService.closeExtensionHostWindow(this.contextService.getWorkspace().resource.fsPath);
|
||||
}
|
||||
if (session && session.getId() === event.body.sessionId) {
|
||||
|
@ -432,11 +432,11 @@ export class DebugService implements debug.IDebugService {
|
|||
|
||||
const focusedProcess = this.viewModel.focusedProcess;
|
||||
if (focusedProcess) {
|
||||
return this.sessionStates[focusedProcess.getId()];
|
||||
return this.sessionStates.get(focusedProcess.getId());
|
||||
}
|
||||
const processes = this.model.getProcesses();
|
||||
if (processes.length > 0) {
|
||||
return this.sessionStates[processes[0].getId()];
|
||||
return this.sessionStates.get(processes[0].getId());
|
||||
}
|
||||
|
||||
return debug.State.Inactive;
|
||||
|
@ -447,7 +447,7 @@ export class DebugService implements debug.IDebugService {
|
|||
}
|
||||
|
||||
private setStateAndEmit(sessionId: string, newState: debug.State): void {
|
||||
this.sessionStates[sessionId] = newState;
|
||||
this.sessionStates.set(sessionId, newState);
|
||||
this._onDidChangeState.fire();
|
||||
}
|
||||
|
||||
|
@ -664,9 +664,9 @@ export class DebugService implements debug.IDebugService {
|
|||
if (!this.viewModel.focusedProcess) {
|
||||
this.focusStackFrameAndEvaluate(null, process);
|
||||
}
|
||||
this.toDisposeOnSessionEnd[session.getId()] = [];
|
||||
this.toDisposeOnSessionEnd.set(session.getId(), []);
|
||||
if (client) {
|
||||
this.toDisposeOnSessionEnd[session.getId()].push(client);
|
||||
this.toDisposeOnSessionEnd.get(session.getId()).push(client);
|
||||
}
|
||||
this.registerSessionListeners(process, session);
|
||||
|
||||
|
@ -839,7 +839,7 @@ export class DebugService implements debug.IDebugService {
|
|||
});
|
||||
|
||||
try {
|
||||
this.toDisposeOnSessionEnd[session.getId()] = lifecycle.dispose(this.toDisposeOnSessionEnd[session.getId()]);
|
||||
this.toDisposeOnSessionEnd.set(session.getId(), lifecycle.dispose(this.toDisposeOnSessionEnd.get(session.getId())));
|
||||
} catch (e) {
|
||||
// an internal module might be open so the dispose can throw -> ignore and continue with stop session.
|
||||
}
|
||||
|
@ -896,7 +896,7 @@ export class DebugService implements debug.IDebugService {
|
|||
}
|
||||
if (this.textFileService.isDirty(modelUri)) {
|
||||
// Only send breakpoints for a file once it is not dirty #8077
|
||||
this.breakpointsToSendOnResourceSaved[modelUri.toString()] = true;
|
||||
this.breakpointsToSendOnResourceSaved.add(modelUri.toString());
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
|
@ -991,8 +991,8 @@ export class DebugService implements debug.IDebugService {
|
|||
fileChangesEvent.contains(bp.uri, FileChangeType.DELETED)));
|
||||
|
||||
fileChangesEvent.getUpdated().forEach(event => {
|
||||
if (this.breakpointsToSendOnResourceSaved[event.resource.toString()]) {
|
||||
this.breakpointsToSendOnResourceSaved[event.resource.toString()] = false;
|
||||
if (this.breakpointsToSendOnResourceSaved.has(event.resource.toString())) {
|
||||
this.breakpointsToSendOnResourceSaved.delete(event.resource.toString());
|
||||
this.sendBreakpoints(event.resource, true).done(null, errors.onUnexpectedError);
|
||||
}
|
||||
});
|
||||
|
@ -1008,7 +1008,7 @@ export class DebugService implements debug.IDebugService {
|
|||
}
|
||||
|
||||
public dispose(): void {
|
||||
Object.keys(this.toDisposeOnSessionEnd).forEach(key => lifecycle.dispose(this.toDisposeOnSessionEnd[key]));
|
||||
this.toDisposeOnSessionEnd.forEach(toDispose => lifecycle.dispose(toDispose));
|
||||
this.toDispose = lifecycle.dispose(this.toDispose);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,14 +13,14 @@ export abstract class V8Protocol {
|
|||
|
||||
private outputStream: stream.Writable;
|
||||
private sequence: number;
|
||||
private pendingRequests: { [id: number]: (e: DebugProtocol.Response) => void; };
|
||||
private pendingRequests: Map<number, (e: DebugProtocol.Response) => void>;
|
||||
private rawData: Buffer;
|
||||
private contentLength: number;
|
||||
|
||||
constructor(private id: string) {
|
||||
this.sequence = 1;
|
||||
this.contentLength = -1;
|
||||
this.pendingRequests = {};
|
||||
this.pendingRequests = new Map<number, (e: DebugProtocol.Response) => void>();
|
||||
this.rawData = new Buffer(0);
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,7 @@ export abstract class V8Protocol {
|
|||
|
||||
if (clb) {
|
||||
// store callback for this request
|
||||
this.pendingRequests[request.seq] = clb;
|
||||
this.pendingRequests.set(request.seq, clb);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -130,9 +130,9 @@ export abstract class V8Protocol {
|
|||
break;
|
||||
case 'response':
|
||||
const response = <DebugProtocol.Response>rawData;
|
||||
const clb = this.pendingRequests[response.request_seq];
|
||||
const clb = this.pendingRequests.get(response.request_seq);
|
||||
if (clb) {
|
||||
delete this.pendingRequests[response.request_seq];
|
||||
this.pendingRequests.delete(response.request_seq);
|
||||
clb(response);
|
||||
}
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue