Skip to content

Commit 94d1efa

Browse files
committed
feat: new command RobotCode: Report Issue
with this command you can report an issue directly from vscode to RobotCode's issue tracker
1 parent ac23751 commit 94d1efa

File tree

8 files changed

+336
-277
lines changed

8 files changed

+336
-277
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ assignees: ''
1010
**Describe the bug**
1111
A clear and concise description of what the bug is.
1212

13-
**To Reproduce**
13+
**Steps To Reproduce**
1414
Steps to reproduce the behavior:
1515
1. Go to '...'
1616
2. Click on '....'
@@ -36,13 +36,13 @@ If applicable, add screenshots or videos to help explain your problem.
3636
**Logs**
3737
Copy the messages from VSCode "Output" view for RobotCode and RobotCode Language Server for the specific folder/workspace.
3838

39+
**Additional context**
40+
Add any other context about the problem here.
41+
3942
**Desktop (please complete the following information):**
4043
- VS Code Version [e.g. 1.60]
4144
- RobotCode Version [e.g. 0.3.2]
4245
- OS: [e.g. Windows, Linux]
4346
- Python Version [e.g. 3.9.7]
4447
- RobotFramework Version [e.g. 4.0.0]
4548
- Additional tools like robocop, robotidy
46-
47-
**Additional context**
48-
Add any other context about the problem here.

package-lock.json

Lines changed: 175 additions & 260 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1572,27 +1572,29 @@
15721572
"dependencies": {
15731573
"@vscode/python-extension": "^1.0.5",
15741574
"ansi-colors": "^4.1.3",
1575+
"fs-extra": "^11.2.0",
15751576
"robotcode": "file:",
15761577
"vscode-languageclient": "^9.0.1"
15771578
},
15781579
"devDependencies": {
15791580
"@eslint/compat": "^1.1.1",
15801581
"@eslint/eslintrc": "^3.1.0",
1581-
"@eslint/js": "^9.10.0",
1582-
"@types/node": "^22.5.5",
1582+
"@eslint/js": "^9.11.1",
1583+
"@types/fs-extra": "^11.0.4",
1584+
"@types/node": "^22.7.2",
15831585
"@types/vscode": "^1.86.0",
15841586
"@vscode/test-electron": "^2.4.1",
15851587
"@vscode/vsce": "^3.1.0",
1586-
"esbuild": "^0.23.1",
1587-
"eslint": "^9.10.0",
1588+
"esbuild": "^0.24.0",
1589+
"eslint": "^9.11.1",
15881590
"eslint-config-prettier": "^9.1.0",
15891591
"eslint-plugin-prettier": "^5.2.1",
15901592
"globals": "^15.9.0",
1591-
"ovsx": "^0.9.4",
1593+
"ovsx": "^0.9.5",
15921594
"prettier": "^3.3.3",
15931595
"ts-loader": "^9.5.1",
15941596
"typescript": "^5.6.2",
1595-
"typescript-eslint": "^8.6.0"
1597+
"typescript-eslint": "^8.7.0"
15961598
},
15971599
"workspaces": [
15981600
"docs"
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<!--
2+
Please fill in all XXX markers and remove the comments if possible
3+
**After** creating the issue on GitHub, you can add screenshots and videos of what is happening.
4+
You can also add logs from the "Output" view of VSCode for RobotCode and RobotCode Language Server.
5+
-->
6+
7+
**Describe the bug**
8+
<!-- A clear and concise description of what the bug is. -->
9+
10+
XXX
11+
12+
13+
**Steps To Reproduce**
14+
15+
<!---
16+
Steps to reproduce the behavior:
17+
1. Go to '...'
18+
2. Click on '....'
19+
3. Scroll down to '....'
20+
4. See error
21+
22+
If needed and possible add some example source code like:
23+
```robotframework
24+
***Settings***
25+
Library Collections
26+
27+
***Test Cases***
28+
a simple test
29+
do something # this should shown something
30+
```
31+
-->
32+
33+
XXX
34+
35+
36+
**Expected behavior**
37+
<!-- A clear and concise description of what you expected to happen. -->
38+
39+
XXX
40+
41+
42+
**Screenshots/ Videos**
43+
<!-- If applicable, add screenshots or videos to help explain your problem. -->
44+
45+
XXX
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Python Version: ${{ PYTHON_VERSION }}
2+
RobotFramework Version: ${{ ROBOTFRAMEWORK_VERSION }}
3+
Additional tools: ${{ ADDITIONAL_TOOLS }}

vscode-client/languageToolsManager.ts

Lines changed: 93 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ import { PythonManager } from "./pythonmanger";
1212
import { LanguageStatusSeverity } from "vscode";
1313
import { TestControllerManager } from "./testcontrollermanager";
1414

15+
import * as path from "path";
16+
import * as fs from "fs-extra";
17+
1518
const NOT_INSTALLED = "not installed";
1619

1720
type QuickPickActionItem = {
@@ -168,6 +171,12 @@ export class LanguageToolsManager {
168171
}
169172
},
170173
},
174+
{
175+
label: "Report Issue",
176+
action: async (folder?: vscode.WorkspaceFolder): Promise<void> => {
177+
vscode.commands.executeCommand("robotcode.reportIssue", folder);
178+
},
179+
},
171180
];
172181

173182
constructor(
@@ -220,6 +229,87 @@ export class LanguageToolsManager {
220229
},
221230
),
222231

232+
vscode.commands.registerCommand("robotcode.reportIssue", async (folder?: vscode.WorkspaceFolder) => {
233+
if (folder === undefined) {
234+
if (vscode.window.activeTextEditor !== undefined) {
235+
folder = vscode.workspace.getWorkspaceFolder(vscode.window.activeTextEditor.document.uri);
236+
}
237+
}
238+
if (folder === undefined) {
239+
if (vscode.workspace.workspaceFolders !== undefined && vscode.workspace.workspaceFolders.length === 1) {
240+
folder = vscode.workspace.workspaceFolders[0];
241+
} else {
242+
if (vscode.workspace.workspaceFolders !== undefined && vscode.workspace.workspaceFolders.length > 1) {
243+
folder = await vscode.window.showWorkspaceFolderPick({
244+
placeHolder: "Select a workspace folder to report an issue for",
245+
});
246+
}
247+
}
248+
}
249+
const folders = folder !== undefined ? [folder] : (vscode.workspace.workspaceFolders ?? []);
250+
251+
const bodyTemplatePath = path.join(
252+
extensionContext.extensionPath,
253+
"resources",
254+
"report_issue_body_template.md",
255+
);
256+
const issueBody = (await fs.readFile(bodyTemplatePath, { encoding: "utf8" })).replaceAll("\r", "").trim();
257+
258+
const dataTemplatePath = path.join(
259+
extensionContext.extensionPath,
260+
"resources",
261+
"report_issue_data_template.md",
262+
);
263+
let data = (await fs.readFile(dataTemplatePath, { encoding: "utf8" })).replaceAll("\r", "").trim();
264+
265+
const pythonVersions: string[] = [];
266+
const robotFrameworkVersions: string[] = [];
267+
const robocopVersions: string[] = [];
268+
const tidyVersions: string[] = [];
269+
270+
for (const folder of folders) {
271+
const pythonInfo = await pythonManager.getPythonInfo(folder);
272+
273+
if (pythonInfo !== undefined) {
274+
const n = `${pythonInfo.version}${pythonInfo.type !== undefined ? " " + pythonInfo.type : ""}`;
275+
if (!pythonVersions.includes(n)) pythonVersions.push(n);
276+
}
277+
278+
const info = await this.languageClientsManager.getProjectInfo(folder);
279+
if (info !== undefined) {
280+
if (info.robotVersionString && !robotFrameworkVersions.includes(info.robotVersionString))
281+
robotFrameworkVersions.push(info.robotVersionString);
282+
283+
if (info.robocopVersionString && !robocopVersions.includes(info.robocopVersionString))
284+
robocopVersions.push(info.robocopVersionString);
285+
286+
if (info.tidyVersionString && !tidyVersions.includes(info.tidyVersionString))
287+
tidyVersions.push(info.tidyVersionString);
288+
}
289+
}
290+
291+
data = data.replace("${{ PYTHON_VERSION }}", pythonVersions.join(", "));
292+
data = data.replace("${{ ROBOTFRAMEWORK_VERSION }}", robotFrameworkVersions.join(", "));
293+
data = data.replace(
294+
"${{ ADDITIONAL_TOOLS }}",
295+
robocopVersions.length > 0 || tidyVersions.length > 0
296+
? [
297+
robocopVersions.map((v) => "robotframework-robocop==" + v).join(", "),
298+
tidyVersions.map((v) => "robotframework-tidy==" + v).join(", "),
299+
].join(", ")
300+
: "",
301+
);
302+
303+
const args = {
304+
extensionId: "d-biehl.robotcode",
305+
// issueTitle: "Issue with RobotCode",
306+
issueBody,
307+
data,
308+
};
309+
310+
await vscode.commands.executeCommand("workbench.action.openIssueReporter", args);
311+
}),
312+
223313
vscode.commands.registerCommand("robotcode.showToolMenu", async (folder?: vscode.WorkspaceFolder) => {
224314
let f = folder;
225315

@@ -285,14 +375,15 @@ export class LanguageToolsManager {
285375
case ClientState.Starting:
286376
this.removeFolder(folder);
287377
this.robotVersion.busy = true;
288-
await this.updateItems();
378+
289379
break;
290380
default:
291381
this.removeFolder(folder);
292382
this.robotVersion.busy = false;
293-
await this.updateItems();
383+
294384
break;
295385
}
386+
await this.updateItems();
296387
}),
297388
pythonManager.onActivePythonEnvironmentChanged(async (event) => {
298389
if (event.resource !== undefined) {

vscode-client/languageclientsmanger.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,9 @@ interface DiscoverInfoResult {
103103
}
104104

105105
export interface ProjectInfo {
106-
robotVersionString: string;
106+
robotVersionString?: string;
107107
robocopVersionString?: string;
108-
tidyVersionString: string;
108+
tidyVersionString?: string;
109109
}
110110

111111
interface RobotCodeContributions {

vscode-client/pythonmanger.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export interface ActivePythonEnvironmentChangedEvent {
1414
export class PythonInfo {
1515
constructor(
1616
public readonly name: string,
17+
public readonly type: string | undefined,
1718
public readonly version: string,
1819
public readonly path?: string,
1920
) {}
@@ -250,7 +251,8 @@ export class PythonManager {
250251
async getPythonInfo(folder: vscode.WorkspaceFolder): Promise<PythonInfo | undefined> {
251252
try {
252253
const config = vscode.workspace.getConfiguration(CONFIG_SECTION, folder);
253-
let name;
254+
let name: string | undefined;
255+
let type: string | undefined;
254256
let path: string | undefined;
255257
let version: string | undefined;
256258

@@ -271,13 +273,14 @@ export class PythonManager {
271273
version =
272274
env?.version !== undefined ? `${env.version.major}.${env.version.minor}.${env.version.micro}` : undefined;
273275
if (env?.environment !== undefined) {
274-
name = `('${env?.environment?.name ?? UNKNOWN}': ${env?.tools?.[0] ?? UNKNOWN})`;
276+
type = env?.tools?.[0];
277+
name = `('${env?.environment?.name ?? UNKNOWN}': ${type ?? UNKNOWN})`;
275278
} else {
276279
name = env?.executable.bitness ?? UNKNOWN;
277280
}
278281
}
279282

280-
return new PythonInfo(name ?? CUSTOM, version ?? UNKNOWN, path);
283+
return new PythonInfo(name ?? CUSTOM, type, version ?? UNKNOWN, path);
281284
} catch {
282285
return undefined;
283286
}

0 commit comments

Comments
 (0)