lava-oushudb-dt-sql-parser/src/parser/pgsql.ts
Hayden 1b02ff5d75
feat: FlinkSQL supports auto complete (#115)
* feat: add antlr4-c3 dependencies

* feat: distinguish table, catalog and database from uid

* feat: move semicolon from sqlStatements to sqlStatement

* chore: move antlr4ts-cli to devDependencies

* feat: improve basic parser and support suggestions of token and syntax

* feat: implement suggest method in sql parsers

* test: flink sql suggestion test cases

* feat: optimize ts defination of suggestion

* feat: add split listener and optimize performance of auto-completion

* test: supplementary flink suggestion unit tests
2023-06-09 11:22:53 +08:00

35 lines
1.0 KiB
TypeScript

import { Token } from 'antlr4ts';
import { CandidatesCollection } from 'antlr4-c3';
import { PostgreSQLLexer } from '../lib/pgsql/PostgreSQLLexer';
import { PostgreSQLParser, ProgramContext } from '../lib/pgsql/PostgreSQLParser';
import BasicParser from './common/basicParser';
import { Suggestions } from './common/basic-parser-types';
export default class PostgresSQL extends BasicParser<PostgreSQLLexer, ProgramContext, PostgreSQLParser> {
public createLexerFormCharStream(charStreams) {
const lexer = new PostgreSQLLexer(charStreams);
return lexer;
}
public createParserFromTokenStream(tokenStream) {
return new PostgreSQLParser(tokenStream);
}
public preferredRules: Set<number> = new Set();
protected get splitListener () {
return null as any;
}
public processCandidates(
candidates: CandidatesCollection,
allTokens: Token[],
caretTokenIndex: number
): Suggestions<Token> {
return {
syntax: [],
keywords: []
}
}
}