"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const abstractParseService_1 = require("../abstract/abstractParseService");
const antlr4ts_1 = require("antlr4ts");
const oracleKeyWord_1 = require("../../../keyword/oracle/oracleKeyWord");
const PlSqlLexer_1 = require("../../../grammar/oracle/PlSqlLexer");
const recovermark_1 = require("../../../strategy/recovermark");
const oracleErrorStrategy_1 = require("../../../strategy/oracle/oracleErrorStrategy");
const oracleListener_1 = require("../../../listener/oracle/oracleListener");
const PlSqlParser_1 = require("../../../grammar/oracle/PlSqlParser");
const tree_1 = require("antlr4ts/tree");
class OracleParseService extends abstractParseService_1.AbstractParseService {
    getKeyWorld() {
        return oracleKeyWord_1.OracleKeyWord.keyword;
    }
    parserSQL() {
        let charStream = antlr4ts_1.CharStreams.fromString(this.editorContext.command);
        let lexer = new PlSqlLexer_1.PlSqlLexer(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 PlSqlParser_1.PlSqlParser(tokenStream);
        parser.errorHandler = new oracleErrorStrategy_1.OracleErrorStrategy();
        let rootContext = parser.sql_script();
        let walker = new tree_1.ParseTreeWalker();
        let listener = new oracleListener_1.OracleListener(this.symbolTable);
        // @ts-ignore
        walker.walk(listener, rootContext);
        return tokenStream;
    }
}
exports.OracleParseService = OracleParseService;
