@prometheus-io/codemirror-promql
Version:
a CodeMirror mode for the PromQL language
32 lines (31 loc) • 1.21 kB
TypeScript
import { Diagnostic } from '@codemirror/lint';
import { SyntaxNode } from '@lezer/common';
import { EditorState } from '@codemirror/state';
import { ValueType } from '../types';
export declare class Parser {
private readonly tree;
private readonly state;
private readonly diagnostics;
constructor(state: EditorState);
getDiagnostics(): Diagnostic[];
analyze(): void;
private diagnoseAllErrorNodes;
checkAST(node: SyntaxNode | null): ValueType;
private checkAggregationExpr;
private checkBinaryExpr;
private checkCallFunction;
private checkAnchoredSmoothedExpr;
private checkVectorSelector;
private expectType;
private addDiagnostic;
private addDiagnosticWithSeverity;
private isTopLevelDurationRangeExpr;
/**
* Returns the duration expression used as the subquery resolution step (after
* the `:`). Lezer represents `SubqueryExpr` with direct children only
* (`VectorSelector` plus one or two `DurationExpr` nodes), so the step is the
* last direct `DurationExpr` when two are present. This avoids confusing
* colons inside label matchers with the subquery colon.
*/
private getSubqueryStepDurationExpr;
}