Fix/export abstract visitor (#237)

* fix: #236 export AbstractParseTreeVisitor

* build: set isolatedModules true

* feat: import parser about from filters
This commit is contained in:
Hayden 2023-12-19 19:22:27 +08:00 committed by GitHub
parent 55a4832047
commit 8f72a5af60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
162 changed files with 327 additions and 277 deletions

View File

@ -1,23 +1,45 @@
export * from './parser';
export * from './lib/flinksql/FlinkSqlParserListener';
export * from './lib/flinksql/FlinkSqlParserVisitor';
export * from './lib/mysql/MySqlParserVisitor';
export * from './lib/mysql/MySqlParserListener';
export * from './lib/hive/HiveSqlParserListener';
export * from './lib/hive/HiveSqlParserVisitor';
export * from './lib/plsql/PlSqlParserListener';
export * from './lib/plsql/PlSqlParserVisitor';
export * from './lib/spark/SparkSqlParserVisitor';
export * from './lib/spark/SparkSqlParserListener';
export * from './lib/pgsql/PostgreSQLParserListener';
export * from './lib/pgsql/PostgreSQLParserVisitor';
export * from './lib/trinosql/TrinoSqlListener';
export * from './lib/trinosql/TrinoSqlVisitor';
export * from './lib/impala/ImpalaSqlParserListener';
export * from './lib/impala/ImpalaSqlParserVisitor';
export { AbstractParseTreeVisitor } from 'antlr4ts/tree/AbstractParseTreeVisitor';
export {
MySQL,
FlinkSQL,
SparkSQL,
HiveSQL,
PostgresSQL,
TrinoSQL,
ImpalaSQL,
PLSQL,
} from './parser';
export {
MySqlParserListener,
MySqlParserVisitor,
FlinkSqlParserListener,
FlinkSqlParserVisitor,
SparkSqlParserListener,
SparkSqlParserVisitor,
HiveSqlParserListener,
HiveSqlParserVisitor,
PlSqlParserListener,
PlSqlParserVisitor,
PostgreSQLParserListener,
PostgreSQLParserVisitor,
TrinoSqlListener,
TrinoSqlVisitor,
ImpalaSqlParserListener,
ImpalaSqlParserVisitor,
} from './lib';
export { SyntaxContextType } from './parser/common/basic-parser-types';
export type * from './parser/common/basic-parser-types';
export type {
CaretPosition,
WordRange,
Suggestions,
SyntaxSuggestion,
TextSlice,
} from './parser/common/basic-parser-types';
export type { SyntaxError, ParseError, ErrorListener } from './parser/common/parseErrorListener';
/**

23
src/lib/index.ts Normal file
View File

@ -0,0 +1,23 @@
export { FlinkSqlParserListener } from './flinksql/FlinkSqlParserListener';
export { FlinkSqlParserVisitor } from './flinksql/FlinkSqlParserVisitor';
export { MySqlParserListener } from './mysql/MySqlParserListener';
export { MySqlParserVisitor } from './mysql/MySqlParserVisitor';
export { HiveSqlParserListener } from './hive/HiveSqlParserListener';
export { HiveSqlParserVisitor } from './hive/HiveSqlParserVisitor';
export { PlSqlParserListener } from './plsql/PlSqlParserListener';
export { PlSqlParserVisitor } from './plsql/PlSqlParserVisitor';
export { SparkSqlParserListener } from './spark/SparkSqlParserListener';
export { SparkSqlParserVisitor } from './spark/SparkSqlParserVisitor';
export { PostgreSQLParserListener } from './pgsql/PostgreSQLParserListener';
export { PostgreSQLParserVisitor } from './pgsql/PostgreSQLParserVisitor';
export { TrinoSqlListener } from './trinosql/TrinoSqlListener';
export { TrinoSqlVisitor } from './trinosql/TrinoSqlVisitor';
export { ImpalaSqlParserListener } from './impala/ImpalaSqlParserListener';
export { ImpalaSqlParserVisitor } from './impala/ImpalaSqlParserVisitor';

View File

@ -1,6 +1,4 @@
import { CommonTokenStream } from 'antlr4ts';
import { ErrorListener, FlinkSQL } from '../../src';
import { FlinkSqlLexer } from '../../src/lib/flinksql/FlinkSqlLexer';
import { CommonTokenStream, ErrorListener, FlinkSQL, FlinkSqlLexer } from '../filters';
describe('BasicParser unit tests', () => {
const flinkParser = new FlinkSQL();

63
test/filters/index.ts Normal file
View File

@ -0,0 +1,63 @@
/**
* All unit tests should import parser about from this file.
* In this way, the exports of dt-sql-parser in the entry file is guaranteed to be complete.
*
* parser
* dt-sql-parser
*
* See this issue https://github.com/DTStack/dt-sql-parser/issues/236.
*/
export * from '../../src';
/**
* Something required by unit test but dt-sql-parser'entry not.
* If you need to add an export to this file,
* consider whether it should be exported in src/index as well.
*
* dt-sql-parser的入口不需要的导出
* dt-sql-parser
*/
export { CommonTokenStream } from 'antlr4ts';
export { ParseTreeWalker, ParseTreeListener } from 'antlr4ts/tree';
export { FlinkSqlLexer } from '../../src/lib/flinksql/FlinkSqlLexer';
export { FlinkSqlParser } from '../../src/lib/flinksql/FlinkSqlParser';
export * as FlinkSqlParserRuleContext from '../../src/lib/flinksql/FlinkSqlParser';
export { MySqlLexer } from '../../src/lib/mysql/MySqlLexer';
export { MySqlParser } from '../../src/lib/mysql/MySqlParser';
export * as MySqlParserRuleContext from '../../src/lib/mysql/MySqlParser';
export { HiveSqlLexer } from '../../src/lib/hive/HiveSqlLexer';
export { HiveSqlParser } from '../../src/lib/hive/HiveSqlParser';
export * as HiveSqlParserRuleContext from '../../src/lib/hive/HiveSqlParser';
export { PlSqlLexer } from '../../src/lib/plsql/PlSqlLexer';
export { PlSqlParser } from '../../src/lib/plsql/PlSqlParser';
export * as PlSqlParserRuleContext from '../../src/lib/plsql/PlSqlParser';
export { SparkSqlLexer } from '../../src/lib/spark/SparkSqlLexer';
export { SparkSqlParser } from '../../src/lib/spark/SparkSqlParser';
export * as SparkSQLParserRuleContext from '../../src/lib/spark/SparkSqlParser';
export { PostgreSQLLexer } from '../../src/lib/pgsql/PostgreSQLLexer';
export { PostgreSQLParser } from '../../src/lib/pgsql/PostgreSQLParser';
export * as PostgreSQLParserRuleContext from '../../src/lib/pgsql/PostgreSQLParser';
export { TrinoSqlLexer } from '../../src/lib/trinosql/TrinoSqlLexer';
export { TrinoSqlParser } from '../../src/lib/trinosql/TrinoSqlParser';
export * as TrinoSqlParserRuleContext from '../../src/lib/trinosql/TrinoSqlParser';
export { ImpalaSqlLexer } from '../../src/lib/impala/ImpalaSqlLexer';
export { ImpalaSqlParser } from '../../src/lib/impala/ImpalaSqlParser';
export * as ImpalaSqlParserRuleContext from '../../src/lib/impala/ImpalaSqlParser';
export { FlinkSqlSplitListener } from '../../src/parser/flinksql';
export { MysqlSplitListener } from '../../src/parser/mysql';
export { HiveSqlSplitListener } from '../../src/parser/hive';
export { SparkSqlSplitListener } from '../../src/parser/spark';
export { PgSqlSplitListener } from '../../src/parser/pgsql';
export { TrinoSqlSplitListener } from '../../src/parser/trinosql';
export { ImpalaSqlSplitListener } from '../../src/parser/impala';

View File

@ -1,7 +1,4 @@
import path from 'path';
import { writeFileSync } from 'node:fs';
import FlinkSQL from '../../../../src/parser/flinksql';
import { FlinkSQL } from '../../../filters';
import {
readSQL,
benchmark,

View File

@ -1,6 +1,4 @@
import FlinkSQL from '../../../src/parser/flinksql';
import { FlinkSqlSplitListener } from '../../../src/parser/flinksql';
import { FlinkSqlParserListener } from '../../../src/lib/flinksql/FlinkSqlParserListener';
import { FlinkSQL, FlinkSqlSplitListener, FlinkSqlParserListener } from '../../filters';
const validSQL1 = `INSERT INTO country_page_view
VALUES ('Chinese', 'mumiao', 18),

View File

@ -1,4 +1,4 @@
import FlinkSQL from '../../../src/parser/flinksql';
import { FlinkSQL } from '../../filters';
describe('FlinkSQL Lexer tests', () => {
const parser = new FlinkSQL();

View File

@ -1,7 +1,9 @@
import FlinkSQL from '../../../src/parser/flinksql';
import { FlinkSqlParserListener } from '../../../src/lib/flinksql/FlinkSqlParserListener';
import { TableExpressionContext } from '../../../src/lib/flinksql/FlinkSqlParser';
import { ParseTreeListener } from 'antlr4ts/tree';
import {
FlinkSQL,
FlinkSqlParserListener,
FlinkSqlParserRuleContext,
ParseTreeListener,
} from '../../filters';
describe('Flink SQL Listener Tests', () => {
const expectTableName = 'user1';
@ -13,7 +15,9 @@ describe('Flink SQL Listener Tests', () => {
test('Listener enterTableName', async () => {
let result = '';
class MyListener implements FlinkSqlParserListener {
enterTableExpression = (ctx: TableExpressionContext): void => {
enterTableExpression = (
ctx: FlinkSqlParserRuleContext.TableExpressionContext
): void => {
result = ctx.text.toLowerCase();
};
}

View File

@ -1,7 +1,6 @@
import fs from 'fs';
import path from 'path';
import { CaretPosition, SyntaxContextType } from '../../../../src/parser/common/basic-parser-types';
import FlinkSQL from '../../../../src/parser/flinksql';
import { CaretPosition, SyntaxContextType, FlinkSQL } from '../../../filters';
const syntaxSql = fs.readFileSync(
path.join(__dirname, 'fixtures', 'multipleStatement.sql'),

View File

@ -1,7 +1,6 @@
import fs from 'fs';
import path from 'path';
import { CaretPosition, SyntaxContextType } from '../../../../src/parser/common/basic-parser-types';
import FlinkSQL from '../../../../src/parser/flinksql';
import { CaretPosition, SyntaxContextType, FlinkSQL } from '../../../filters';
import { commentOtherLine } from '../../../helper';
const syntaxSql = fs.readFileSync(

View File

@ -1,7 +1,6 @@
import fs from 'fs';
import path from 'path';
import { CaretPosition } from '../../../../src/parser/common/basic-parser-types';
import FlinkSQL from '../../../../src/parser/flinksql';
import { FlinkSQL, CaretPosition } from '../../../filters';
import { commentOtherLine } from '../../../helper';
const tokenSql = fs.readFileSync(path.join(__dirname, 'fixtures', 'tokenSuggestion.sql'), 'utf-8');

View File

@ -1,4 +1,4 @@
import FlinkSQL from '../../../../src/parser/flinksql';
import { FlinkSQL } from '../../../filters';
import { readSQL } from '../../../helper';
const features = {

View File

@ -1,4 +1,4 @@
import FlinkSQL from '../../../../src/parser/flinksql';
import { FlinkSQL } from '../../../filters';
import { readSQL } from '../../../helper';
// 综合测试的 sql 不做切割

View File

@ -1,6 +1,6 @@
import fs from 'fs';
import path from 'path';
import FlinkSQL from '../../../../src/parser/flinksql';
import { FlinkSQL } from '../../../filters';
// 注释 sql 不做切割
const features = {

View File

@ -1,6 +1,6 @@
import fs from 'fs';
import path from 'path';
import FlinkSQL from '../../../../src/parser/flinksql';
import { FlinkSQL } from '../../../filters';
// 综合测试的 sql 不做切割
const features = {

View File

@ -1,4 +1,4 @@
import FlinkSQL from '../../../../src/parser/flinksql';
import { FlinkSQL } from '../../../filters';
import { readSQL } from '../../../helper';
const parser = new FlinkSQL();

View File

@ -1,4 +1,4 @@
import FlinkSQL from '../../../../src/parser/flinksql';
import { FlinkSQL } from '../../../filters';
import { readSQL } from '../../../helper';
const features = {

View File

@ -1,4 +1,4 @@
import FlinkSQL from '../../../../src/parser/flinksql';
import { FlinkSQL } from '../../../filters';
import { readSQL } from '../../../helper';
const features = {

View File

@ -1,4 +1,4 @@
import FlinkSQL from '../../../../src/parser/flinksql';
import { FlinkSQL } from '../../../filters';
import { readSQL } from '../../../helper';
const features = {

View File

@ -1,4 +1,4 @@
import FlinkSQL from '../../../../src/parser/flinksql';
import { FlinkSQL } from '../../../filters';
import { readSQL } from '../../../helper';
const features = {

View File

@ -1,4 +1,4 @@
import FlinkSQL from '../../../../src/parser/flinksql';
import { FlinkSQL } from '../../../filters';
import { readSQL } from '../../../helper';
const features = {

View File

@ -1,4 +1,4 @@
import FlinkSQL from '../../../../src/parser/flinksql';
import { FlinkSQL } from '../../../filters';
import { readSQL } from '../../../helper';
const parser = new FlinkSQL();

View File

@ -1,4 +1,4 @@
import FlinkSQL from '../../../../src/parser/flinksql';
import { FlinkSQL } from '../../../filters';
import { readSQL } from '../../../helper';
const parser = new FlinkSQL();

View File

@ -1,4 +1,4 @@
import FlinkSQL from '../../../../src/parser/flinksql';
import { FlinkSQL } from '../../../filters';
import { readSQL } from '../../../helper';
const features = {

View File

@ -1,4 +1,4 @@
import FlinkSQL from '../../../../src/parser/flinksql';
import { FlinkSQL } from '../../../filters';
import { readSQL } from '../../../helper';
const features = {

View File

@ -1,6 +1,4 @@
import FlinkSQL from '../../../src/parser/flinksql';
import { FlinkSqlParserVisitor } from '../../../src/lib/flinksql/FlinkSqlParserVisitor';
import { AbstractParseTreeVisitor } from 'antlr4ts/tree';
import { FlinkSQL, AbstractParseTreeVisitor, FlinkSqlParserVisitor } from '../../filters';
describe('Flink SQL Visitor Tests', () => {
const expectTableName = 'user1';

View File

@ -1,6 +1,4 @@
import HiveSQL from '../../../src/parser/hive';
import { HiveSqlSplitListener } from '../../../src/parser/hive';
import { HiveSqlParserListener } from '../../../src/lib/hive/HiveSqlParserListener';
import { HiveSQL, HiveSqlSplitListener, HiveSqlParserListener } from '../../filters';
const validSQL1 = `INSERT INTO country_page_view
VALUES ('Chinese', 'mumiao', 18),

View File

@ -1,4 +1,4 @@
import HiveSQL from '../../../src/parser/hive';
import { HiveSQL } from '../../filters';
describe('HiveSQL Lexer tests', () => {
const parser = new HiveSQL();

View File

@ -1,7 +1,5 @@
import { ParseTreeListener } from 'antlr4ts/tree';
import { ProgramContext } from '../../../src/lib/hive/HiveSqlParser';
import { HiveSqlParserListener } from '../../../src/lib/hive/HiveSqlParserListener';
import HiveSQL from '../../../src/parser/hive';
import { HiveSQL, HiveSqlParserListener, HiveSqlParserRuleContext } from '../../filters';
describe('HiveSQL Listener Tests', () => {
const parser = new HiveSQL();
@ -18,7 +16,10 @@ describe('HiveSQL Listener Tests', () => {
}
const listenTableName = new MyListener();
await parser.listen(listenTableName as ParseTreeListener, parseTree as ProgramContext);
await parser.listen(
listenTableName as ParseTreeListener,
parseTree as HiveSqlParserRuleContext.ProgramContext
);
expect(result).toBe(expectTableName.toUpperCase());
});
test('Listener enterCreateTable', async () => {
@ -32,7 +33,10 @@ describe('HiveSQL Listener Tests', () => {
}
const listenTableName = new MyListener();
await parser.listen(listenTableName as ParseTreeListener, parseTree as ProgramContext);
await parser.listen(
listenTableName as ParseTreeListener,
parseTree as HiveSqlParserRuleContext.ProgramContext
);
expect(result).toBe('DROPTABLETABLE_NAME');
});

View File

@ -1,7 +1,6 @@
import fs from 'fs';
import path from 'path';
import { CaretPosition, SyntaxContextType } from '../../../../src/parser/common/basic-parser-types';
import HiveSQL from '../../../../src/parser/hive';
import { CaretPosition, SyntaxContextType, HiveSQL } from '../../../filters';
const syntaxSql = fs.readFileSync(
path.join(__dirname, 'fixtures', 'multipleStatement.sql'),

View File

@ -1,7 +1,6 @@
import fs from 'fs';
import path from 'path';
import { CaretPosition, SyntaxContextType } from '../../../../src/parser/common/basic-parser-types';
import HiveSQL from '../../../../src/parser/hive';
import { CaretPosition, SyntaxContextType, HiveSQL } from '../../../filters';
import { commentOtherLine } from '../../../helper';
const syntaxSql = fs.readFileSync(

View File

@ -1,7 +1,6 @@
import fs from 'fs';
import path from 'path';
import { CaretPosition } from '../../../../src/parser/common/basic-parser-types';
import HiveSQL from '../../../../src/parser/hive';
import { CaretPosition, HiveSQL } from '../../../filters';
import { commentOtherLine } from '../../../helper';
const tokenSql = fs.readFileSync(path.join(__dirname, 'fixtures', 'tokenSuggestion.sql'), 'utf-8');

View File

@ -1,4 +1,4 @@
import HiveSQL from '../../../../src/parser/hive';
import { HiveSQL } from '../../../filters';
import { readSQL } from '../../../helper';
const parser = new HiveSQL();

View File

@ -1,4 +1,4 @@
import HiveSQL from '../../../../src/parser/hive';
import { HiveSQL } from '../../../filters';
import { readSQL } from '../../../helper';
const parser = new HiveSQL();

View File

@ -1,4 +1,4 @@
import HiveSQL from '../../../../src/parser/hive';
import { HiveSQL } from '../../../filters';
import { readSQL } from '../../../helper';
const parser = new HiveSQL();

View File

@ -1,4 +1,4 @@
import HiveSQL from '../../../../src/parser/hive';
import { HiveSQL } from '../../../filters';
import { readSQL } from '../../../helper';
const parser = new HiveSQL();

View File

@ -1,4 +1,4 @@
import HiveSQL from '../../../../src/parser/hive';
import { HiveSQL } from '../../../filters';
import { readSQL } from '../../../helper';
const parser = new HiveSQL();

View File

@ -1,4 +1,4 @@
import HiveSQL from '../../../../src/parser/hive';
import { HiveSQL } from '../../../filters';
import { readSQL } from '../../../helper';
const parser = new HiveSQL();

View File

@ -1,4 +1,4 @@
import HiveSQL from '../../../../src/parser/hive';
import { HiveSQL } from '../../../filters';
import { readSQL } from '../../../helper';
const parser = new HiveSQL();

View File

@ -1,4 +1,4 @@
import HiveSQL from '../../../../src/parser/hive';
import { HiveSQL } from '../../../filters';
import { readSQL } from '../../../helper';
const parser = new HiveSQL();

View File

@ -1,4 +1,4 @@
import HiveSQL from '../../../../src/parser/hive';
import { HiveSQL } from '../../../filters';
import { readSQL } from '../../../helper';
const features = {

View File

@ -1,4 +1,4 @@
import HiveSQL from '../../../../src/parser/hive';
import { HiveSQL } from '../../../filters';
import { readSQL } from '../../../helper';
const features = {

View File

@ -1,4 +1,4 @@
import HiveSQL from '../../../../src/parser/hive';
import { HiveSQL } from '../../../filters';
import { readSQL } from '../../../helper';
const parser = new HiveSQL();

View File

@ -1,4 +1,4 @@
import HiveSQL from '../../../../src/parser/hive';
import { HiveSQL } from '../../../filters';
import { readSQL } from '../../../helper';
const parser = new HiveSQL();

View File

@ -1,4 +1,4 @@
import HiveSQL from '../../../../src/parser/hive';
import { HiveSQL } from '../../../filters';
import { readSQL } from '../../../helper';
const parser = new HiveSQL();

View File

@ -1,4 +1,4 @@
import HiveSQL from '../../../../src/parser/hive';
import { HiveSQL } from '../../../filters';
import { readSQL } from '../../../helper';
const parser = new HiveSQL();

View File

@ -1,4 +1,4 @@
import HiveSQL from '../../../../src/parser/hive';
import { HiveSQL } from '../../../filters';
import { readSQL } from '../../../helper';
const parser = new HiveSQL();

View File

@ -1,4 +1,4 @@
import HiveSQL from '../../../../src/parser/hive';
import { HiveSQL } from '../../../filters';
import { readSQL } from '../../../helper';
const parser = new HiveSQL();

View File

@ -1,7 +1,9 @@
import { AbstractParseTreeVisitor } from 'antlr4ts/tree/AbstractParseTreeVisitor';
import { HiveSqlParserVisitor } from '../../../src/lib/hive/HiveSqlParserVisitor';
import HiveSQL from '../../../src/parser/hive';
import { ProgramContext } from '../../../src/lib/hive/HiveSqlParser';
import {
HiveSQL,
HiveSqlParserVisitor,
AbstractParseTreeVisitor,
HiveSqlParserRuleContext,
} from '../../filters';
describe('HiveSQL Visitor Tests', () => {
const expectTableName = 'dm_gis.dlv_addr_tc_count';
@ -25,7 +27,7 @@ describe('HiveSQL Visitor Tests', () => {
}
const visitor = new MyVisitor();
visitor.visit(parseTree as ProgramContext);
visitor.visit(parseTree as HiveSqlParserRuleContext.ProgramContext);
expect(result).toBe(expectTableName);
});

View File

@ -1,6 +1,4 @@
import ImpalaSQL from '../../../src/parser/impala';
import { ImpalaSqlSplitListener } from '../../../src/parser/impala';
import { ImpalaSqlParserListener } from '../../../src/lib/impala/ImpalaSqlParserListener';
import { ImpalaSQL, ImpalaSqlSplitListener, ImpalaSqlParserListener } from '../../filters';
const validSQL1 = `INSERT INTO country_page_view
VALUES ('Chinese', 'mumiao', 18),

View File

@ -1,4 +1,4 @@
import ImpalaSQL from '../../../src/parser/impala';
import { ImpalaSQL } from '../../filters';
describe('ImpalaSQL Lexer tests', () => {
const parser = new ImpalaSQL();

View File

@ -1,11 +1,9 @@
import impalaSQL from '../../../src/parser/impala';
import { ImpalaSqlParserListener } from '../../../src/lib/impala/ImpalaSqlParserListener';
import { ParseTreeListener } from 'antlr4ts/tree';
import { ImpalaSQL, ImpalaSqlParserListener, ParseTreeListener } from '../../filters';
describe('impala SQL Listener Tests', () => {
const expectTableName = 'user1';
const sql = `select id,name,sex from ${expectTableName};`;
const parser = new impalaSQL();
const parser = new ImpalaSQL();
const parseTree = parser.parse(sql);

View File

@ -1,7 +1,6 @@
import fs from 'fs';
import path from 'path';
import { CaretPosition, SyntaxContextType } from '../../../../src/parser/common/basic-parser-types';
import ImpalaSQL from '../../../../src/parser/impala';
import { ImpalaSQL, CaretPosition, SyntaxContextType } from '../../../filters';
const syntaxSql = fs.readFileSync(
path.join(__dirname, 'fixtures', 'multipleStatement.sql'),

View File

@ -1,7 +1,6 @@
import fs from 'fs';
import path from 'path';
import { CaretPosition, SyntaxContextType } from '../../../../src/parser/common/basic-parser-types';
import ImpalaSQL from '../../../../src/parser/impala';
import { ImpalaSQL, CaretPosition, SyntaxContextType } from '../../../filters';
import { commentOtherLine } from '../../../helper';
const syntaxSql = fs.readFileSync(

View File

@ -1,13 +1,12 @@
import fs from 'fs';
import path from 'path';
import { CaretPosition } from '../../../../src/parser/common/basic-parser-types';
import impalaSQL from '../../../../src/parser/impala';
import { ImpalaSQL, CaretPosition } from '../../../filters';
import { commentOtherLine } from '../../../helper';
const tokenSql = fs.readFileSync(path.join(__dirname, 'fixtures', 'tokenSuggestion.sql'), 'utf-8');
describe('Impala SQL Token Suggestion', () => {
const parser = new impalaSQL();
const parser = new ImpalaSQL();
test('After ALTER', () => {
const pos: CaretPosition = {

View File

@ -1,4 +1,4 @@
import ImpalaSQL from '../../../../src/parser/impala';
import { ImpalaSQL } from '../../../filters';
import { readSQL } from '../../../helper';
const parser = new ImpalaSQL();

View File

@ -1,4 +1,4 @@
import ImpalaSQL from '../../../../src/parser/impala';
import { ImpalaSQL } from '../../../filters';
import { readSQL } from '../../../helper';
const parser = new ImpalaSQL();

View File

@ -1,4 +1,4 @@
import ImpalaSQL from '../../../../src/parser/impala';
import { ImpalaSQL } from '../../../filters';
import { readSQL } from '../../../helper';
const parser = new ImpalaSQL();

View File

@ -1,4 +1,4 @@
import ImpalaSQL from '../../../../src/parser/impala';
import { ImpalaSQL } from '../../../filters';
import { readSQL } from '../../../helper';
const parser = new ImpalaSQL();

View File

@ -1,4 +1,4 @@
import ImpalaSQL from '../../../../src/parser/impala';
import { ImpalaSQL } from '../../../filters';
import { readSQL } from '../../../helper';
const parser = new ImpalaSQL();

View File

@ -1,4 +1,4 @@
import ImpalaSQL from '../../../../src/parser/impala';
import { ImpalaSQL } from '../../../filters';
import { readSQL } from '../../../helper';
const parser = new ImpalaSQL();

View File

@ -1,4 +1,4 @@
import ImpalaSQL from '../../../../src/parser/impala';
import { ImpalaSQL } from '../../../filters';
import { readSQL } from '../../../helper';
const parser = new ImpalaSQL();

View File

@ -1,4 +1,4 @@
import ImpalaSQL from '../../../../src/parser/impala';
import { ImpalaSQL } from '../../../filters';
import { readSQL } from '../../../helper';
const parser = new ImpalaSQL();

View File

@ -1,4 +1,4 @@
import ImpalaSQL from '../../../../src/parser/impala';
import { ImpalaSQL } from '../../../filters';
import { readSQL } from '../../../helper';
const parser = new ImpalaSQL();

View File

@ -1,4 +1,4 @@
import ImpalaSQL from '../../../../src/parser/impala';
import { ImpalaSQL } from '../../../filters';
import { readSQL } from '../../../helper';
const parser = new ImpalaSQL();

View File

@ -1,4 +1,4 @@
import ImpalaSQL from '../../../../src/parser/impala';
import { ImpalaSQL } from '../../../filters';
import { readSQL } from '../../../helper';
const parser = new ImpalaSQL();

View File

@ -1,11 +1,9 @@
import impalaSQL from '../../../src/parser/impala';
import { ImpalaSqlParserVisitor } from '../../../src/lib/impala/ImpalaSqlParserVisitor';
import { AbstractParseTreeVisitor } from 'antlr4ts/tree';
import { ImpalaSQL, ImpalaSqlParserVisitor, AbstractParseTreeVisitor } from '../../filters';
describe('impala SQL Visitor Tests', () => {
const expectTableName = 'user1';
const sql = `select id,name,sex from ${expectTableName};`;
const parser = new impalaSQL();
const parser = new ImpalaSQL();
const parseTree = parser.parse(sql, (error) => {
console.log('Parse error:', error);

View File

@ -1,6 +1,5 @@
import MySQL from '../../../src/parser/mysql';
import { MysqlSplitListener } from '../../../src/parser/mysql';
import { MySqlParserListener } from '../../../src/lib/mysql/MySqlParserListener';
import { MySQL } from '../../filters';
import { MysqlSplitListener, MySqlParserListener } from '../../filters';
const validSQL1 = `INSERT INTO country_page_view
VALUES ('Chinese', 'mumiao', 18),

View File

@ -1,4 +1,4 @@
import MySQL from '../../../src/parser/mysql';
import { MySQL } from '../../filters';
describe('MySQL Lexer tests', () => {
const parser = new MySQL();

View File

@ -1,6 +1,5 @@
import MySQL from '../../../src/parser/mysql';
import { MySqlParserListener } from '../../../src/lib/mysql/MySqlParserListener';
import { ParseTreeListener } from 'antlr4ts/tree';
import { MySQL } from '../../filters';
import { MySqlParserListener, ParseTreeListener } from '../../filters';
describe('MySQL Listener Tests', () => {
const expectTableName = 'user1';

View File

@ -1,7 +1,6 @@
import fs from 'fs';
import path from 'path';
import { CaretPosition, SyntaxContextType } from '../../../../src/parser/common/basic-parser-types';
import MySQL from '../../../../src/parser/mysql';
import { MySQL, CaretPosition, SyntaxContextType } from '../../../filters';
const syntaxSql = fs.readFileSync(
path.join(__dirname, 'fixtures', 'multipleStatement.sql'),

View File

@ -1,7 +1,6 @@
import fs from 'fs';
import path from 'path';
import { CaretPosition, SyntaxContextType } from '../../../../src/parser/common/basic-parser-types';
import MySQL from '../../../../src/parser/mysql';
import { MySQL, CaretPosition, SyntaxContextType } from '../../../filters';
import { commentOtherLine } from '../../../helper';
const syntaxSql = fs.readFileSync(

View File

@ -1,7 +1,6 @@
import fs from 'fs';
import path from 'path';
import { CaretPosition } from '../../../../src/parser/common/basic-parser-types';
import MySQL from '../../../../src/parser/mysql';
import { MySQL, CaretPosition } from '../../../filters';
import { commentOtherLine } from '../../../helper';
const tokenSql = fs.readFileSync(path.join(__dirname, 'fixtures', 'tokenSuggestion.sql'), 'utf-8');

View File

@ -1,4 +1,4 @@
import MySQL from '../../../src/parser/mysql';
import { MySQL } from '../../filters';
describe('MySQL Syntax Tests', () => {
const parser = new MySQL();

View File

@ -1,4 +1,4 @@
import MySQL from '../../../../src/parser/mysql';
import { MySQL } from '../../../filters';
import { readSQL } from '../../../helper';
const parser = new MySQL();

View File

@ -1,4 +1,4 @@
import MySQL from '../../../../src/parser/mysql';
import { MySQL } from '../../../filters';
import { readSQL } from '../../../helper';
const parser = new MySQL();

View File

@ -1,4 +1,4 @@
import MySQL from '../../../../src/parser/mysql';
import { MySQL } from '../../../filters';
import { readSQL } from '../../../helper';
const parser = new MySQL();

View File

@ -1,4 +1,4 @@
import MySQL from '../../../../src/parser/mysql';
import { MySQL } from '../../../filters';
import { readSQL } from '../../../helper';
const parser = new MySQL();

View File

@ -1,6 +1,4 @@
import MySQL from '../../../src/parser/mysql';
import { MySqlParserVisitor } from '../../../src/lib/mysql/MySqlParserVisitor';
import { AbstractParseTreeVisitor } from 'antlr4ts/tree';
import { MySQL, MySqlParserVisitor, AbstractParseTreeVisitor } from '../../filters';
describe('MySQL Visitor Tests', () => {
const expectTableName = 'user1';

View File

@ -1,6 +1,4 @@
import PgSQL from '../../../src/parser/pgsql';
import { PgSqlSplitListener } from '../../../src/parser/pgsql';
import { PostgreSQLParserListener } from '../../../src/lib/pgsql/PostgreSQLParserListener';
import { PostgresSQL, PgSqlSplitListener, PostgreSQLParserListener } from '../../filters';
const validSQL1 = `INSERT INTO country_page_view
VALUES ('Chinese', 'mumiao', 18),
@ -9,7 +7,7 @@ const validSQL2 = 'SELECT * FROM tb;';
const inValidSQL = 'CREATE TABLE';
describe('PgSQL ErrorStrategy test', () => {
const pgSQL = new PgSQL();
const pgSQL = new PostgresSQL();
// TODO: handle unexpected case
// test('begin inValid', () => {

View File

@ -1,4 +1,4 @@
import PostgresSQL from '../../../src/parser/pgsql';
import { PostgresSQL } from '../../filters';
describe('PostgresSQL Lexer tests', () => {
const mysqlParser = new PostgresSQL();

View File

@ -1,6 +1,4 @@
import { ParseTreeListener } from 'antlr4ts/tree';
import { PostgreSQLParserListener } from '../../../src/lib/pgsql/PostgreSQLParserListener';
import PostgresSQL from '../../../src/parser/pgsql';
import { PostgresSQL, PostgreSQLParserListener, ParseTreeListener } from '../../filters';
describe('PostgresSQL Listener Tests', () => {
const expectTableName = 'user1';

View File

@ -1,7 +1,6 @@
import fs from 'fs';
import path from 'path';
import { CaretPosition, SyntaxContextType } from '../../../../src/parser/common/basic-parser-types';
import PgSQL from '../../../../src/parser/pgsql';
import { CaretPosition, SyntaxContextType, PostgresSQL } from '../../../filters';
const syntaxSql = fs.readFileSync(
path.join(__dirname, 'fixtures', 'multipleStatement.sql'),
@ -9,7 +8,7 @@ const syntaxSql = fs.readFileSync(
);
describe('PgSQL Multiple Statements Syntax Suggestion', () => {
const parser = new PgSQL();
const parser = new PostgresSQL();
test('Create table ', () => {
const pos: CaretPosition = {

View File

@ -1,7 +1,6 @@
import fs from 'fs';
import path from 'path';
import { CaretPosition, SyntaxContextType } from '../../../../src/parser/common/basic-parser-types';
import PgSQL from '../../../../src/parser/pgsql';
import { PostgresSQL, CaretPosition, SyntaxContextType } from '../../../filters';
import { commentOtherLine } from '../../../helper';
const syntaxSql = fs.readFileSync(
@ -10,7 +9,7 @@ const syntaxSql = fs.readFileSync(
);
describe('Postgre SQL Syntax Suggestion', () => {
const parser = new PgSQL();
const parser = new PostgresSQL();
test('Validate Syntax SQL', () => {
expect(parser.validate(syntaxSql).length).not.toBe(0);

View File

@ -1,7 +1,6 @@
import fs from 'fs';
import path from 'path';
import { CaretPosition } from '../../../../src/parser/common/basic-parser-types';
import PostgresSQL from '../../../../src/parser/pgsql';
import { PostgresSQL, CaretPosition } from '../../../filters';
import { commentOtherLine } from '../../../helper';
const tokenSql = fs.readFileSync(path.join(__dirname, 'fixtures', 'tokenSuggestion.sql'), 'utf-8');

View File

@ -1,7 +1,7 @@
import PgSQL from '../../../../src/parser/pgsql';
import { PostgresSQL } from '../../../filters';
import { readSQL } from '../../../helper';
const parser = new PgSQL();
const parser = new PostgresSQL();
const features = {
alters: readSQL(__dirname, 'alter.sql'),

View File

@ -1,7 +1,7 @@
import PgSQL from '../../../../src/parser/pgsql';
import { PostgresSQL } from '../../../filters';
import { readSQL } from '../../../helper';
const parser = new PgSQL();
const parser = new PostgresSQL();
const features = {
creates: readSQL(__dirname, 'create.sql'),

View File

@ -1,7 +1,7 @@
import PgSQL from '../../../../src/parser/pgsql';
import { PostgresSQL } from '../../../filters';
import { readSQL } from '../../../helper';
const parser = new PgSQL();
const parser = new PostgresSQL();
const features = {
deletes: readSQL(__dirname, 'delete.sql'),

View File

@ -1,7 +1,7 @@
import PgSQL from '../../../../src/parser/pgsql';
import { PostgresSQL } from '../../../filters';
import { readSQL } from '../../../helper';
const parser = new PgSQL();
const parser = new PostgresSQL();
const features = {
drops: readSQL(__dirname, 'drop.sql'),

View File

@ -1,7 +1,7 @@
import PgSQL from '../../../../src/parser/pgsql';
import { PostgresSQL } from '../../../filters';
import { readSQL } from '../../../helper';
const parser = new PgSQL();
const parser = new PostgresSQL();
const features = {
inserts: readSQL(__dirname, 'insert.sql'),

View File

@ -1,7 +1,7 @@
import PgSQL from '../../../../src/parser/pgsql';
import { PostgresSQL } from '../../../filters';
import { readSQL } from '../../../helper';
const parser = new PgSQL();
const parser = new PostgresSQL();
const features = {
others: readSQL(__dirname, 'others.sql'),

View File

@ -1,7 +1,7 @@
import PgSQL from '../../../../src/parser/pgsql';
import { PostgresSQL } from '../../../filters';
import { readSQL } from '../../../helper';
const parser = new PgSQL();
const parser = new PostgresSQL();
const features = {
selects: readSQL(__dirname, 'select.sql'),

View File

@ -1,7 +1,7 @@
import PgSQL from '../../../../src/parser/pgsql';
import { PostgresSQL } from '../../../filters';
import { readSQL } from '../../../helper';
const parser = new PgSQL();
const parser = new PostgresSQL();
const features = {
updates: readSQL(__dirname, 'update.sql'),

View File

@ -1,6 +1,4 @@
import { AbstractParseTreeVisitor } from 'antlr4ts/tree/AbstractParseTreeVisitor';
import { PostgreSQLParserVisitor } from '../../../src/lib/pgsql/PostgreSQLParserVisitor';
import PostgresSQL from '../../../src/parser/pgsql';
import { PostgresSQL, AbstractParseTreeVisitor, PostgreSQLParserVisitor } from '../../filters';
describe('MySQL Visitor Tests', () => {
const expectTableName = 'user1';

View File

@ -1,4 +1,4 @@
import PLSQL from '../../../src/parser/plsql';
import { PLSQL } from '../../filters';
describe('PLSQL Lexer tests', () => {
const parser = new PLSQL();

View File

@ -1,6 +1,4 @@
import { ParseTreeListener } from 'antlr4ts/tree';
import { PlSqlParserListener } from '../../../src/lib/plsql/PlSqlParserListener';
import PLSQL from '../../../src/parser/plsql';
import { PLSQL, PlSqlParserListener, ParseTreeListener } from '../../filters';
describe('PLSQL Listener Tests', () => {
const expectTableName = 'user1';

View File

@ -1,7 +1,7 @@
import PLSQLParser from '../../../src/parser/plsql';
import { PLSQL } from '../../filters';
describe('PLSQL Syntax Tests', () => {
const parser = new PLSQLParser();
const parser = new PLSQL();
test('Test simple select Statement', () => {
const sql = 'select id,name from user1;';

View File

@ -1,6 +1,4 @@
import { AbstractParseTreeVisitor } from 'antlr4ts/tree/AbstractParseTreeVisitor';
import { PlSqlParserVisitor } from '../../../src/lib/plsql/PlSqlParserVisitor';
import PLSQL from '../../../src/parser/plsql';
import { PLSQL, AbstractParseTreeVisitor, PlSqlParserVisitor } from '../../filters';
describe('PLSQL Visitor Tests', () => {
const expectTableName = 'user1';

View File

@ -1,6 +1,4 @@
import SparkSQL from '../../../src/parser/spark';
import { SparkSqlSplitListener } from '../../../src/parser/spark';
import { SparkSqlParserListener } from '../../../src/lib/spark/SparkSqlParserListener';
import { SparkSQL, SparkSqlSplitListener, SparkSqlParserListener } from '../../filters';
const validSQL1 = `INSERT INTO country_page_view
VALUES ('Chinese', 'mumiao', 18),

View File

@ -1,4 +1,4 @@
import SparkSQL from '../../../src/parser/spark';
import { SparkSQL } from '../../filters';
describe('SparkSQL Lexer tests', () => {
const parser = new SparkSQL();

Some files were not shown because too many files have changed in this diff Show More