Chore: Update lezer package of prometheus frontend (#91252)

* update lezer package

* Use UnquotedLabelMatcher instead of LabelMatcher

* Use UnquotedLabelMatcher instead of LabelMatcher in parsing.ts
This commit is contained in:
ismail simsek authored and GitHub committed 2024-08-11 23:48:04 +02:00
1 parent 75f0b3a228
commit b8ebc5d463
6 files changed
+23 -25

No files matched your search

+2 -2
View File
@@ -48,8 +48,8 @@
"@leeoniya/ufuzzy": "1.0.14",
"@lezer/common": "1.2.1",
"@lezer/highlight": "1.2.0",
"@lezer/lr": "1.4.0",
"@prometheus-io/lezer-promql": "0.52.1",
"@lezer/lr": "1.4.2",
"@prometheus-io/lezer-promql": "0.53.1",
"@reduxjs/toolkit": "2.2.7",
"d3": "7.9.0",
"date-fns": "3.6.0",
@@ -9,7 +9,6 @@ import {
FunctionCallBody,
GroupingLabels,
Identifier,
LabelMatcher,
LabelMatchers,
LabelName,
MatchOp,
@@ -19,6 +18,7 @@ import {
parser,
PromQL,
StringLiteral,
UnquotedLabelMatcher,
VectorSelector,
} from '@prometheus-io/lezer-promql';
@@ -33,7 +33,7 @@ type NodeTypeId =
| typeof FunctionCallBody
| typeof GroupingLabels
| typeof Identifier
| typeof LabelMatcher
| typeof UnquotedLabelMatcher
| typeof LabelMatchers
| typeof LabelName
| typeof PromQL
@@ -178,7 +178,7 @@ const RESOLVERS: Resolver[] = [
fun: resolveInFunction,
},
{
path: [StringLiteral, LabelMatcher],
path: [StringLiteral, UnquotedLabelMatcher],
fun: resolveLabelMatcher,
},
{
@@ -186,7 +186,7 @@ const RESOLVERS: Resolver[] = [
fun: resolveTopLevel,
},
{
path: [ERROR_NODE_NAME, LabelMatcher],
path: [ERROR_NODE_NAME, UnquotedLabelMatcher],
fun: resolveLabelMatcher,
},
{
@@ -216,7 +216,7 @@ function getLabelOp(opNode: SyntaxNode): LabelOperator | null {
}
function getLabel(labelMatcherNode: SyntaxNode, text: string): Label | null {
if (labelMatcherNode.type.id !== LabelMatcher) {
if (labelMatcherNode.type.id !== UnquotedLabelMatcher) {
return null;
}
@@ -253,7 +253,7 @@ function getLabels(labelMatchersNode: SyntaxNode, text: string): Label[] {
return [];
}
const labelNodes = labelMatchersNode.getChildren(LabelMatcher);
const labelNodes = labelMatchersNode.getChildren(UnquotedLabelMatcher);
return labelNodes.map((ln) => getLabel(ln, text)).filter(notEmpty);
}
@@ -317,7 +317,7 @@ function resolveLabelMatcher(node: SyntaxNode, text: string, pos: number): Situa
// - or an error node (like in `{job=^}`)
const inStringNode = !node.type.isError;
const parent = walk(node, [['parent', LabelMatcher]]);
const parent = walk(node, [['parent', UnquotedLabelMatcher]]);
if (parent === null) {
return null;
}
@@ -387,7 +387,7 @@ function resolveDurations(node: SyntaxNode, text: string, pos: number): Situatio
function resolveLabelKeysWithEquals(node: SyntaxNode, text: string, pos: number): Situation | null {
// next false positive:
// `something{a="1"^}`
const child = walk(node, [['firstChild', LabelMatcher]]);
const child = walk(node, [['firstChild', UnquotedLabelMatcher]]);
if (child !== null) {
// means the label-matching part contains at least one label already.
//
@@ -514,7 +514,7 @@ describe('buildVisualQueryFromString', () => {
text: 'afe}',
from: 14,
to: 18,
parentType: 'LabelMatcher',
parentType: 'UnquotedLabelMatcher',
},
],
query: {
@@ -11,7 +11,6 @@ import {
FunctionIdentifier,
GroupingLabels,
Identifier,
LabelMatcher,
LabelName,
MatchingModifierClause,
MatchOp,
@@ -20,6 +19,7 @@ import {
ParenExpr,
parser,
StringLiteral,
UnquotedLabelMatcher,
VectorSelector,
Without,
} from '@prometheus-io/lezer-promql';
@@ -145,7 +145,7 @@ export function handleExpression(expr: string, node: SyntaxNode, context: Contex
break;
}
case LabelMatcher: {
case UnquotedLabelMatcher: {
// Same as MetricIdentifier should be just one per query.
visQuery.labels.push(getLabel(expr, node));
const err = node.getChild(ErrorId);