Skip to content

Commit d0cf152

Browse files
committed
add dynamic run configurations for debugger
1 parent 1bba163 commit d0cf152

File tree

3 files changed

+64
-26
lines changed

3 files changed

+64
-26
lines changed

package.json

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,26 @@
4646
"Robotic Process Automation",
4747
"RPA"
4848
],
49+
"featureFlags": {
50+
"usingNewInterpreterStorage": true
51+
},
52+
"capabilities": {
53+
"untrustedWorkspaces": {
54+
"supported": "limited",
55+
"description": "Only Partial IntelliSense with RobotCode is supported. Cannot execute Python with untrusted files."
56+
},
57+
"virtualWorkspaces": {
58+
"supported": "limited",
59+
"description": "Only Partial IntelliSense supported."
60+
}
61+
},
4962
"activationEvents": [
50-
"workspaceContains:**/*.robot",
63+
"onLanguage:robotframework",
64+
"workspaceContains:**/*.{robot,resource}",
5165
"onDebug",
52-
"onDebugAdapterProtocolTracker:robotframework",
5366
"onDebugInitialConfigurations",
5467
"onDebugDynamicConfigurations",
55-
"onDebugResolve:robotframework",
56-
"onLanguage:robotframework"
68+
"onDebugResolve:robotcode"
5769
],
5870
"galleryBanner": {
5971
"theme": "dark",
@@ -63,6 +75,7 @@
6375
"contributes": {
6476
"configurationDefaults": {
6577
"[robotframework]": {
78+
"editor.wordBasedSuggestions": false,
6679
"editor.semanticHighlighting.enabled": true
6780
}
6881
},
@@ -85,7 +98,7 @@
8598
"headerKeyword": [
8699
"keyword.other.header.keyword.robotframework"
87100
],
88-
"headerSetting": [
101+
"headerSettings": [
89102
"keyword.other.header.setting.robotframework"
90103
],
91104
"headerVariable": [
@@ -467,7 +480,7 @@
467480
"debuggers": [
468481
{
469482
"type": "robotcode",
470-
"label": "RobotCode Debug",
483+
"label": "RobotCode Debugger",
471484
"languages": [
472485
"robotframework"
473486
],

vscode-client/debugmanager.ts

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -154,25 +154,37 @@ export class DebugManager {
154154
"robotcode",
155155
new RobotCodeDebugConfigurationProvider(this.pythonManager)
156156
),
157+
vscode.debug.registerDebugConfigurationProvider(
158+
"robotcode",
159+
{
160+
provideDebugConfigurations(
161+
_folder: vscode.WorkspaceFolder | undefined,
162+
_token?: vscode.CancellationToken
163+
): vscode.ProviderResult<vscode.DebugConfiguration[]> {
164+
return [
165+
{
166+
name: "RobotCode: Run .robot file",
167+
type: "robotcode",
168+
request: "launch",
169+
cwd: "${workspaceFolder}",
170+
target: "${file}",
171+
},
172+
{
173+
name: "RobotCode: Run all tests",
174+
type: "robotcode",
175+
request: "launch",
176+
cwd: "${workspaceFolder}",
177+
target: ".",
178+
},
179+
];
180+
},
181+
},
182+
vscode.DebugConfigurationProviderTriggerKind.Dynamic
183+
),
157184
vscode.debug.registerDebugAdapterDescriptorFactory(
158185
"robotcode",
159186
new RobotCodeDebugAdapterDescriptorFactory(this.pythonManager)
160187
),
161-
// vscode.debug.registerDebugAdapterTrackerFactory("robotcode", {
162-
// createDebugAdapterTracker(session: vscode.DebugSession) {
163-
// return {
164-
// onWillStartSession: () => OUTPUT_CHANNEL.appendLine(`DEBUG_ADAPTER start session`),
165-
// onWillStopSession: () => OUTPUT_CHANNEL.appendLine(`DEBUG_ADAPTER stop session`),
166-
// onWillReceiveMessage: (m) =>
167-
// OUTPUT_CHANNEL.appendLine(`DEBUG_ADAPTER > ${JSON.stringify(m, undefined, 2)}`),
168-
// onDidSendMessage: (m) =>
169-
// OUTPUT_CHANNEL.appendLine(`DEBUG_ADAPTER < ${JSON.stringify(m, undefined, 2)}`),
170-
// onError: (e) =>
171-
// OUTPUT_CHANNEL.appendLine(`DEBUG_ADAPTER ERROR: ${JSON.stringify(e, undefined, 2)}`),
172-
// onExit: (c, s) => OUTPUT_CHANNEL.appendLine(`DEBUG_ADAPTER EXIT code ${c} signal ${s}`),
173-
// };
174-
// },
175-
// }),
176188
vscode.debug.onDidReceiveDebugSessionCustomEvent(async (event) => {
177189
if (event.session.configuration.type === "robotcode") {
178190
switch (event.event) {
@@ -209,7 +221,7 @@ export class DebugManager {
209221
this._attachedSessions.delete(session);
210222
}
211223
}),
212-
vscode.languages.registerInlineValuesProvider("robotframework", {
224+
vscode.languages.registerInlineValuesProvider("robotcode", {
213225
provideInlineValues(
214226
document: vscode.TextDocument,
215227
viewPort: vscode.Range,
@@ -246,7 +258,7 @@ export class DebugManager {
246258
);
247259
},
248260
}),
249-
vscode.languages.registerEvaluatableExpressionProvider("robotframework", {
261+
vscode.languages.registerEvaluatableExpressionProvider("robotcode", {
250262
provideEvaluatableExpression(
251263
document: vscode.TextDocument,
252264
position: vscode.Position,
@@ -304,7 +316,7 @@ export class DebugManager {
304316
...template,
305317
...{
306318
type: "robotcode",
307-
name: "robotcode: Run Tests",
319+
name: "RobotCode: Run Tests",
308320
request: "launch",
309321
cwd: folder?.uri.fsPath,
310322
target: ".",

vscode-client/languageclientsmanger.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,8 +390,10 @@ export class LanguageClientsManager {
390390
const folders = new Set<vscode.WorkspaceFolder>();
391391

392392
for (const document of vscode.workspace.textDocuments) {
393-
const workspaceFolder = vscode.workspace.getWorkspaceFolder(document.uri);
394-
if (workspaceFolder) folders.add(workspaceFolder);
393+
if (document.languageId === "robotframework") {
394+
const workspaceFolder = vscode.workspace.getWorkspaceFolder(document.uri);
395+
if (workspaceFolder) folders.add(workspaceFolder);
396+
}
395397
}
396398

397399
for (const folder of folders) {
@@ -409,6 +411,17 @@ export class LanguageClientsManager {
409411
suites?: string[],
410412
token?: vscode.CancellationToken
411413
): Promise<RobotTestItem[] | undefined> {
414+
const robotFiles = await vscode.workspace.findFiles(
415+
new vscode.RelativePattern(workspaceFolder, "**/*.robot"),
416+
undefined,
417+
1,
418+
token
419+
);
420+
421+
if (robotFiles.length === 0) {
422+
return undefined;
423+
}
424+
412425
const client = await this.getLanguageClientForResource(workspaceFolder.uri);
413426

414427
if (!client) return;

0 commit comments

Comments
 (0)