From 8d3faabc90dcc2f25809e72e7bf35f0eedc44f3d Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 8 Nov 2024 23:09:52 +0100 Subject: [PATCH] Update dependency @lezer/lr to v1.4.2 (#87522) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update dependency @lezer/lr to v1.4.2 * Fix: Update dependency @lezer/lr to v1.4.2 (#94818) * Update dependency @lezer/lr to v1.4.2 * Tempo: Update error detection shift in error lookup Since lezer 1.3.8 the position seems to be shifted + 1 * Add back looking for errors behind the cursor * Post-merge fixes --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * Fix the resolvers for loki situation * grammar --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Piotr Jamróz Co-authored-by: ismail simsek --- package.json | 2 +- .../monaco-completion-provider/situation.test.ts | 11 +++++++++++ .../monaco-completion-provider/situation.ts | 16 ++++++++-------- public/app/plugins/datasource/tempo/package.json | 2 +- .../datasource/tempo/traceql/situation.ts | 4 ++++ yarn.lock | 13 ++----------- 6 files changed, 27 insertions(+), 21 deletions(-) diff --git a/package.json b/package.json index 9c86f59a831..a8eb0dd3c0d 100644 --- a/package.json +++ b/package.json @@ -280,7 +280,7 @@ "@leeoniya/ufuzzy": "1.0.14", "@lezer/common": "1.2.3", "@lezer/highlight": "1.2.1", - "@lezer/lr": "1.3.3", + "@lezer/lr": "1.4.2", "@locker/near-membrane-dom": "0.13.6", "@locker/near-membrane-shared": "0.13.6", "@locker/near-membrane-shared-dom": "0.13.6", diff --git a/public/app/plugins/datasource/loki/components/monaco-query-field/monaco-completion-provider/situation.test.ts b/public/app/plugins/datasource/loki/components/monaco-query-field/monaco-completion-provider/situation.test.ts index 13444c8dcb8..eb3b6c1b59f 100644 --- a/public/app/plugins/datasource/loki/components/monaco-query-field/monaco-completion-provider/situation.test.ts +++ b/public/app/plugins/datasource/loki/components/monaco-query-field/monaco-completion-provider/situation.test.ts @@ -367,6 +367,17 @@ describe('situation', () => { }); }); + it('identifies all labels from queries when cursor is at the beginning', () => { + assertSituation('{^,two!="val2",three=~"val3",four!~"val4"}', { + type: 'IN_LABEL_SELECTOR_NO_LABEL_NAME', + otherLabels: [ + { name: 'two', value: 'val2', op: '!=' }, + { name: 'three', value: 'val3', op: '=~' }, + { name: 'four', value: 'val4', op: '!~' }, + ], + }); + }); + it('identifies all labels from queries when cursor is at end', () => { // Note the extra whitespace, if the cursor is after whitespace, the situation will fail to resolve assertSituation('{one="val1",two!="val2",three=~"val3",four!~"val4",^}', { diff --git a/public/app/plugins/datasource/loki/components/monaco-query-field/monaco-completion-provider/situation.ts b/public/app/plugins/datasource/loki/components/monaco-query-field/monaco-completion-provider/situation.ts index ce8d939873b..0b6b4b07083 100644 --- a/public/app/plugins/datasource/loki/components/monaco-query-field/monaco-completion-provider/situation.ts +++ b/public/app/plugins/datasource/loki/components/monaco-query-field/monaco-completion-provider/situation.ts @@ -185,7 +185,13 @@ const ERROR_NODE_ID = 0; const RESOLVERS: Resolver[] = [ { - paths: [[Selector], [Selector, Matchers], [Matchers], [ERROR_NODE_ID, Matchers, Selector]], + paths: [ + [Selector], + [Selector, Matchers], + [Matchers], + [ERROR_NODE_ID, Matchers], + [ERROR_NODE_ID, Matchers, Selector], + ], fun: resolveSelector, }, { @@ -624,13 +630,7 @@ function resolveSelector(node: SyntaxNode, text: string, pos: number): Situation } } - const selectorNode = - node.type.id === ERROR_NODE_ID - ? walk(node, [ - ['parent', Matchers], - ['parent', Selector], - ]) - : node; + const selectorNode = node.type.id === ERROR_NODE_ID ? walk(node, [['parent', Matchers]]) : node; if (!selectorNode) { return null; } diff --git a/public/app/plugins/datasource/tempo/package.json b/public/app/plugins/datasource/tempo/package.json index 54cc51ac95f..492aa6830f9 100644 --- a/public/app/plugins/datasource/tempo/package.json +++ b/public/app/plugins/datasource/tempo/package.json @@ -16,7 +16,7 @@ "@grafana/schema": "workspace:*", "@grafana/ui": "workspace:*", "@lezer/common": "1.2.3", - "@lezer/lr": "1.3.3", + "@lezer/lr": "1.4.2", "@opentelemetry/api": "1.9.0", "@opentelemetry/exporter-collector": "0.25.0", "@opentelemetry/semantic-conventions": "1.27.0", diff --git a/public/app/plugins/datasource/tempo/traceql/situation.ts b/public/app/plugins/datasource/tempo/traceql/situation.ts index 7df07648cf8..65259a7a9ab 100644 --- a/public/app/plugins/datasource/tempo/traceql/situation.ts +++ b/public/app/plugins/datasource/tempo/traceql/situation.ts @@ -169,6 +169,10 @@ export function getSituation(text: string, offset: number): Situation | null { // Try again with the previous character. errorNode = getErrorNode(tree, shiftedOffset - 1); } + if (!errorNode) { + // Try again with the next character + errorNode = getErrorNode(tree, shiftedOffset + 1); + } const cur = errorNode != null ? errorNode.cursor() : tree.cursorAt(shiftedOffset); diff --git a/yarn.lock b/yarn.lock index 0695f6b04aa..bc6e9c87b2c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3403,7 +3403,7 @@ __metadata: "@grafana/schema": "workspace:*" "@grafana/ui": "workspace:*" "@lezer/common": "npm:1.2.3" - "@lezer/lr": "npm:1.3.3" + "@lezer/lr": "npm:1.4.2" "@opentelemetry/api": "npm:1.9.0" "@opentelemetry/exporter-collector": "npm:0.25.0" "@opentelemetry/semantic-conventions": "npm:1.27.0" @@ -4983,15 +4983,6 @@ __metadata: languageName: node linkType: hard -"@lezer/lr@npm:1.3.3": - version: 1.3.3 - resolution: "@lezer/lr@npm:1.3.3" - dependencies: - "@lezer/common": "npm:^1.0.0" - checksum: 10/7e61dc2554b85560ef1af6d3a6112c711d20d54e0c3184657099be8dc40d2747d28d5d332cc1b0d75064846d51fbff0bed162550a332aeccdfa36836b5541cfd - languageName: node - linkType: hard - "@lezer/lr@npm:1.4.2": version: 1.4.2 resolution: "@lezer/lr@npm:1.4.2" @@ -18720,7 +18711,7 @@ __metadata: "@leeoniya/ufuzzy": "npm:1.0.14" "@lezer/common": "npm:1.2.3" "@lezer/highlight": "npm:1.2.1" - "@lezer/lr": "npm:1.3.3" + "@lezer/lr": "npm:1.4.2" "@locker/near-membrane-dom": "npm:0.13.6" "@locker/near-membrane-shared": "npm:0.13.6" "@locker/near-membrane-shared-dom": "npm:0.13.6"