Skip to content

Commit c127dbb

Browse files
stalepclaude
andcommitted
Fix line-based role context resolution and warn on invalid jarPath
- Role property keys at indent 4 (e.g. run-scripts:) now correctly resolve to ROLE_KEY instead of ROLE_SCRIPT_REF in the fallback path - Host list entries under roles now resolve to ROLE_HOST_REF in the fallback path, matching the tree-based logic - Show warning when configured qdup.lsp.jarPath does not exist instead of silently falling back Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent ad0e89b commit c127dbb

2 files changed

Lines changed: 23 additions & 10 deletions

File tree

qDup-lsp/src/main/java/io/hyperfoil/tools/qdup/lsp/CursorContextResolver.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -240,16 +240,19 @@ private YamlContext resolveFromLines(QDupDocument document, int line, int charac
240240
return YamlContext.ROLE_NAME;
241241
}
242242
if (indent == 4) {
243-
String key = trimmed.split(":")[0].trim();
244-
if (key.endsWith("-scripts")) {
245-
return YamlContext.ROLE_SCRIPT_REF;
246-
}
243+
// At indent 4 we are on the role property key itself (e.g. "run-scripts:"),
244+
// which should always be treated as ROLE_KEY.
247245
return YamlContext.ROLE_KEY;
248246
}
249-
// Inside a role property
247+
// Inside a role property — resolve based on nearest parent key
250248
String roleKey = findNearestKey(document, line, 4);
251-
if (roleKey != null && roleKey.endsWith("-scripts")) {
252-
return YamlContext.ROLE_SCRIPT_REF;
249+
if (roleKey != null) {
250+
if (roleKey.endsWith("-scripts")) {
251+
return YamlContext.ROLE_SCRIPT_REF;
252+
}
253+
if ("hosts".equals(roleKey)) {
254+
return YamlContext.ROLE_HOST_REF;
255+
}
253256
}
254257
return YamlContext.ROLE_KEY;
255258
}

vscode/src/extension.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,19 @@ async function resolveServerOptions(context: ExtensionContext): Promise<ServerOp
5353

5454
// 1. User-configured JAR path
5555
const jarPath = config.get<string>('jarPath', '');
56-
if (jarPath && fs.existsSync(jarPath)) {
57-
const java = findJava();
58-
return { command: java, args: ['-jar', jarPath] };
56+
if (jarPath) {
57+
if (fs.existsSync(jarPath)) {
58+
const java = findJava();
59+
return { command: java, args: ['-jar', jarPath] };
60+
}
61+
window.showWarningMessage(
62+
`Configured qDup LSP JAR not found: ${jarPath}. Falling back to other discovery methods.`,
63+
'Open Settings'
64+
).then(selection => {
65+
if (selection === 'Open Settings') {
66+
commands.executeCommand('workbench.action.openSettings', 'qdup.lsp.jarPath');
67+
}
68+
});
5969
}
6070

6171
// 2. Bundled JAR in extension's server/ directory

0 commit comments

Comments
 (0)