mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Merge from vscode 817eb6b0c720a4ecbc13c020afbbebfed667aa09 (#7356)
This commit is contained in:
@@ -12,11 +12,11 @@ import { MockRawSession } from 'vs/workbench/contrib/debug/test/common/mockDebug
|
||||
import { Source } from 'vs/workbench/contrib/debug/common/debugSource';
|
||||
import { DebugSession } from 'vs/workbench/contrib/debug/browser/debugSession';
|
||||
import { SimpleReplElement, RawObjectReplElement, ReplEvaluationInput, ReplModel } from 'vs/workbench/contrib/debug/common/replModel';
|
||||
import { IBreakpointUpdateData } from 'vs/workbench/contrib/debug/common/debug';
|
||||
import { IBreakpointUpdateData, IDebugSessionOptions } from 'vs/workbench/contrib/debug/common/debug';
|
||||
import { NullOpenerService } from 'vs/platform/opener/common/opener';
|
||||
|
||||
function createMockSession(model: DebugModel, name = 'mockSession', parentSession?: DebugSession | undefined): DebugSession {
|
||||
return new DebugSession({ resolved: { name, type: 'node', request: 'launch' }, unresolved: undefined }, undefined!, model, parentSession, undefined!, undefined!, undefined!, undefined!, undefined!, undefined!, undefined!, undefined!, undefined!, NullOpenerService);
|
||||
function createMockSession(model: DebugModel, name = 'mockSession', options?: IDebugSessionOptions): DebugSession {
|
||||
return new DebugSession({ resolved: { name, type: 'node', request: 'launch' }, unresolved: undefined }, undefined!, model, options, undefined!, undefined!, undefined!, undefined!, undefined!, undefined!, undefined!, undefined!, undefined!, NullOpenerService);
|
||||
}
|
||||
|
||||
suite('Debug - Model', () => {
|
||||
@@ -110,6 +110,44 @@ suite('Debug - Model', () => {
|
||||
assert.equal(model.getFunctionBreakpoints().length, 0);
|
||||
});
|
||||
|
||||
test('breakpoints multiple sessions', () => {
|
||||
const modelUri = uri.file('/myfolder/myfile.js');
|
||||
const breakpoints = model.addBreakpoints(modelUri, [{ lineNumber: 5, enabled: true, condition: 'x > 5' }, { lineNumber: 10, enabled: false }]);
|
||||
const session = createMockSession(model);
|
||||
const data = new Map<string, DebugProtocol.Breakpoint>();
|
||||
|
||||
assert.equal(breakpoints[0].lineNumber, 5);
|
||||
assert.equal(breakpoints[1].lineNumber, 10);
|
||||
|
||||
data.set(breakpoints[0].getId(), { verified: false, line: 10 });
|
||||
data.set(breakpoints[1].getId(), { verified: true, line: 50 });
|
||||
model.setBreakpointSessionData(session.getId(), {}, data);
|
||||
assert.equal(breakpoints[0].lineNumber, 5);
|
||||
assert.equal(breakpoints[1].lineNumber, 50);
|
||||
|
||||
const session2 = createMockSession(model);
|
||||
const data2 = new Map<string, DebugProtocol.Breakpoint>();
|
||||
data2.set(breakpoints[0].getId(), { verified: true, line: 100 });
|
||||
data2.set(breakpoints[1].getId(), { verified: true, line: 500 });
|
||||
model.setBreakpointSessionData(session2.getId(), {}, data2);
|
||||
|
||||
// Breakpoint is verified only once, show that line
|
||||
assert.equal(breakpoints[0].lineNumber, 100);
|
||||
// Breakpoint is verified two times, show the original line
|
||||
assert.equal(breakpoints[1].lineNumber, 10);
|
||||
|
||||
model.setBreakpointSessionData(session.getId(), {}, undefined);
|
||||
// No more double session verification
|
||||
assert.equal(breakpoints[0].lineNumber, 100);
|
||||
assert.equal(breakpoints[1].lineNumber, 500);
|
||||
|
||||
assert.equal(breakpoints[0].supported, false);
|
||||
const data3 = new Map<string, DebugProtocol.Breakpoint>();
|
||||
data3.set(breakpoints[0].getId(), { verified: true, line: 500 });
|
||||
model.setBreakpointSessionData(session2.getId(), { supportsConditionalBreakpoints: true }, data2);
|
||||
assert.equal(breakpoints[0].supported, true);
|
||||
});
|
||||
|
||||
// Threads
|
||||
|
||||
test('threads simple', () => {
|
||||
@@ -341,10 +379,10 @@ suite('Debug - Model', () => {
|
||||
session['raw'] = <any>rawSession;
|
||||
const thread = new Thread(session, 'mockthread', 1);
|
||||
const stackFrame = new StackFrame(thread, 1, <any>undefined, 'app.js', 'normal', { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 10 }, 1);
|
||||
const replModel = new ReplModel(session);
|
||||
replModel.addReplExpression(stackFrame, 'myVariable').then();
|
||||
replModel.addReplExpression(stackFrame, 'myVariable').then();
|
||||
replModel.addReplExpression(stackFrame, 'myVariable').then();
|
||||
const replModel = new ReplModel();
|
||||
replModel.addReplExpression(session, stackFrame, 'myVariable').then();
|
||||
replModel.addReplExpression(session, stackFrame, 'myVariable').then();
|
||||
replModel.addReplExpression(session, stackFrame, 'myVariable').then();
|
||||
|
||||
assert.equal(replModel.getReplElements().length, 3);
|
||||
replModel.getReplElements().forEach(re => {
|
||||
@@ -405,13 +443,13 @@ suite('Debug - Model', () => {
|
||||
model.addSession(session);
|
||||
const secondSession = createMockSession(model, 'mockSession2');
|
||||
model.addSession(secondSession);
|
||||
const firstChild = createMockSession(model, 'firstChild', session);
|
||||
const firstChild = createMockSession(model, 'firstChild', { parentSession: session });
|
||||
model.addSession(firstChild);
|
||||
const secondChild = createMockSession(model, 'secondChild', session);
|
||||
const secondChild = createMockSession(model, 'secondChild', { parentSession: session });
|
||||
model.addSession(secondChild);
|
||||
const thirdSession = createMockSession(model, 'mockSession3');
|
||||
model.addSession(thirdSession);
|
||||
const anotherChild = createMockSession(model, 'secondChild', secondSession);
|
||||
const anotherChild = createMockSession(model, 'secondChild', { parentSession: secondSession });
|
||||
model.addSession(anotherChild);
|
||||
|
||||
const sessions = model.getSessions();
|
||||
@@ -426,8 +464,7 @@ suite('Debug - Model', () => {
|
||||
// Repl output
|
||||
|
||||
test('repl output', () => {
|
||||
const session = new DebugSession({ resolved: { name: 'mockSession', type: 'node', request: 'launch' }, unresolved: undefined }, undefined!, model, undefined, undefined!, undefined!, undefined!, undefined!, undefined!, undefined!, undefined!, undefined!, undefined!, NullOpenerService);
|
||||
const repl = new ReplModel(session);
|
||||
const repl = new ReplModel();
|
||||
repl.appendToRepl('first line\n', severity.Error);
|
||||
repl.appendToRepl('second line ', severity.Error);
|
||||
repl.appendToRepl('third line ', severity.Error);
|
||||
@@ -466,4 +503,41 @@ suite('Debug - Model', () => {
|
||||
assert.equal(elements[1], '23\n45\n');
|
||||
assert.equal(elements[2], '6');
|
||||
});
|
||||
|
||||
test('repl merging', () => {
|
||||
// 'mergeWithParent' should be ignored when there is no parent.
|
||||
const parent = createMockSession(model, 'parent', { repl: 'mergeWithParent' });
|
||||
const child1 = createMockSession(model, 'child1', { parentSession: parent, repl: 'separate' });
|
||||
const child2 = createMockSession(model, 'child2', { parentSession: parent, repl: 'mergeWithParent' });
|
||||
const grandChild = createMockSession(model, 'grandChild', { parentSession: child2, repl: 'mergeWithParent' });
|
||||
const child3 = createMockSession(model, 'child3', { parentSession: parent });
|
||||
|
||||
parent.appendToRepl('1\n', severity.Info);
|
||||
assert.equal(parent.getReplElements().length, 1);
|
||||
assert.equal(child1.getReplElements().length, 0);
|
||||
assert.equal(child2.getReplElements().length, 1);
|
||||
assert.equal(grandChild.getReplElements().length, 1);
|
||||
assert.equal(child3.getReplElements().length, 0);
|
||||
|
||||
grandChild.appendToRepl('1\n', severity.Info);
|
||||
assert.equal(parent.getReplElements().length, 2);
|
||||
assert.equal(child1.getReplElements().length, 0);
|
||||
assert.equal(child2.getReplElements().length, 2);
|
||||
assert.equal(grandChild.getReplElements().length, 2);
|
||||
assert.equal(child3.getReplElements().length, 0);
|
||||
|
||||
child3.appendToRepl('1\n', severity.Info);
|
||||
assert.equal(parent.getReplElements().length, 2);
|
||||
assert.equal(child1.getReplElements().length, 0);
|
||||
assert.equal(child2.getReplElements().length, 2);
|
||||
assert.equal(grandChild.getReplElements().length, 2);
|
||||
assert.equal(child3.getReplElements().length, 1);
|
||||
|
||||
child1.appendToRepl('1\n', severity.Info);
|
||||
assert.equal(parent.getReplElements().length, 2);
|
||||
assert.equal(child1.getReplElements().length, 1);
|
||||
assert.equal(child2.getReplElements().length, 2);
|
||||
assert.equal(grandChild.getReplElements().length, 2);
|
||||
assert.equal(child3.getReplElements().length, 1);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -7,7 +7,7 @@ import { URI as uri } from 'vs/base/common/uri';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { IWorkspaceFolder } from 'vs/platform/workspace/common/workspace';
|
||||
import { Position, IPosition } from 'vs/editor/common/core/position';
|
||||
import { ILaunch, IDebugService, State, IDebugSession, IConfigurationManager, IStackFrame, IBreakpointData, IBreakpointUpdateData, IConfig, IDebugModel, IViewModel, IBreakpoint, LoadedSourceEvent, IThread, IRawModelUpdate, IFunctionBreakpoint, IExceptionBreakpoint, IDebugger, IExceptionInfo, AdapterEndEvent, IReplElement, IExpression, IReplElementSource, IDataBreakpoint } from 'vs/workbench/contrib/debug/common/debug';
|
||||
import { ILaunch, IDebugService, State, IDebugSession, IConfigurationManager, IStackFrame, IBreakpointData, IBreakpointUpdateData, IConfig, IDebugModel, IViewModel, IBreakpoint, LoadedSourceEvent, IThread, IRawModelUpdate, IFunctionBreakpoint, IExceptionBreakpoint, IDebugger, IExceptionInfo, AdapterEndEvent, IReplElement, IExpression, IReplElementSource, IDataBreakpoint, IDebugSessionOptions } from 'vs/workbench/contrib/debug/common/debug';
|
||||
import { Source } from 'vs/workbench/contrib/debug/common/debugSource';
|
||||
import { CompletionItem } from 'vs/editor/common/modes';
|
||||
import Severity from 'vs/base/common/severity';
|
||||
@@ -102,7 +102,7 @@ export class MockDebugService implements IDebugService {
|
||||
|
||||
public removeWatchExpressions(id?: string): void { }
|
||||
|
||||
public startDebugging(launch: ILaunch, configOrName?: IConfig | string, noDebug?: boolean): Promise<boolean> {
|
||||
public startDebugging(launch: ILaunch, configOrName?: IConfig | string, options?: IDebugSessionOptions): Promise<boolean> {
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
|
||||
@@ -159,6 +159,10 @@ export class MockSession implements IDebugSession {
|
||||
return [];
|
||||
}
|
||||
|
||||
hasSeparateRepl(): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
removeReplExpressions(): void { }
|
||||
get onDidChangeReplElements(): Event<void> {
|
||||
throw new Error('not implemented');
|
||||
|
||||
Reference in New Issue
Block a user