import {EditorContext,EditorParser,CodeCompletionRequest} from "."
import Global = WebAssembly.Global;
import {GlobalConstant} from "./constant/globalConstant";


//手动测试类

function selectTest1() {
    console.log("当前selectTest1：");
    let context = new EditorContext();
    context.cpId = 1;
    context.dataBaseName = "employees";
    context.editorType = "sql";
    context.command = "select a, b from c";
    context.rangeOffset = 10;
    context.currentChar = "b";
    context.dataSourceName = GlobalConstant.DATASOURCE_ORACLE;


    let parseResult = EditorParser.parse(context);
    console.log("测试结果：");
    console.log(parseResult);

}

function selectTest2() {
    console.log("当前selectTest2：");
    let context = new EditorContext();
    context.cpId = 1;
    context.dataBaseName = "employees";
    context.editorType = "sql";
    context.command = "select a from c";
    context.rangeOffset = 7;
    context.currentChar = "a";
    context.dataSourceName = GlobalConstant.DATASOURCE_ORACLE;


    let parseResult = EditorParser.parse(context);
    console.log("测试结果：");
    console.log(parseResult);

}


function selectTest3() {
    console.log("当前selectTest3：");
    let context = new EditorContext();
    context.cpId = 1;
    context.dataBaseName = "employees";
    context.editorType = "sql";
    context.command = "select a";
    context.rangeOffset = 7;
    context.currentChar = "a";
    context.dataSourceName = GlobalConstant.DATASOURCE_ORACLE;


    let parseResult = EditorParser.parse(context);
    console.log("测试结果：");
    console.log(parseResult);

}

function selectErrorTest1() {
    console.log("当前selectTest3：");
    let context = new EditorContext();
    context.cpId = 1;
    context.dataBaseName = "employees";
    context.editorType = "sql";
    context.command = "select a froc b";
    context.rangeOffset = 7;
    context.currentChar = "a";
    context.dataSourceName = GlobalConstant.DATASOURCE_ORACLE;


    let parseResult = EditorParser.parse(context);
    console.log("测试结果：");
    console.log(parseResult);
}

// function insertTest(){
//     console.log("当前insertTest：");
//     let context = new EditorContext();
//     context.cpId = 1;
//     context.dataBaseName = "world";
//     context.editorType = "sql";
//     context.command = "insert into c(ID,Name) values(1,2)";
//     context.rangeOffset = 12;
//     context.currentChar = "c";
//     context.dataSourceName = "MYSQL";
//
//
//
//     let parser = new EditorParser();
//     let completionRequest = EditorParser.parse(context);
//     if (completionRequest == undefined){
//         console.log("补全类型为undefined")
//     }else {
//         console.log(completionRequest)
//     }
//
//
// }

// function updateTest(){
//     console.log("当前updateTest：");
//     let context = new EditorContext();
//     context.cpId = 1;
//     context.dataBaseName = "world";
//     context.editorType = "sql";
//     context.command = "UPDATE city SET N=(SELECT Name FROM country WHERE ID=30) WHERE ID=10";
//     context.rangeOffset = 16;
//     context.currentChar = "N";
//     context.dataSourceName = "MYSQL";
//
//
//
//     let parser = new EditorParser();
//     let completionRequest = EditorParser.parse(context);
//     if (completionRequest == undefined){
//         console.log("补全类型为undefined")
//     }else {
//         console.log(completionRequest)
//     }
//
//
// }

// function deleteTest(){
//     console.log("当前insertTest：");
//     let context = new EditorContext();
//     context.cpId = 1;
//     context.dataBaseName = "world";
//     context.editorType = "sql";
//     context.command = "DELETE FROM c";
//     context.rangeOffset = 12;
//     context.currentChar = "c";
//     context.dataSourceName = "MYSQL";
//
//
//
//     let parser = new EditorParser();
//     let completionRequest = EditorParser.parse(context);
//     if (completionRequest == undefined){
//         console.log("补全类型为undefined")
//     }else {
//         console.log(completionRequest)
//     }
//
//
// }


/**
 * 查询测试集
 */
function selectTestSuit(){
    selectTest1();
    selectTest2();
    selectTest3();
}

/**
 * 错误测试集
 */

function errorTestSuit(){
    selectErrorTest1();
}

selectTestSuit();
errorTestSuit();

// insertTest();
// updateTest();
// deleteTest();