Skip to content

Commit f4ae73c

Browse files
authored
Add automatic project formatting (#814)
* Add biome as a dev dependency and add "npm format" script * Align new debugger code with project style
1 parent 1dcbd65 commit f4ae73c

File tree

11 files changed

+1170
-886
lines changed

11 files changed

+1170
-886
lines changed

biome.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
{
2+
"vcs": {
3+
"defaultBranch": "master"
4+
},
25
"formatter": {
36
"enabled": true,
47
"formatWithErrors": false,
@@ -16,7 +19,7 @@
1619
"rules": {
1720
"style": {
1821
"noUselessElse": "off",
19-
"useImportType": "off"
22+
"useImportType": "off"
2023
}
2124
}
2225
}

package-lock.json

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

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
],
3232
"main": "./out/extension.js",
3333
"scripts": {
34+
"format": "biome format --write --changed src",
3435
"compile": "tsc -p ./",
3536
"lint": "eslint ./src --quiet",
3637
"watch": "tsc -watch -p ./",
@@ -263,7 +264,7 @@
263264
"maximum": 200,
264265
"description": "Scale factor (%) to apply to the Godot documentation viewer."
265266
},
266-
"godotTools.documentation.displayMinimap":{
267+
"godotTools.documentation.displayMinimap": {
267268
"type": "boolean",
268269
"default": true,
269270
"description": "Whether to display the minimap for the Godot documentation viewer."
@@ -875,6 +876,7 @@
875876
}
876877
},
877878
"devDependencies": {
879+
"@biomejs/biome": "^1.9.4",
878880
"@types/chai": "^4.3.11",
879881
"@types/chai-as-promised": "^8.0.1",
880882
"@types/chai-subset": "^1.3.5",

src/debugger/godot4/debug_session.ts

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export class GodotDebugSession extends LoggingDebugSession {
2929

3030
public variables_manager: VariablesManager;
3131

32-
public constructor(projectVersion : string) {
32+
public constructor(projectVersion: string) {
3333
super();
3434

3535
this.setDebuggerLinesStartAt1(false);
@@ -233,14 +233,14 @@ export class GodotDebugSession extends LoggingDebugSession {
233233

234234
// TODO: create scopes dynamically for a given frame
235235
const vscode_scope_ids = this.variables_manager.get_or_create_frame_scopes(args.frameId);
236-
const scopes_with_references = [
237-
{name: "Locals", variablesReference: vscode_scope_ids.Locals, expensive: false},
238-
{name: "Members", variablesReference: vscode_scope_ids.Members, expensive: false},
239-
{name: "Globals", variablesReference: vscode_scope_ids.Globals, expensive: false},
240-
];
236+
const scopes_with_references = [
237+
{ name: "Locals", variablesReference: vscode_scope_ids.Locals, expensive: false },
238+
{ name: "Members", variablesReference: vscode_scope_ids.Members, expensive: false },
239+
{ name: "Globals", variablesReference: vscode_scope_ids.Globals, expensive: false },
240+
];
241241

242242
response.body = {
243-
scopes: scopes_with_references
243+
scopes: scopes_with_references,
244244
// scopes: [
245245
// { name: "Locals", variablesReference: 1, expensive: false },
246246
// { name: "Members", variablesReference: 2, expensive: false },
@@ -252,7 +252,10 @@ export class GodotDebugSession extends LoggingDebugSession {
252252
this.sendResponse(response);
253253
}
254254

255-
protected async variablesRequest(response: DebugProtocol.VariablesResponse, args: DebugProtocol.VariablesArguments) {
255+
protected async variablesRequest(
256+
response: DebugProtocol.VariablesResponse,
257+
args: DebugProtocol.VariablesArguments,
258+
) {
256259
log.info("variablesRequest", args);
257260
try {
258261
const variables = await this.variables_manager.get_vscode_object(args.variablesReference);
@@ -274,10 +277,13 @@ export class GodotDebugSession extends LoggingDebugSession {
274277
log.info("evaluateRequest", args);
275278

276279
try {
277-
const parsed_variable = await this.variables_manager.get_vscode_variable_by_name(args.expression, args.frameId);
280+
const parsed_variable = await this.variables_manager.get_vscode_variable_by_name(
281+
args.expression,
282+
args.frameId,
283+
);
278284
response.body = {
279285
result: parsed_variable.value,
280-
variablesReference: parsed_variable.variablesReference
286+
variablesReference: parsed_variable.variablesReference,
281287
};
282288
} catch (error) {
283289
response.success = false;

src/debugger/godot4/helpers.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { GodotVariable, } from "../debug_runtime";
1+
import { GodotVariable } from "../debug_runtime";
22
import { SceneNode } from "../scene_tree_provider";
33
import { ObjectId } from "./variables/variants";
44

@@ -43,9 +43,12 @@ export function get_sub_values(value: any): GodotVariable[] {
4343
} else if (value instanceof Map) {
4444
subValues = [];
4545
for (const [key, val] of value.entries()) {
46-
const name = typeof key["stringify_value"] === "function" ? `${key.type_name()}${key.stringify_value()}` : `${key}`;
46+
const name =
47+
typeof key["stringify_value"] === "function"
48+
? `${key.type_name()}${key.stringify_value()}`
49+
: `${key}`;
4750
const godot_id = val instanceof ObjectId ? val.id : undefined;
48-
subValues.push({id: godot_id, name, value: val } as GodotVariable);
51+
subValues.push({ id: godot_id, name, value: val } as GodotVariable);
4952
}
5053
} else if (typeof value["sub_values"] === "function") {
5154
subValues = value.sub_values()?.map((sva) => {
@@ -59,4 +62,4 @@ export function get_sub_values(value: any): GodotVariable[] {
5962
}
6063

6164
return subValues;
62-
}
65+
}

0 commit comments

Comments
 (0)