提交 6acf1a2a 编写于 作者: I isidor

debug: use readonly more

fixes #48064
上级 8745c1f8
......@@ -145,7 +145,7 @@ export interface IProcess extends ITreeElement {
readonly state: ProcessState;
getSourceForUri(modelUri: uri): Source;
getThread(threadId: number): IThread;
getAllThreads(): IThread[];
getAllThreads(): ReadonlyArray<IThread>;
getSource(raw: DebugProtocol.Source): Source;
completions(frameId: number, text: string, position: Position, overwriteBefore: number): TPromise<ISuggestion[]>;
}
......@@ -225,57 +225,57 @@ export interface IStackFrame extends ITreeElement {
}
export interface IEnablement extends ITreeElement {
enabled: boolean;
readonly enabled: boolean;
}
export interface IBreakpointData {
id?: string;
lineNumber: number;
column?: number;
enabled?: boolean;
condition?: string;
logMessage?: string;
hitCondition?: string;
readonly id?: string;
readonly lineNumber: number;
readonly column?: number;
readonly enabled?: boolean;
readonly condition?: string;
readonly logMessage?: string;
readonly hitCondition?: string;
}
export interface IBreakpointUpdateData extends DebugProtocol.Breakpoint {
condition?: string;
hitCondition?: string;
logMessage?: string;
readonly condition?: string;
readonly hitCondition?: string;
readonly logMessage?: string;
}
export interface IBaseBreakpoint extends IEnablement {
condition: string;
hitCondition: string;
logMessage: string;
verified: boolean;
idFromAdapter: number;
readonly condition: string;
readonly hitCondition: string;
readonly logMessage: string;
readonly verified: boolean;
readonly idFromAdapter: number;
}
export interface IBreakpoint extends IBaseBreakpoint {
uri: uri;
lineNumber: number;
endLineNumber?: number;
column: number;
endColumn?: number;
message: string;
adapterData: any;
readonly uri: uri;
readonly lineNumber: number;
readonly endLineNumber?: number;
readonly column: number;
readonly endColumn?: number;
readonly message: string;
readonly adapterData: any;
}
export interface IFunctionBreakpoint extends IBaseBreakpoint {
name: string;
readonly name: string;
}
export interface IExceptionBreakpoint extends IEnablement {
filter: string;
label: string;
readonly filter: string;
readonly label: string;
}
export interface IExceptionInfo {
id?: string;
description?: string;
breakMode: string;
details?: DebugProtocol.ExceptionDetails;
readonly id?: string;
readonly description?: string;
readonly breakMode: string;
readonly details?: DebugProtocol.ExceptionDetails;
}
// model interfaces
......@@ -284,17 +284,18 @@ export interface IViewModel extends ITreeElement {
/**
* Returns the focused debug process or null if no process is stopped.
*/
focusedProcess: IProcess;
readonly focusedProcess: IProcess;
/**
* Returns the focused thread or null if no thread is stopped.
*/
focusedThread: IThread;
readonly focusedThread: IThread;
/**
* Returns the focused stack frame or null if there are no stack frames.
*/
focusedStackFrame: IStackFrame;
readonly focusedStackFrame: IStackFrame;
getSelectedExpression(): IExpression;
getSelectedFunctionBreakpoint(): IFunctionBreakpoint;
setSelectedExpression(expression: IExpression): void;
......@@ -409,8 +410,8 @@ export interface IDebugAdapterProvider extends ITerminalLauncher {
}
export interface IAdapterExecutable {
command?: string;
args?: string[];
readonly command?: string;
readonly args?: string[];
}
export interface IPlatformSpecificAdapterContribution {
......@@ -446,7 +447,7 @@ export interface IDebuggerContribution extends IPlatformSpecificAdapterContribut
}
export interface IDebugConfigurationProvider {
type: string;
readonly type: string;
handle: number;
resolveDebugConfiguration?(folderUri: uri | undefined, debugConfiguration: IConfig): TPromise<IConfig>;
provideDebugConfigurations?(folderUri: uri | undefined): TPromise<IConfig[]>;
......
......@@ -966,6 +966,10 @@ export class Model implements IModel {
this._onDidChangeBreakpoints.fire({ changed: updated });
}
public unverifyBreakpoints(): void {
this.breakpoints.forEach(bp => bp.verified = false);
}
private sortAndDeDup(): void {
this.breakpoints = this.breakpoints.sort((first, second) => {
if (first.uri.toString() !== second.uri.toString()) {
......@@ -981,19 +985,20 @@ export class Model implements IModel {
}
public setEnablement(element: IEnablement, enable: boolean): void {
if (element instanceof Breakpoint || element instanceof FunctionBreakpoint || element instanceof ExceptionBreakpoint) {
const changed: (IBreakpoint | IFunctionBreakpoint)[] = [];
if (element.enabled !== enable && (element instanceof Breakpoint || element instanceof FunctionBreakpoint)) {
changed.push(element);
}
const changed: (IBreakpoint | IFunctionBreakpoint)[] = [];
if (element.enabled !== enable && (element instanceof Breakpoint || element instanceof FunctionBreakpoint)) {
changed.push(element);
}
element.enabled = enable;
if (element instanceof Breakpoint && !element.enabled) {
const breakpoint = <Breakpoint>element;
breakpoint.verified = false;
}
element.enabled = enable;
if (element instanceof Breakpoint && !element.enabled) {
const breakpoint = <Breakpoint>element;
breakpoint.verified = false;
this._onDidChangeBreakpoints.fire({ changed: changed });
}
this._onDidChangeBreakpoints.fire({ changed: changed });
}
public enableOrDisableAllBreakpoints(enable: boolean): void {
......
......@@ -39,7 +39,17 @@ export class ViewModel implements IViewModel {
}
public get focusedThread(): IThread {
return this._focusedStackFrame ? this._focusedStackFrame.thread : (this._focusedProcess ? this._focusedProcess.getAllThreads().pop() : null);
if (this._focusedStackFrame) {
return this._focusedStackFrame.thread;
}
if (this._focusedProcess) {
const threads = this._focusedProcess.getAllThreads();
if (threads && threads.length) {
return threads[threads.length - 1];
}
}
return undefined;
}
public get focusedStackFrame(): IStackFrame {
......
......@@ -696,7 +696,7 @@ export class DebugService implements debug.IDebugService {
if (this.model.getProcesses().length === 0) {
this.removeReplExpressions();
this.allProcesses.clear();
this.model.getBreakpoints().forEach(bp => bp.verified = false);
this.model.unverifyBreakpoints();
}
this.launchJsonChanged = false;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册