"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
 * MySQL类型数据源的自动提示和错误提示生成实现类
 */
const antlr4ts_1 = require("antlr4ts");
const mysqlListener_1 = require("../../../listener/mysql/mysqlListener");
const MySqlLexer_1 = require("../../../grammar/mysql/MySqlLexer");
const recovermark_1 = require("../../../strategy/recovermark");
const MySqlParser_1 = require("../../../grammar/mysql/MySqlParser");
const mySqlErrorStrategy_1 = require("../../../strategy/mysql/mySqlErrorStrategy");
const tree_1 = require("antlr4ts/tree");
const abstractParseService_1 = require("../abstract/abstractParseService");
const mysqlKeyWord_1 = require("../../../keyword/mysql/mysqlKeyWord");
class MysqlParseService extends abstractParseService_1.AbstractParseService {
    parserSQL() {
        let charStream = antlr4ts_1.CharStreams.fromString(this.editorContext.command);
        let lexer = new MySqlLexer_1.MySqlLexer(charStream);
        let tokenStream = new antlr4ts_1.CommonTokenStream(lexer);
        recovermark_1.Recovermark.rewriteStream = new antlr4ts_1.TokenStreamRewriter(tokenStream);
        recovermark_1.Recovermark.editorContext = this.editorContext;
        let parser = new MySqlParser_1.MySqlParser(tokenStream);
        parser.errorHandler = new mySqlErrorStrategy_1.MySqlErrorStrategy();
        let rootContext = parser.root();
        let walker = new tree_1.ParseTreeWalker();
        let listener = new mysqlListener_1.MysqlListener(this.symbolTable);
        walker.walk(listener, rootContext);
        return tokenStream;
    }
    getKeyWorld() {
        return mysqlKeyWord_1.MysqlKeyWord.keyWordList;
    }
}
exports.MysqlParseService = MysqlParseService;
