debug: DebugSession.getLabel() clenaup

This commit is contained in:
isidor
2018-10-05 17:56:47 +02:00
parent 2f0fdd34f2
commit fac58fc8fe
10 changed files with 21 additions and 23 deletions
@@ -238,7 +238,7 @@ export class MainThreadDebugService implements MainThreadDebugServiceShape, IDeb
return {
id: <DebugSessionUUID>session.getId(),
type: session.configuration.type,
name: session.getName(false)
name: session.configuration.name
};
}
return undefined;
@@ -192,7 +192,7 @@ export class FocusSessionActionItem extends SelectActionItem {
action: IAction,
@IDebugService private debugService: IDebugService,
@IThemeService themeService: IThemeService,
@IContextViewService contextViewService: IContextViewService
@IContextViewService contextViewService: IContextViewService,
) {
super(null, action, [], -1, contextViewService, { ariaLabel: nls.localize('debugSession', 'Debug Session') });
@@ -215,8 +215,7 @@ export class FocusSessionActionItem extends SelectActionItem {
private update() {
const session = this.debugService.getViewModel().focusedSession;
const sessions = this.debugService.getModel().getSessions();
const showRootName = this.debugService.getConfigurationManager().getLaunches().length > 1;
const names = sessions.map(s => s.getName(showRootName));
const names = sessions.map(s => s.getLabel());
this.setOptions(names, session ? sessions.indexOf(session) : undefined);
}
}
@@ -760,8 +760,7 @@ export class FocusSessionAction extends AbstractDebugAction {
}
public run(sessionName: string): TPromise<any> {
const isMultiRoot = this.debugService.getConfigurationManager().getLaunches().length > 1;
const session = this.debugService.getModel().getSessions().filter(p => p.getName(isMultiRoot) === sessionName).pop();
const session = this.debugService.getModel().getSessions().filter(p => p.getLabel() === sessionName).pop();
this.debugService.focusStackFrame(undefined, undefined, session, true);
const stackFrame = this.debugService.getViewModel().focusedStackFrame;
if (stackFrame) {
@@ -226,7 +226,7 @@ class SessionTreeItem extends BaseTreeItem {
private _map: Map<string, BaseTreeItem>;
constructor(parent: BaseTreeItem, session: IDebugSession, private _environmentService: IEnvironmentService, private rootProvider: IWorkspaceContextService) {
super(parent, session.getName(true));
super(parent, session.getLabel());
this._initialized = false;
this._session = session;
this._map = new Map();
+1 -1
View File
@@ -144,7 +144,7 @@ export interface IDebugSession extends ITreeElement {
readonly state: State;
readonly root: IWorkspaceFolder;
getName(includeRoot: boolean): string;
getLabel(): string;
getSourceForUri(modelUri: uri): Source;
getSource(raw: DebugProtocol.Source): Source;
@@ -19,7 +19,6 @@ import { ITree, IActionProvider, IDataSource, IRenderer, IAccessibilityProvider
import { IAction, IActionItem } from 'vs/base/common/actions';
import { RestartAction, StopAction, ContinueAction, StepOverAction, StepIntoAction, StepOutAction, PauseAction, RestartFrameAction, TerminateThreadAction } from 'vs/workbench/parts/debug/browser/debugActions';
import { CopyStackTraceAction } from 'vs/workbench/parts/debug/electron-browser/electronDebugActions';
import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/common/workspace';
import { TreeResourceNavigator, WorkbenchTree } from 'vs/platform/list/browser/listService';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
@@ -397,7 +396,6 @@ class CallStackRenderer implements IRenderer {
private static readonly SESSION_TEMPLATE_ID = 'session';
constructor(
@IWorkspaceContextService private contextService: IWorkspaceContextService,
@ILabelService private labelService: ILabelService
) {
// noop
@@ -484,7 +482,7 @@ class CallStackRenderer implements IRenderer {
private renderSession(session: IDebugSession, data: ISessionTemplateData): void {
data.session.title = nls.localize({ key: 'session', comment: ['Session is a noun'] }, "Session");
data.name.textContent = session.getName(this.contextService.getWorkbenchState() === WorkbenchState.WORKSPACE);
data.name.textContent = session.getLabel();
const stoppedThread = session.getAllThreads().filter(t => t.stopped).pop();
data.stateLabel.textContent = stoppedThread ? nls.localize('paused', "Paused")
@@ -285,10 +285,10 @@ export class DebugService implements IDebugService {
const sessions = this.model.getSessions();
const alreadyRunningMessage = nls.localize('configurationAlreadyRunning', "There is already a debug configuration \"{0}\" running.", configOrName);
if (sessions.some(s => s.getName(false) === configOrName && (!launch || !launch.workspace || !s.root || s.root.uri.toString() === launch.workspace.uri.toString()))) {
if (sessions.some(s => s.configuration.name === configOrName && (!launch || !launch.workspace || !s.root || s.root.uri.toString() === launch.workspace.uri.toString()))) {
return Promise.reject(new Error(alreadyRunningMessage));
}
if (compound && compound.configurations && sessions.some(p => compound.configurations.indexOf(p.getName(false)) !== -1)) {
if (compound && compound.configurations && sessions.some(p => compound.configurations.indexOf(p.configuration.name) !== -1)) {
return Promise.reject(new Error(alreadyRunningMessage));
}
} else if (typeof configOrName !== 'string') {
@@ -20,7 +20,7 @@ import { Thread, ExpressionContainer, DebugModel } from 'vs/workbench/parts/debu
import { RawDebugSession } from 'vs/workbench/parts/debug/electron-browser/rawDebugSession';
import product from 'vs/platform/node/product';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { IWorkspaceFolder } from 'vs/platform/workspace/common/workspace';
import { IWorkspaceFolder, IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { RunOnceScheduler } from 'vs/base/common/async';
import { generateUuid } from 'vs/base/common/uuid';
@@ -61,7 +61,8 @@ export class DebugSession implements IDebugSession {
@IOutputService private outputService: IOutputService,
@IWindowService private windowService: IWindowService,
@IConfigurationService private configurationService: IConfigurationService,
@IViewletService private viewletService: IViewletService
@IViewletService private viewletService: IViewletService,
@IWorkspaceContextService private workspaceContextService: IWorkspaceContextService
) {
this.id = generateUuid();
this.repl = new ReplModel(this);
@@ -83,7 +84,8 @@ export class DebugSession implements IDebugSession {
this._configuration = configuration;
}
getName(includeRoot: boolean): string {
getLabel(): string {
const includeRoot = this.workspaceContextService.getWorkspace().folders.length > 1;
return includeRoot && this.root ? `${this.configuration.name} (${resources.basenameOrAuthority(this.root.uri)})` : this.configuration.name;
}
@@ -154,7 +154,7 @@ export class MockSession implements IDebugSession {
return 'mock';
}
getName(includeRoot: boolean): string {
getLabel(): string {
return 'mockname';
}
@@ -110,7 +110,7 @@ suite('Debug - Model', () => {
test('threads simple', () => {
const threadId = 1;
const threadName = 'firstThread';
const session = new DebugSession({ resolved: { name: 'mockSession', type: 'node', request: 'launch' }, unresolved: undefined }, undefined, model, undefined, undefined, undefined, undefined, undefined, undefined, undefined);
const session = new DebugSession({ resolved: { name: 'mockSession', type: 'node', request: 'launch' }, unresolved: undefined }, undefined, model, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined);
model.addSession(session);
assert.equal(model.getSessions().length, 1);
@@ -140,7 +140,7 @@ suite('Debug - Model', () => {
const stoppedReason = 'breakpoint';
// Add the threads
const session = new DebugSession({ resolved: { name: 'mockSession', type: 'node', request: 'launch' }, unresolved: undefined }, undefined, model, undefined, undefined, undefined, undefined, undefined, undefined, undefined);
const session = new DebugSession({ resolved: { name: 'mockSession', type: 'node', request: 'launch' }, unresolved: undefined }, undefined, model, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined);
model.addSession(session);
session['raw'] = <any>rawSession;
@@ -227,7 +227,7 @@ suite('Debug - Model', () => {
const runningThreadId = 2;
const runningThreadName = 'runningThread';
const stoppedReason = 'breakpoint';
const session = new DebugSession({ resolved: { name: 'mockSession', type: 'node', request: 'launch' }, unresolved: undefined }, undefined, model, undefined, undefined, undefined, undefined, undefined, undefined, undefined);
const session = new DebugSession({ resolved: { name: 'mockSession', type: 'node', request: 'launch' }, unresolved: undefined }, undefined, model, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined);
model.addSession(session);
session['raw'] = <any>rawSession;
@@ -340,7 +340,7 @@ suite('Debug - Model', () => {
});
test('repl expressions', () => {
const session = new DebugSession({ resolved: { name: 'mockSession', type: 'node', request: 'launch' }, unresolved: undefined }, undefined, model, undefined, undefined, undefined, undefined, undefined, undefined, undefined);
const session = new DebugSession({ resolved: { name: 'mockSession', type: 'node', request: 'launch' }, unresolved: undefined }, undefined, model, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined);
assert.equal(session.getReplElements().length, 0);
model.addSession(session);
@@ -364,7 +364,7 @@ suite('Debug - Model', () => {
});
test('stack frame get specific source name', () => {
const session = new DebugSession({ resolved: { name: 'mockSession', type: 'node', request: 'launch' }, unresolved: undefined }, undefined, model, undefined, undefined, undefined, undefined, undefined, undefined, undefined);
const session = new DebugSession({ resolved: { name: 'mockSession', type: 'node', request: 'launch' }, unresolved: undefined }, undefined, model, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined);
model.addSession(session);
let firstStackFrame: StackFrame;
@@ -395,7 +395,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);
const session = new DebugSession({ resolved: { name: 'mockSession', type: 'node', request: 'launch' }, unresolved: undefined }, undefined, model, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined);
const repl = new ReplModel(session);
repl.appendToRepl('first line\n', severity.Error);
repl.appendToRepl('second line', severity.Error);