Merge from vscode 8e0f348413f4f616c23a88ae30030efa85811973 (#6381)

* Merge from vscode 8e0f348413f4f616c23a88ae30030efa85811973

* disable strict null check
This commit is contained in:
Anthony Dresser
2019-07-15 22:35:46 -07:00
committed by GitHub
parent f720ec642f
commit 0b7e7ddbf9
2406 changed files with 59140 additions and 35464 deletions

View File

@@ -23,6 +23,7 @@ import { commonSuffixLength } from 'vs/base/common/strings';
import { posix } from 'vs/base/common/path';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
import { ITextEditor } from 'vs/workbench/common/editor';
export class SimpleReplElement implements IReplElement {
constructor(
@@ -89,7 +90,7 @@ export class RawObjectReplElement implements IExpression {
export class ExpressionContainer implements IExpressionContainer {
public static allValues: Map<string, string> = new Map<string, string>();
public static allValues = new Map<string, string>();
// Use chunks to support variable paging #9537
private static readonly BASE_CHUNK_SIZE = 100;
@@ -123,7 +124,7 @@ export class ExpressionContainer implements IExpressionContainer {
return this.children;
}
private doGetChildren(): Promise<IExpression[]> {
private async doGetChildren(): Promise<IExpression[]> {
if (!this.hasChildren) {
return Promise.resolve([]);
}
@@ -133,29 +134,28 @@ export class ExpressionContainer implements IExpressionContainer {
}
// Check if object has named variables, fetch them independent from indexed variables #9670
const childrenThenable = !!this.namedVariables ? this.fetchVariables(undefined, undefined, 'named') : Promise.resolve([]);
return childrenThenable.then(childrenArray => {
// Use a dynamic chunk size based on the number of elements #9774
let chunkSize = ExpressionContainer.BASE_CHUNK_SIZE;
while (!!this.indexedVariables && this.indexedVariables > chunkSize * ExpressionContainer.BASE_CHUNK_SIZE) {
chunkSize *= ExpressionContainer.BASE_CHUNK_SIZE;
const children = this.namedVariables ? await this.fetchVariables(undefined, undefined, 'named') : [];
// Use a dynamic chunk size based on the number of elements #9774
let chunkSize = ExpressionContainer.BASE_CHUNK_SIZE;
while (!!this.indexedVariables && this.indexedVariables > chunkSize * ExpressionContainer.BASE_CHUNK_SIZE) {
chunkSize *= ExpressionContainer.BASE_CHUNK_SIZE;
}
if (!!this.indexedVariables && this.indexedVariables > chunkSize) {
// There are a lot of children, create fake intermediate values that represent chunks #9537
const numberOfChunks = Math.ceil(this.indexedVariables / chunkSize);
for (let i = 0; i < numberOfChunks; i++) {
const start = (this.startOfVariables || 0) + i * chunkSize;
const count = Math.min(chunkSize, this.indexedVariables - i * chunkSize);
children.push(new Variable(this.session, this, this.reference, `[${start}..${start + count - 1}]`, '', '', undefined, count, { kind: 'virtual' }, undefined, true, start));
}
if (!!this.indexedVariables && this.indexedVariables > chunkSize) {
// There are a lot of children, create fake intermediate values that represent chunks #9537
const numberOfChunks = Math.ceil(this.indexedVariables / chunkSize);
for (let i = 0; i < numberOfChunks; i++) {
const start = (this.startOfVariables || 0) + i * chunkSize;
const count = Math.min(chunkSize, this.indexedVariables - i * chunkSize);
childrenArray.push(new Variable(this.session, this, this.reference, `[${start}..${start + count - 1}]`, '', '', undefined, count, { kind: 'virtual' }, undefined, true, start));
}
return children;
}
return childrenArray;
}
return this.fetchVariables(this.startOfVariables, this.indexedVariables, 'indexed')
.then(variables => childrenArray.concat(variables));
});
const variables = await this.fetchVariables(this.startOfVariables, this.indexedVariables, 'indexed');
return children.concat(variables);
}
getId(): string {
@@ -213,7 +213,7 @@ export class Expression extends ExpressionContainer implements IExpression {
}
}
evaluate(session: IDebugSession | undefined, stackFrame: IStackFrame | undefined, context: string): Promise<void> {
async evaluate(session: IDebugSession | undefined, stackFrame: IStackFrame | undefined, context: string): Promise<void> {
if (!session || (!stackFrame && context !== 'repl')) {
this.value = context === 'repl' ? nls.localize('startDebugFirst', "Please start a debug session to evaluate expressions") : Expression.DEFAULT_VALUE;
this.available = false;
@@ -223,7 +223,8 @@ export class Expression extends ExpressionContainer implements IExpression {
}
this.session = session;
return session.evaluate(this.name, stackFrame ? stackFrame.frameId : undefined, context).then(response => {
try {
const response = await session.evaluate(this.name, stackFrame ? stackFrame.frameId : undefined, context);
this.available = !!(response && response.body);
if (response && response.body) {
this.value = response.body.result;
@@ -232,11 +233,11 @@ export class Expression extends ExpressionContainer implements IExpression {
this.indexedVariables = response.body.indexedVariables;
this.type = response.body.type || this.type;
}
}, err => {
this.value = err.message;
} catch (e) {
this.value = e.message;
this.available = false;
this.reference = 0;
});
}
}
toString(): string {
@@ -267,12 +268,13 @@ export class Variable extends ExpressionContainer implements IExpression {
this.value = value;
}
setVariable(value: string): Promise<any> {
async setVariable(value: string): Promise<any> {
if (!this.session) {
return Promise.resolve(undefined);
}
return this.session.setVariable((<ExpressionContainer>this.parent).reference, this.name, value).then(response => {
try {
const response = await this.session.setVariable((<ExpressionContainer>this.parent).reference, this.name, value);
if (response && response.body) {
this.value = response.body.value;
this.type = response.body.type || this.type;
@@ -280,9 +282,9 @@ export class Variable extends ExpressionContainer implements IExpression {
this.namedVariables = response.body.namedVariables;
this.indexedVariables = response.body.indexedVariables;
}
}, err => {
} catch (err) {
this.errorMessage = err.message;
});
}
}
toString(): string {
@@ -302,7 +304,7 @@ export class Scope extends ExpressionContainer implements IScope {
indexedVariables?: number,
public range?: IRange
) {
super(stackFrame.thread.session, reference, `scope:${stackFrame.getId()}:${name}:${index}`, namedVariables, indexedVariables);
super(stackFrame.thread.session, reference, `scope:${name}:${index}`, namedVariables, indexedVariables);
}
toString(): string {
@@ -312,7 +314,7 @@ export class Scope extends ExpressionContainer implements IScope {
export class StackFrame implements IStackFrame {
private scopes: Promise<Scope[]> | null;
private scopes: Promise<Scope[]> | undefined;
constructor(
public thread: IThread,
@@ -322,9 +324,7 @@ export class StackFrame implements IStackFrame {
public presentationHint: string | undefined,
public range: IRange,
private index: number
) {
this.scopes = null;
}
) { }
getId(): string {
return `stackframe:${this.thread.getId()}:${this.frameId}:${this.index}`;
@@ -380,6 +380,10 @@ export class StackFrame implements IStackFrame {
return this.thread.session.restartFrame(this.frameId, this.thread.threadId);
}
forgetScopes(): void {
this.scopes = undefined;
}
toString(): string {
const lineNumberToString = typeof this.range.startLineNumber === 'number' ? `:${this.range.startLineNumber}` : '';
const sourceToString = `${this.source.inMemory ? this.source.name : this.source.uri.fsPath}${lineNumberToString}`;
@@ -387,7 +391,7 @@ export class StackFrame implements IStackFrame {
return sourceToString === UNKNOWN_SOURCE_LABEL ? this.name : `${this.name} (${sourceToString})`;
}
openInEditor(editorService: IEditorService, preserveFocus?: boolean, sideBySide?: boolean, pinned?: boolean): Promise<any> {
openInEditor(editorService: IEditorService, preserveFocus?: boolean, sideBySide?: boolean, pinned?: boolean): Promise<ITextEditor | null> {
return !this.source.available ? Promise.resolve(null) :
this.source.openInEditor(editorService, this.range, preserveFocus, sideBySide, pinned);
}
@@ -659,6 +663,13 @@ export class Breakpoint extends BaseBreakpoint implements IBreakpoint {
return data ? data.endColumn : undefined;
}
get sessionAgnosticData(): { lineNumber: number, column: number | undefined } {
return {
lineNumber: this._lineNumber,
column: this._column
};
}
setSessionData(sessionId: string, data: DebugProtocol.Breakpoint): void {
super.setSessionData(sessionId, data);
if (!this._adapterData) {
@@ -954,10 +965,10 @@ export class DebugModel implements IDebugModel {
this._onDidChangeBreakpoints.fire({ removed: toRemove });
}
updateBreakpoints(data: { [id: string]: IBreakpointUpdateData }): void {
updateBreakpoints(data: Map<string, IBreakpointUpdateData>): void {
const updated: IBreakpoint[] = [];
this.breakpoints.forEach(bp => {
const bpData = data[bp.getId()];
const bpData = data.get(bp.getId());
if (bpData) {
bp.update(bpData);
updated.push(bp);
@@ -967,15 +978,15 @@ export class DebugModel implements IDebugModel {
this._onDidChangeBreakpoints.fire({ changed: updated });
}
setBreakpointSessionData(sessionId: string, data: { [id: string]: DebugProtocol.Breakpoint }): void {
setBreakpointSessionData(sessionId: string, data: Map<string, DebugProtocol.Breakpoint>): void {
this.breakpoints.forEach(bp => {
const bpData = data[bp.getId()];
const bpData = data.get(bp.getId());
if (bpData) {
bp.setSessionData(sessionId, bpData);
}
});
this.functionBreakpoints.forEach(fbp => {
const fbpData = data[fbp.getId()];
const fbpData = data.get(fbp.getId());
if (fbpData) {
fbp.setSessionData(sessionId, fbpData);
}