mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-14 01:25:37 -05:00
Merge from vscode 64980ea1f3f532c82bb6c28d27bba9ef2c5b4463 (#7206)
* Merge from vscode 64980ea1f3f532c82bb6c28d27bba9ef2c5b4463 * fix config changes * fix strictnull checks
This commit is contained in:
@@ -14,7 +14,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
|
||||
import { MenuId, IMenu, IMenuService } from 'vs/platform/actions/common/actions';
|
||||
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { renderViewTree } from 'vs/workbench/contrib/debug/browser/baseDebugView';
|
||||
import { IAction } from 'vs/base/common/actions';
|
||||
import { IAction, Action } from 'vs/base/common/actions';
|
||||
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
@@ -30,6 +30,10 @@ import { HighlightedLabel } from 'vs/base/browser/ui/highlightedlabel/highlighte
|
||||
import { createMatches, FuzzyScore } from 'vs/base/common/filters';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { dispose } from 'vs/base/common/lifecycle';
|
||||
import { ActionBar } from 'vs/base/browser/ui/actionbar/actionbar';
|
||||
import { isSessionAttach } from 'vs/workbench/contrib/debug/common/debugUtils';
|
||||
import { STOP_ID, STOP_LABEL, DISCONNECT_ID, DISCONNECT_LABEL, RESTART_SESSION_ID, RESTART_LABEL, STEP_OVER_ID, STEP_OVER_LABEL, STEP_INTO_LABEL, STEP_INTO_ID, STEP_OUT_LABEL, STEP_OUT_ID, PAUSE_ID, PAUSE_LABEL, CONTINUE_ID, CONTINUE_LABEL } from 'vs/workbench/contrib/debug/browser/debugCommands';
|
||||
import { ICommandService } from 'vs/platform/commands/common/commands';
|
||||
|
||||
const $ = dom.$;
|
||||
|
||||
@@ -48,6 +52,7 @@ export class CallStackView extends ViewletPanel {
|
||||
private tree!: WorkbenchAsyncDataTree<CallStackItem | IDebugModel, CallStackItem, FuzzyScore>;
|
||||
private contributedContextMenu: IMenu;
|
||||
private parentSessionToExpand = new Set<IDebugSession>();
|
||||
private selectionNeedsUpdate = false;
|
||||
|
||||
constructor(
|
||||
private options: IViewletViewOptions,
|
||||
@@ -86,7 +91,10 @@ export class CallStackView extends ViewletPanel {
|
||||
this.tree.updateChildren().then(() => {
|
||||
this.parentSessionToExpand.forEach(s => this.tree.expand(s));
|
||||
this.parentSessionToExpand.clear();
|
||||
this.updateTreeSelection();
|
||||
if (this.selectionNeedsUpdate) {
|
||||
this.selectionNeedsUpdate = false;
|
||||
this.updateTreeSelection();
|
||||
}
|
||||
});
|
||||
}, 50);
|
||||
}
|
||||
@@ -105,48 +113,48 @@ export class CallStackView extends ViewletPanel {
|
||||
const treeContainer = renderViewTree(container);
|
||||
|
||||
this.dataSource = new CallStackDataSource(this.debugService);
|
||||
this.tree = this.instantiationService.createInstance(WorkbenchAsyncDataTree, treeContainer, new CallStackDelegate(), [
|
||||
new SessionsRenderer(),
|
||||
new ThreadsRenderer(),
|
||||
this.tree = this.instantiationService.createInstance(WorkbenchAsyncDataTree, 'CallStackView', treeContainer, new CallStackDelegate(), [
|
||||
new SessionsRenderer(this.instantiationService),
|
||||
new ThreadsRenderer(this.instantiationService),
|
||||
this.instantiationService.createInstance(StackFramesRenderer),
|
||||
new ErrorsRenderer(),
|
||||
new LoadMoreRenderer(),
|
||||
new ShowMoreRenderer()
|
||||
], this.dataSource, {
|
||||
accessibilityProvider: new CallStackAccessibilityProvider(),
|
||||
ariaLabel: nls.localize({ comment: ['Debug is a noun in this context, not a verb.'], key: 'callStackAriaLabel' }, "Debug Call Stack"),
|
||||
identityProvider: {
|
||||
getId: (element: CallStackItem) => {
|
||||
if (typeof element === 'string') {
|
||||
return element;
|
||||
}
|
||||
if (element instanceof Array) {
|
||||
return `showMore ${element[0].getId()}`;
|
||||
}
|
||||
|
||||
return element.getId();
|
||||
accessibilityProvider: new CallStackAccessibilityProvider(),
|
||||
ariaLabel: nls.localize({ comment: ['Debug is a noun in this context, not a verb.'], key: 'callStackAriaLabel' }, "Debug Call Stack"),
|
||||
identityProvider: {
|
||||
getId: (element: CallStackItem) => {
|
||||
if (typeof element === 'string') {
|
||||
return element;
|
||||
}
|
||||
},
|
||||
keyboardNavigationLabelProvider: {
|
||||
getKeyboardNavigationLabel: (e: CallStackItem) => {
|
||||
if (isDebugSession(e)) {
|
||||
return e.getLabel();
|
||||
}
|
||||
if (e instanceof Thread) {
|
||||
return `${e.name} ${e.stateLabel}`;
|
||||
}
|
||||
if (e instanceof StackFrame || typeof e === 'string') {
|
||||
return e;
|
||||
}
|
||||
if (e instanceof ThreadAndSessionIds) {
|
||||
return LoadMoreRenderer.LABEL;
|
||||
}
|
||||
|
||||
return nls.localize('showMoreStackFrames2', "Show More Stack Frames");
|
||||
if (element instanceof Array) {
|
||||
return `showMore ${element[0].getId()}`;
|
||||
}
|
||||
},
|
||||
expandOnlyOnTwistieClick: true
|
||||
});
|
||||
|
||||
return element.getId();
|
||||
}
|
||||
},
|
||||
keyboardNavigationLabelProvider: {
|
||||
getKeyboardNavigationLabel: (e: CallStackItem) => {
|
||||
if (isDebugSession(e)) {
|
||||
return e.getLabel();
|
||||
}
|
||||
if (e instanceof Thread) {
|
||||
return `${e.name} ${e.stateLabel}`;
|
||||
}
|
||||
if (e instanceof StackFrame || typeof e === 'string') {
|
||||
return e;
|
||||
}
|
||||
if (e instanceof ThreadAndSessionIds) {
|
||||
return LoadMoreRenderer.LABEL;
|
||||
}
|
||||
|
||||
return nls.localize('showMoreStackFrames2', "Show More Stack Frames");
|
||||
}
|
||||
},
|
||||
expandOnlyOnTwistieClick: true
|
||||
});
|
||||
|
||||
this.tree.setInput(this.debugService.getModel()).then(undefined, onUnexpectedError);
|
||||
|
||||
@@ -201,8 +209,8 @@ export class CallStackView extends ViewletPanel {
|
||||
this.onCallStackChangeScheduler.schedule();
|
||||
}
|
||||
}));
|
||||
const onCallStackChange = Event.any<any>(this.debugService.getViewModel().onDidFocusStackFrame, this.debugService.getViewModel().onDidFocusSession);
|
||||
this._register(onCallStackChange(() => {
|
||||
const onFocusChange = Event.any<any>(this.debugService.getViewModel().onDidFocusStackFrame, this.debugService.getViewModel().onDidFocusSession);
|
||||
this._register(onFocusChange(() => {
|
||||
if (this.ignoreFocusStackFrameEvent) {
|
||||
return;
|
||||
}
|
||||
@@ -210,6 +218,10 @@ export class CallStackView extends ViewletPanel {
|
||||
this.needsRefresh = true;
|
||||
return;
|
||||
}
|
||||
if (this.onCallStackChangeScheduler.isScheduled()) {
|
||||
this.selectionNeedsUpdate = true;
|
||||
return;
|
||||
}
|
||||
|
||||
this.updateTreeSelection();
|
||||
}));
|
||||
@@ -227,6 +239,7 @@ export class CallStackView extends ViewletPanel {
|
||||
}));
|
||||
|
||||
this._register(this.debugService.onDidNewSession(s => {
|
||||
this._register(s.onDidChangeName(() => this.tree.rerender(s)));
|
||||
if (s.parentSession) {
|
||||
// Auto expand sessions that have sub sessions
|
||||
this.parentSessionToExpand.add(s.parentSession);
|
||||
@@ -334,6 +347,7 @@ interface IThreadTemplateData {
|
||||
state: HTMLElement;
|
||||
stateLabel: HTMLSpanElement;
|
||||
label: HighlightedLabel;
|
||||
actionBar: ActionBar;
|
||||
}
|
||||
|
||||
interface ISessionTemplateData {
|
||||
@@ -342,6 +356,7 @@ interface ISessionTemplateData {
|
||||
state: HTMLElement;
|
||||
stateLabel: HTMLSpanElement;
|
||||
label: HighlightedLabel;
|
||||
actionBar: ActionBar;
|
||||
}
|
||||
|
||||
interface IErrorTemplateData {
|
||||
@@ -363,6 +378,10 @@ interface IStackFrameTemplateData {
|
||||
class SessionsRenderer implements ITreeRenderer<IDebugSession, FuzzyScore, ISessionTemplateData> {
|
||||
static readonly ID = 'session';
|
||||
|
||||
constructor(
|
||||
private readonly instantiationService: IInstantiationService
|
||||
) { }
|
||||
|
||||
get templateId(): string {
|
||||
return SessionsRenderer.ID;
|
||||
}
|
||||
@@ -373,28 +392,35 @@ class SessionsRenderer implements ITreeRenderer<IDebugSession, FuzzyScore, ISess
|
||||
const state = dom.append(session, $('.state'));
|
||||
const stateLabel = dom.append(state, $('span.label'));
|
||||
const label = new HighlightedLabel(name, false);
|
||||
const actionBar = new ActionBar(session);
|
||||
|
||||
return { session, name, state, stateLabel, label };
|
||||
return { session, name, state, stateLabel, label, actionBar };
|
||||
}
|
||||
|
||||
renderElement(element: ITreeNode<IDebugSession, FuzzyScore>, index: number, data: ISessionTemplateData): void {
|
||||
renderElement(element: ITreeNode<IDebugSession, FuzzyScore>, _: number, data: ISessionTemplateData): void {
|
||||
const session = element.element;
|
||||
data.session.title = nls.localize({ key: 'session', comment: ['Session is a noun'] }, "Session");
|
||||
data.label.set(session.getLabel(), createMatches(element.filterData));
|
||||
const stoppedThread = session.getAllThreads().filter(t => t.stopped).pop();
|
||||
|
||||
data.actionBar.clear();
|
||||
const actions = getActions(this.instantiationService, element.element);
|
||||
data.actionBar.push(actions, { icon: true, label: false });
|
||||
|
||||
data.stateLabel.textContent = stoppedThread ? nls.localize('paused', "Paused")
|
||||
: nls.localize({ key: 'running', comment: ['indicates state'] }, "Running");
|
||||
}
|
||||
|
||||
disposeTemplate(templateData: ISessionTemplateData): void {
|
||||
// noop
|
||||
templateData.actionBar.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
class ThreadsRenderer implements ITreeRenderer<IThread, FuzzyScore, IThreadTemplateData> {
|
||||
static readonly ID = 'thread';
|
||||
|
||||
constructor(private readonly instantiationService: IInstantiationService) { }
|
||||
|
||||
get templateId(): string {
|
||||
return ThreadsRenderer.ID;
|
||||
}
|
||||
@@ -405,8 +431,9 @@ class ThreadsRenderer implements ITreeRenderer<IThread, FuzzyScore, IThreadTempl
|
||||
const state = dom.append(thread, $('.state'));
|
||||
const stateLabel = dom.append(state, $('span.label'));
|
||||
const label = new HighlightedLabel(name, false);
|
||||
const actionBar = new ActionBar(thread);
|
||||
|
||||
return { thread, name, state, stateLabel, label };
|
||||
return { thread, name, state, stateLabel, label, actionBar };
|
||||
}
|
||||
|
||||
renderElement(element: ITreeNode<IThread, FuzzyScore>, index: number, data: IThreadTemplateData): void {
|
||||
@@ -414,10 +441,14 @@ class ThreadsRenderer implements ITreeRenderer<IThread, FuzzyScore, IThreadTempl
|
||||
data.thread.title = nls.localize('thread', "Thread");
|
||||
data.label.set(thread.name, createMatches(element.filterData));
|
||||
data.stateLabel.textContent = thread.stateLabel;
|
||||
|
||||
data.actionBar.clear();
|
||||
const actions = getActions(this.instantiationService, thread);
|
||||
data.actionBar.push(actions, { icon: true, label: false });
|
||||
}
|
||||
|
||||
disposeTemplate(templateData: IThreadTemplateData): void {
|
||||
// noop
|
||||
templateData.actionBar.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -707,3 +738,147 @@ class CallStackAccessibilityProvider implements IAccessibilityProvider<CallStack
|
||||
return nls.localize('loadMoreStackFrames', "Load More Stack Frames");
|
||||
}
|
||||
}
|
||||
|
||||
function getActions(instantiationService: IInstantiationService, element: IDebugSession | IThread): IAction[] {
|
||||
const getThreadActions = (thread: IThread): IAction[] => {
|
||||
return [
|
||||
thread.stopped ? instantiationService.createInstance(ContinueAction, thread) : instantiationService.createInstance(PauseAction, thread),
|
||||
instantiationService.createInstance(StepOverAction, thread),
|
||||
instantiationService.createInstance(StepIntoAction, thread),
|
||||
instantiationService.createInstance(StepOutAction, thread)
|
||||
];
|
||||
};
|
||||
|
||||
if (element instanceof Thread) {
|
||||
return getThreadActions(element);
|
||||
}
|
||||
|
||||
const session = <IDebugSession>element;
|
||||
const stopOrDisconectAction = isSessionAttach(session) ? instantiationService.createInstance(DisconnectAction, session) : instantiationService.createInstance(StopAction, session);
|
||||
const restartAction = instantiationService.createInstance(RestartAction, session);
|
||||
const threads = session.getAllThreads();
|
||||
if (threads.length === 1) {
|
||||
return getThreadActions(threads[0]).concat([
|
||||
restartAction,
|
||||
stopOrDisconectAction
|
||||
]);
|
||||
}
|
||||
|
||||
return [
|
||||
restartAction,
|
||||
stopOrDisconectAction
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
class StopAction extends Action {
|
||||
|
||||
constructor(
|
||||
private readonly session: IDebugSession,
|
||||
@ICommandService private readonly commandService: ICommandService
|
||||
) {
|
||||
super(`action.${STOP_ID}`, STOP_LABEL, 'debug-action stop');
|
||||
}
|
||||
|
||||
public run(): Promise<any> {
|
||||
return this.commandService.executeCommand(STOP_ID, this.session.getId(), this.session);
|
||||
}
|
||||
}
|
||||
|
||||
class DisconnectAction extends Action {
|
||||
|
||||
constructor(
|
||||
private readonly session: IDebugSession,
|
||||
@ICommandService private readonly commandService: ICommandService
|
||||
) {
|
||||
super(`action.${DISCONNECT_ID}`, DISCONNECT_LABEL, 'debug-action disconnect');
|
||||
}
|
||||
|
||||
public run(): Promise<any> {
|
||||
return this.commandService.executeCommand(DISCONNECT_ID, this.session.getId(), this.session);
|
||||
}
|
||||
}
|
||||
|
||||
class RestartAction extends Action {
|
||||
|
||||
constructor(
|
||||
private readonly session: IDebugSession,
|
||||
@ICommandService private readonly commandService: ICommandService
|
||||
) {
|
||||
super(`action.${RESTART_SESSION_ID}`, RESTART_LABEL, 'debug-action restart');
|
||||
}
|
||||
|
||||
public run(): Promise<any> {
|
||||
return this.commandService.executeCommand(RESTART_SESSION_ID, this.session.getId(), this.session);
|
||||
}
|
||||
}
|
||||
|
||||
class StepOverAction extends Action {
|
||||
|
||||
constructor(
|
||||
private readonly thread: IThread,
|
||||
@ICommandService private readonly commandService: ICommandService
|
||||
) {
|
||||
super(`action.${STEP_OVER_ID}`, STEP_OVER_LABEL, 'debug-action step-over', thread.stopped);
|
||||
}
|
||||
|
||||
public run(): Promise<any> {
|
||||
return this.commandService.executeCommand(STEP_OVER_ID, this.thread.threadId, this.thread);
|
||||
}
|
||||
}
|
||||
|
||||
class StepIntoAction extends Action {
|
||||
|
||||
constructor(
|
||||
private readonly thread: IThread,
|
||||
@ICommandService private readonly commandService: ICommandService
|
||||
) {
|
||||
super(`action.${STEP_INTO_ID}`, STEP_INTO_LABEL, 'debug-action step-into', thread.stopped);
|
||||
}
|
||||
|
||||
public run(): Promise<any> {
|
||||
return this.commandService.executeCommand(STEP_INTO_ID, this.thread.threadId, this.thread);
|
||||
}
|
||||
}
|
||||
|
||||
class StepOutAction extends Action {
|
||||
|
||||
constructor(
|
||||
private readonly thread: IThread,
|
||||
@ICommandService private readonly commandService: ICommandService
|
||||
) {
|
||||
super(`action.${STEP_OUT_ID}`, STEP_OUT_LABEL, 'debug-action step-out', thread.stopped);
|
||||
}
|
||||
|
||||
public run(): Promise<any> {
|
||||
return this.commandService.executeCommand(STEP_OUT_ID, this.thread.threadId, this.thread);
|
||||
}
|
||||
}
|
||||
|
||||
class PauseAction extends Action {
|
||||
|
||||
constructor(
|
||||
private readonly thread: IThread,
|
||||
@ICommandService private readonly commandService: ICommandService
|
||||
) {
|
||||
super(`action.${PAUSE_ID}`, PAUSE_LABEL, 'debug-action pause', !thread.stopped);
|
||||
}
|
||||
|
||||
public run(): Promise<any> {
|
||||
return this.commandService.executeCommand(PAUSE_ID, this.thread.threadId, this.thread);
|
||||
}
|
||||
}
|
||||
|
||||
class ContinueAction extends Action {
|
||||
|
||||
constructor(
|
||||
private readonly thread: IThread,
|
||||
@ICommandService private readonly commandService: ICommandService
|
||||
) {
|
||||
super(`action.${CONTINUE_ID}`, CONTINUE_LABEL, 'debug-action continue', thread.stopped);
|
||||
}
|
||||
|
||||
public run(): Promise<any> {
|
||||
return this.commandService.executeCommand(CONTINUE_ID, this.thread.threadId, this.thread);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user