diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ce54939..dea4c5cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ All notable changes to the **kdb VS Code extension** are documented in this file ### Enhancements - Semantic highlighting for local variables -- Display version of Insights server connected +- Display version of connected Insights server ### Fixes @@ -15,6 +15,7 @@ All notable changes to the **kdb VS Code extension** are documented in this file - Fix for Issue [#382](https://github.com/KxSystems/kx-vscode/issues/382) - Fix for run q file not using the current editor contents - Fix for autocomplete for new and unsaved documents +- Fix for results tab ### Internal Improvements diff --git a/server/src/parser/parser.ts b/server/src/parser/parser.ts index ac4bc60f..566ba6e1 100644 --- a/server/src/parser/parser.ts +++ b/server/src/parser/parser.ts @@ -88,9 +88,8 @@ function assignment(state: State, token: Token) { if (top?.tokenType === Colon || top?.tokenType === DoubleColon) { token.assignment = [top]; stack.pop(); - top = stack.shift(); - if (top) { - token.assignment.push(top); + if (stack.length > 0) { + token.assignment.push(...stack); clear(stack); } } @@ -182,9 +181,6 @@ function expression(state: State, tokens: Token[]) { break; } break; - case RParen: - case LParen: - break; default: stack.push(token); break; diff --git a/server/src/parser/utils.ts b/server/src/parser/utils.ts index 9b78b8cf..fb2569e1 100644 --- a/server/src/parser/utils.ts +++ b/server/src/parser/utils.ts @@ -122,6 +122,9 @@ export function amended(token: Token) { } export function local(token: Token, tokens: Token[]) { + if (qualified(token)) { + return false; + } const scope = inLambda(token); if (scope && !scope.tangled) { if (token.image === "x" || token.image === "y" || token.image === "z") { diff --git a/server/src/qLangServer.ts b/server/src/qLangServer.ts index bd6940e7..016e316e 100644 --- a/server/src/qLangServer.ts +++ b/server/src/qLangServer.ts @@ -167,7 +167,7 @@ export default class QLangServer { public setSettings(settings: LSPAny) { this.settings = { - debug: settings.debug || false, + debug: settings.debug_parser || false, linting: settings.linting || false, refactoring: settings.refactoring || "Workspace", }; diff --git a/src/extension.ts b/src/extension.ts index e0338dfa..800f9eb6 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -471,7 +471,7 @@ export async function activate(context: ExtensionContext) { commands.registerCommand( "kdb.createDataSource", async (item: FileTreeItem) => { - if (hasWorkspaceOrShowOption()) { + if (hasWorkspaceOrShowOption("adding datasources")) { const uri = await addWorkspaceFile(item, "datasource", ".kdb.json"); if (uri) { @@ -501,7 +501,7 @@ export async function activate(context: ExtensionContext) { commands.registerCommand( "kdb.createScratchpad", async (item: FileTreeItem) => { - if (hasWorkspaceOrShowOption()) { + if (hasWorkspaceOrShowOption("adding workbooks")) { const uri = await addWorkspaceFile(item, "workbook", ".kdb.q"); if (uri) { await window.showTextDocument(uri); @@ -513,7 +513,7 @@ export async function activate(context: ExtensionContext) { commands.registerCommand( "kdb.createPythonScratchpad", async (item: FileTreeItem) => { - if (hasWorkspaceOrShowOption()) { + if (hasWorkspaceOrShowOption("adding workbooks")) { const uri = await addWorkspaceFile(item, "workbook", ".kdb.py"); if (uri) { await window.showTextDocument(uri); diff --git a/src/utils/core.ts b/src/utils/core.ts index a8577ffb..7584fdb6 100644 --- a/src/utils/core.ts +++ b/src/utils/core.ts @@ -635,12 +635,15 @@ export function formatTable(headers_: any, rows_: any, opts: any) { return result.join("\n"); } -export function hasWorkspaceOrShowOption() { +export function hasWorkspaceOrShowOption(action: string) { if (workspace.workspaceFolders && workspace.workspaceFolders.length > 0) { return true; } window - .showWarningMessage("No workspace folder is opened.", "Open") + .showWarningMessage( + `No workspace folder is open. Please open a folder to enable ${action}.`, + "Open", + ) .then((res) => { if (res === "Open") { commands.executeCommand("workbench.action.files.openFolder"); diff --git a/test/suite/qLangServer.test.ts b/test/suite/qLangServer.test.ts index 8ddb95b7..98bd75d6 100644 --- a/test/suite/qLangServer.test.ts +++ b/test/suite/qLangServer.test.ts @@ -381,11 +381,23 @@ describe("qLangServer", () => { }); describe("onSemanticTokens", () => { - it("should find semantic local variables", () => { + it("should tokenize local variables", () => { const params = createDocument("a:{[b;c]d:1;b*c*d}"); const result = server.onSemanticTokens(params); assert.strictEqual(result.data.length, 30); }); + + it("should ignore qualified variables", () => { + const params = createDocument("a:{.ns.b:1;.ns.b}"); + const result = server.onSemanticTokens(params); + assert.strictEqual(result.data.length, 0); + }); + + it("should detect empty lists", () => { + const params = createDocument("a:{b:();b}"); + const result = server.onSemanticTokens(params); + assert.strictEqual(result.data.length, 10); + }); }); describe("setSettings", () => { diff --git a/test/suite/utils.test.ts b/test/suite/utils.test.ts index 28649d0a..e63442c7 100644 --- a/test/suite/utils.test.ts +++ b/test/suite/utils.test.ts @@ -355,13 +355,13 @@ describe("Utils", () => { it("should return true if a workspace folder is opened", () => { sinon.stub(vscode.workspace, "workspaceFolders").get(() => [{}]); - const result = coreUtils.hasWorkspaceOrShowOption(); + const result = coreUtils.hasWorkspaceOrShowOption("Test"); assert.strictEqual(result, true); }); it("should return false and display message if no workspace", () => { const stub = sinon.stub(vscode.window, "showWarningMessage").resolves(); - const result = coreUtils.hasWorkspaceOrShowOption(); + const result = coreUtils.hasWorkspaceOrShowOption("Test"); assert.strictEqual(result, false); assert.ok(stub.calledOnce); });