Skip to content

Commit d476ea3

Browse files
committed
Show DebugSession#workspaceFolder in UI
* Adapt DebugSessions Tree Model Contributed on behalf of STMicroelectronics Signed-off-by: Johannes Faltermeier <[email protected]>
1 parent 9327aa0 commit d476ea3

File tree

4 files changed

+34
-10
lines changed

4 files changed

+34
-10
lines changed

packages/debug/src/browser/debug-session-contribution.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import { Channel, DebugAdapterPath } from '../common/debug-service';
3030
import { ContributionProvider } from '@theia/core/lib/common/contribution-provider';
3131
import { FileService } from '@theia/filesystem/lib/browser/file-service';
3232
import { DebugContribution } from './debug-contribution';
33+
import { WorkspaceService } from '@theia/workspace/lib/browser';
3334

3435
/**
3536
* DebugSessionContribution symbol for DI.
@@ -114,6 +115,8 @@ export class DefaultDebugSessionFactory implements DebugSessionFactory {
114115
protected readonly fileService: FileService;
115116
@inject(ContributionProvider) @named(DebugContribution)
116117
protected readonly debugContributionProvider: ContributionProvider<DebugContribution>;
118+
@inject(WorkspaceService)
119+
protected readonly workspaceService: WorkspaceService;
117120

118121
get(sessionId: string, options: DebugSessionOptions, parentSession?: DebugSession): DebugSession {
119122
const connection = new DebugSessionConnection(
@@ -135,7 +138,8 @@ export class DefaultDebugSessionFactory implements DebugSessionFactory {
135138
this.labelProvider,
136139
this.messages,
137140
this.fileService,
138-
this.debugContributionProvider);
141+
this.debugContributionProvider,
142+
this.workspaceService);
139143
}
140144

141145
protected getTraceOutputChannel(): OutputChannel | undefined {

packages/debug/src/browser/debug-session.tsx

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import { DebugFunctionBreakpoint } from './model/debug-function-breakpoint';
4141
import { FileService } from '@theia/filesystem/lib/browser/file-service';
4242
import { DebugContribution } from './debug-contribution';
4343
import { waitForEvent } from '@theia/core/lib/common/promise-util';
44+
import { WorkspaceService } from '@theia/workspace/lib/browser';
4445

4546
export enum DebugState {
4647
Inactive,
@@ -79,7 +80,8 @@ export class DebugSession implements CompositeTreeElement {
7980
protected readonly labelProvider: LabelProvider,
8081
protected readonly messages: MessageClient,
8182
protected readonly fileService: FileService,
82-
protected readonly debugContributionProvider: ContributionProvider<DebugContribution>
83+
protected readonly debugContributionProvider: ContributionProvider<DebugContribution>,
84+
protected readonly workspaceService: WorkspaceService,
8385
) {
8486
this.connection.onRequest('runInTerminal', (request: DebugProtocol.RunInTerminalRequest) => this.runInTerminal(request));
8587
this.connection.onDidClose(() => {
@@ -747,10 +749,19 @@ export class DebugSession implements CompositeTreeElement {
747749
}
748750

749751
get label(): string {
750-
if (InternalDebugSessionOptions.is(this.options) && this.options.id) {
751-
return this.configuration.name + ' (' + (this.options.id + 1) + ')';
752+
const showWSFolderInLabel = this.workspaceService.isMultiRootWorkspaceOpened && this.options.workspaceFolderUri;
753+
if (showWSFolderInLabel) {
754+
const wsFolder = this.labelProvider.getName(new URI(this.options.workspaceFolderUri));
755+
if (InternalDebugSessionOptions.is(this.options) && this.options.id) {
756+
return this.configuration.name + ' (' + (this.options.id + 1) + ' - ' + wsFolder + ')';
757+
}
758+
return this.configuration.name + ' (' + wsFolder + ')';
759+
} else {
760+
if (InternalDebugSessionOptions.is(this.options) && this.options.id) {
761+
return this.configuration.name + ' (' + (this.options.id + 1) + ')';
762+
}
763+
return this.configuration.name;
752764
}
753-
return this.configuration.name;
754765
}
755766

756767
get visible(): boolean {

packages/plugin-ext/src/main/browser/debug/debug-main.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ import { DebugConsoleSession } from '@theia/debug/lib/browser/console/debug-cons
5454
import { ContributionProvider } from '@theia/core/lib/common';
5555
import { DebugContribution } from '@theia/debug/lib/browser/debug-contribution';
5656
import { ConnectionImpl } from '../../../common/connection';
57+
import { WorkspaceService } from '@theia/workspace/lib/browser';
5758

5859
export class DebugMainImpl implements DebugMain, Disposable {
5960
private readonly debugExt: DebugExt;
@@ -73,6 +74,7 @@ export class DebugMainImpl implements DebugMain, Disposable {
7374
private readonly fileService: FileService;
7475
private readonly pluginService: HostedPluginSupport;
7576
private readonly debugContributionProvider: ContributionProvider<DebugContribution>;
77+
private readonly workspaceService: WorkspaceService;
7678

7779
private readonly debuggerContributions = new Map<string, DisposableCollection>();
7880
private readonly configurationProviders = new Map<number, DisposableCollection>();
@@ -95,6 +97,7 @@ export class DebugMainImpl implements DebugMain, Disposable {
9597
this.debugContributionProvider = container.getNamed(ContributionProvider, DebugContribution);
9698
this.fileService = container.get(FileService);
9799
this.pluginService = container.get(HostedPluginSupport);
100+
this.workspaceService = container.get(WorkspaceService);
98101

99102
const fireDidChangeBreakpoints = ({ added, removed, changed }: BreakpointsChangeEvent<SourceBreakpoint | FunctionBreakpoint>) => {
100103
this.debugExt.$breakpointsDidChange(
@@ -155,7 +158,8 @@ export class DebugMainImpl implements DebugMain, Disposable {
155158
},
156159
this.fileService,
157160
terminalOptionsExt,
158-
this.debugContributionProvider
161+
this.debugContributionProvider,
162+
this.workspaceService,
159163
);
160164

161165
const toDispose = new DisposableCollection(

packages/plugin-ext/src/main/browser/debug/plugin-debug-session-factory.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import { FileService } from '@theia/filesystem/lib/browser/file-service';
3131
import { DebugContribution } from '@theia/debug/lib/browser/debug-contribution';
3232
import { ContributionProvider } from '@theia/core/lib/common/contribution-provider';
3333
import { Channel } from '@theia/debug/lib/common/debug-service';
34+
import { WorkspaceService } from '@theia/workspace/lib/browser';
3435

3536
export class PluginDebugSession extends DebugSession {
3637
constructor(
@@ -45,8 +46,10 @@ export class PluginDebugSession extends DebugSession {
4546
protected override readonly messages: MessageClient,
4647
protected override readonly fileService: FileService,
4748
protected readonly terminalOptionsExt: TerminalOptionsExt | undefined,
48-
protected override readonly debugContributionProvider: ContributionProvider<DebugContribution>) {
49-
super(id, options, parentSession, connection, terminalServer, editorManager, breakpoints, labelProvider, messages, fileService, debugContributionProvider);
49+
protected override readonly debugContributionProvider: ContributionProvider<DebugContribution>,
50+
protected override readonly workspaceService: WorkspaceService) {
51+
super(id, options, parentSession, connection, terminalServer, editorManager, breakpoints, labelProvider, messages, fileService, debugContributionProvider,
52+
workspaceService);
5053
}
5154

5255
protected override async doCreateTerminal(terminalWidgetOptions: TerminalWidgetOptions): Promise<TerminalWidget> {
@@ -71,7 +74,8 @@ export class PluginDebugSessionFactory extends DefaultDebugSessionFactory {
7174
protected readonly connectionFactory: (sessionId: string) => Promise<Channel>,
7275
protected override readonly fileService: FileService,
7376
protected readonly terminalOptionsExt: TerminalOptionsExt | undefined,
74-
protected override readonly debugContributionProvider: ContributionProvider<DebugContribution>
77+
protected override readonly debugContributionProvider: ContributionProvider<DebugContribution>,
78+
protected override readonly workspaceService: WorkspaceService,
7579
) {
7680
super();
7781
}
@@ -94,7 +98,8 @@ export class PluginDebugSessionFactory extends DefaultDebugSessionFactory {
9498
this.messages,
9599
this.fileService,
96100
this.terminalOptionsExt,
97-
this.debugContributionProvider
101+
this.debugContributionProvider,
102+
this.workspaceService,
98103
);
99104
}
100105
}

0 commit comments

Comments
 (0)