Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
714 changes: 381 additions & 333 deletions package-lock.json

Large diffs are not rendered by default.

13 changes: 6 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -893,11 +893,10 @@
},
"devDependencies": {
"@biomejs/biome": "^1.9.4",
"@types/chai": "^4.3.11",
"@types/chai-as-promised": "^8.0.1",
"@types/chai-subset": "^1.3.5",
"@types/chai": "^5.2.3",
"@types/chai-as-promised": "^8.0.2",
"@types/marked": "^4.0.8",
"@types/mocha": "^10.0.6",
"@types/mocha": "^10.0.10",
"@types/node": "^18.19.75",
"@types/prismjs": "^1.16.8",
"@types/sinon": "^17.0.4",
Expand All @@ -909,12 +908,12 @@
"@vscode/test-cli": "^0.0.10",
"@vscode/test-electron": "^2.3.8",
"@vscode/vsce": "^2.29.0",
"chai": "^4.5.0",
"chai-as-promised": "^8.0.1",
"chai": "^6.2.2",
"chai-as-promised": "^8.0.2",
"chai-subset": "^1.6.0",
"esbuild": "^0.25.0",
"eslint": "^8.37.0",
"mocha": "^10.8.2",
"mocha": "^11.7.5",
"sinon": "^19.0.2",
"ts-node": "^10.9.1",
"tsconfig-paths": "^4.2.0",
Expand Down
7 changes: 4 additions & 3 deletions src/debugger/debugger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
window,
workspace,
} from "vscode";
import { createLogger, get_project_version, register_command, set_context } from "../utils";
import { createLogger, get_project_version, parseGodotVersionOrDefault, register_command, set_context } from "../utils";
import { GodotVariable } from "./debug_runtime";
import { GodotDebugSession as Godot3DebugSession } from "./godot3/debug_session";
import { GodotDebugSession as Godot4DebugSession } from "./godot4/debug_session";
Expand Down Expand Up @@ -114,7 +114,8 @@ export class GodotDebugger implements DebugAdapterDescriptorFactory, DebugConfig
log.info(`Project version identified as ${projectVersion}`);

if (projectVersion?.startsWith("4")) {
this.session = new Godot4DebugSession(projectVersion);
const parsedVersion = parseGodotVersionOrDefault(projectVersion);
this.session = new Godot4DebugSession(parsedVersion);
} else {
this.session = new Godot3DebugSession();
}
Expand Down Expand Up @@ -313,7 +314,7 @@ export class GodotDebugger implements DebugAdapterDescriptorFactory, DebugConfig
stringify_value: () => `<${godot_object.godot_id}>`,
sub_values: () => godot_object.sub_values,
},
} as GodotVariable;
} as GodotVariable; // TODO: why not `satisfies GodotVariable`
}

public refresh_scene_tree() {
Expand Down
4 changes: 2 additions & 2 deletions src/debugger/godot3/server_controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export class ServerController {
log.info("Using 'editor_path' variable from launch.json");

log.info(`Verifying version of '${args.editor_path}'`);
result = verify_godot_version(args.editor_path, "3");
result = await verify_godot_version(args.editor_path, "3");
godotPath = result.godotPath;
log.info(`Verification result: ${result.status}, version: "${result.version}"`);

Expand Down Expand Up @@ -147,7 +147,7 @@ export class ServerController {
godotPath = get_configuration(settingName);

log.info(`Verifying version of '${godotPath}'`);
result = verify_godot_version(godotPath, "3");
result = await verify_godot_version(godotPath, "3");
godotPath = result.godotPath;
log.info(`Verification result: ${result.status}, version: "${result.version}"`);

Expand Down
28 changes: 22 additions & 6 deletions src/debugger/godot4/debug_session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ import { DebugProtocol } from "@vscode/debugprotocol";
import { Subject } from "await-notify";
import * as fs from "node:fs";
import { createLogger } from "../../utils";
import { GodotDebugData } from "../debug_runtime";
import { GodotDebugData, GodotVariable } from "../debug_runtime";
import { AttachRequestArguments, LaunchRequestArguments } from "../debugger";
import { InspectorProvider } from "../inspector_provider";
import { SceneTreeProvider } from "../scene_tree_provider";
import { ServerController } from "./server_controller";
import { VariablesManager } from "./variables/variables_manager";
import { GodotVersion } from "../../utils/godot_version";

const log = createLogger("debugger.session", { output: "Godot Debugger" });

Expand All @@ -29,7 +30,7 @@ export class GodotDebugSession extends LoggingDebugSession {

public variables_manager?: VariablesManager; // defined only between DAP debug_enter/debug_exit events

public constructor(projectVersion: string) {
public constructor(projectVersion: GodotVersion) {
super();

this.setDebuggerLinesStartAt1(false);
Expand Down Expand Up @@ -276,10 +277,25 @@ export class GodotDebugSession extends LoggingDebugSession {
return; // not inside a debug_enter/debug_exit

try {
const parsed_variable = await this.variables_manager.get_vscode_variable_by_name(
args.expression,
args.frameId || 0,
);
let parsed_variable: DebugProtocol.Variable;

if (this.controller.projectVersion.compare(GodotVersion.fromNumbers(4, 6, 0)) >= 0) {
// request evaluation from server
const decodedVariant = await this.controller.evaluate(args.expression, args.frameId || 0);
parsed_variable = await this.variables_manager.parse_variable(
{name: args.expression, value: decodedVariant} satisfies GodotVariable,
VariablesManager.EVALUATE_SCOPE_GODOT_ID,
[],
this.variables_manager.godot_id_to_vscode_id_mapper,
);
} else {
// old version fallback: look up in already resolved variables
parsed_variable = await this.variables_manager.get_vscode_variable_by_name(
args.expression,
args.frameId || 0,
);
}

response.body = {
result: parsed_variable.value,
variablesReference: parsed_variable.variablesReference,
Expand Down
6 changes: 3 additions & 3 deletions src/debugger/godot4/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export async function get_sub_values(value: any, variables_manager: VariablesMan
if (Array.isArray(value)) {
subValues = value.map((val, i) => {
const godot_id = val instanceof ObjectId ? val.id : undefined;
return { id: godot_id, name: `${i}`, value: val } as GodotVariable;
return { id: godot_id, name: `${i}`, value: val } satisfies GodotVariable;
});
} else if (value instanceof Map) {
subValues = [];
Expand All @@ -55,11 +55,11 @@ export async function get_sub_values(value: any, variables_manager: VariablesMan
: `${key}`;
}
const godot_id = val instanceof ObjectId ? val.id : undefined;
subValues.push({ id: godot_id, name: key_name, value: val } as GodotVariable);
subValues.push({ id: godot_id, name: key_name, value: val } satisfies GodotVariable);
}
} else if (typeof value.sub_values === "function") {
subValues = value.sub_values()?.map((sva) => {
return { name: sva.name, value: sva.value } as GodotVariable;
return { name: sva.name, value: sva.value } satisfies GodotVariable;
});
}
}
Expand Down
Loading
Loading