UNPKG

flink-sql-language-server

Version:

A LSP-based language server for Apache Flink SQL

77 lines (76 loc) 2.93 kB
import * as lsp from 'vscode-languageserver'; import { TextDocument } from 'vscode-languageserver-textdocument'; import { AsDatabaseContext, AsTableContext, CommaTableContext, CreateDatabaseContext, CreateTableContext, CreateViewContext, GroupByContext, InsertContext, MapQueryContext, MapTableContext, MatchRecognizeContext, OrderByContext, QueryContext, TableLateralContext, TableReferenceContext, TableSourceContext, WhereContext } from '../lib/FlinkSQLParser'; import { FlinkSQLParserListener } from '../lib/FlinkSQLParserListener'; export declare enum StructureNodeTypeEnum { SINK = "sink", SINK_DB = "sink_db", SOURCE = "source", SOURCE_DB = "source_db", DIM = "dim", SNAPSHOT = "snapshot", VIEW = "view", SELECT = "select", FILTER = "filter", GROUP = "group", UNION = "union", EXCEPT = "except", INTERSECT = "intersect", JOIN = "join", TOP_N = "top_n", CORRELATE = "correlate", UD_TF = "ud_tf", CEP = "cep" } export interface StructureNodeEdge { from: number; to: number; } export interface StructureNodeData { id: number; name: string; type: StructureNodeTypeEnum; range: lsp.Range; } export interface StructureResult { nodes: StructureNodeData[]; edges: StructureNodeEdge[]; } export declare class FlinkStructureListener implements FlinkSQLParserListener { private document; private nodes; private edges; private id; private originalText; constructor(document: TextDocument); private getId; private addStructureNode; getNodes(): StructureNodeData[]; getEdges(): StructureNodeEdge[]; enterInsert(ctx: InsertContext): void; enterQuery(ctx: QueryContext): void; enterWhere(ctx: WhereContext): void; enterGroupBy(ctx: GroupByContext): void; enterOrderBy(ctx: OrderByContext): void; enterMatchRecognize(ctx: MatchRecognizeContext): void; enterMapQuery(ctx: MapQueryContext): void; enterMapTable(ctx: MapTableContext): void; enterTableReference(ctx: TableReferenceContext): void; enterTableSource(ctx: TableSourceContext): void; enterTableLateral(ctx: TableLateralContext): void; enterCommaTable(ctx: CommaTableContext): void; enterAsTable(ctx: AsTableContext): void; enterCreateTable(ctx: CreateTableContext): void; enterAsDatabase(ctx: AsDatabaseContext): void; enterCreateDatabase(ctx: CreateDatabaseContext): void; enterCreateView(ctx: CreateViewContext): void; } export declare function ignoreInsertSource(nodes: StructureNodeData[], edges: StructureNodeEdge[]): { nodes: StructureNodeData[]; edges: StructureNodeEdge[]; }; export declare function addFromCreateContext(nodes: StructureNodeData[], edges: StructureNodeEdge[]): { nodes: StructureNodeData[]; edges: StructureNodeEdge[]; }; export declare function removeEdgesByNodeId(ids: number[], edges: StructureNodeEdge[]): StructureNodeEdge[];