change to ts
This commit is contained in:
31
src/lib/filter.ts
Normal file
31
src/lib/filter.ts
Normal file
@ -0,0 +1,31 @@
|
||||
import * as commentFilter from '../core/comment';
|
||||
|
||||
/**
|
||||
* 过滤--注释
|
||||
* @param {String} sql
|
||||
*/
|
||||
function filterComments(sql) {
|
||||
return commentFilter.parse(sql).text;
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除注释和前后空格
|
||||
* @param {String} sql
|
||||
*/
|
||||
function cleanSql(sql) {
|
||||
return filterComments(sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分割sql
|
||||
* @param {String} sql
|
||||
*/
|
||||
function splitSql(sql) {
|
||||
return commentFilter.parse(sql).lines
|
||||
}
|
||||
|
||||
export {
|
||||
filterComments,
|
||||
cleanSql,
|
||||
splitSql
|
||||
}
|
44
src/lib/parser.ts
Normal file
44
src/lib/parser.ts
Normal file
@ -0,0 +1,44 @@
|
||||
// import * as sqlSyntaxParser from '../core/sqlSyntaxParser';
|
||||
import * as sqlSyntaxParser from '../core/sqlSyntaxParser';
|
||||
import * as sqlAutoCompleteParser from '../core/sqlAutoCompleteParser';
|
||||
/**
|
||||
* 自动补全提示
|
||||
* @param {(string | Array<string>)} sql
|
||||
* @param {string} [type="hive"]
|
||||
*/
|
||||
function parseSyntax(sql, type) {
|
||||
if (typeof type == "undefined") {
|
||||
type = "hive"
|
||||
}
|
||||
let sql1=sql;
|
||||
let sql2='';
|
||||
if(sql instanceof Array){
|
||||
sql1=sql[0];
|
||||
sql2=sql[1];
|
||||
}
|
||||
// @ts-nocheck
|
||||
return sqlSyntaxParser.parser.parseSyntax(sql1, sql2, type, false)
|
||||
}
|
||||
|
||||
/**
|
||||
* 自动补全提示
|
||||
* @param {(string | Array<string>)} sql
|
||||
* @param {string} [type="hive"]
|
||||
*/
|
||||
function parserSql(sql, type) {
|
||||
if (typeof type == "undefined") {
|
||||
type = "hive"
|
||||
}
|
||||
let sql1=sql;
|
||||
let sql2='';
|
||||
if(sql instanceof Array){
|
||||
sql1=sql[0];
|
||||
sql2=sql[1];
|
||||
}
|
||||
return sqlAutoCompleteParser.parser.parseSql(sql1, sql2, type, false)
|
||||
}
|
||||
|
||||
export {
|
||||
parseSyntax,
|
||||
parserSql
|
||||
}
|
Reference in New Issue
Block a user