import hiro.yoshioka.ast.sql.RowColumn;
import hiro.yoshioka.ast.sql.util.ASTAssist;
import hiro.yoshioka.ast.sql.util.ASTProposalableAssist;
import hiro.yoshioka.sql.resource.IDBResource;

import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

import org.eclipse.jface.text.contentassist.CompletionProposal;

public class AssistSelectCTester extends TestAbsAssistTester {

	// public void testFrom000() {
	// read("testSelc000.txt");
	//
	// fUtil.setRowColumn(new RowColumn(3, 6));
	// ASTProposalableAssist assist = fUtil.getASTProposalableAssist();
	// System.out.println("----------------------------------------");
	// // fUtil.dump();
	// // fUtil.dumpNodes();
	//
	// System.out.println("----------------------------------------");
	// assertEquals("Assist type is table?", ASTAssist.ASSIST_TABLE,
	// assist.getType());
	// IDBResource[] proposals = assist.proposalDBResources();
	// assertTrue("must have proposals", proposals.length > 0);
	// for (int i = 0; i < proposals.length; i++) {
	// System.out.println("[" + i + "]"
	// + proposals[i].getNameWithComment() + "/"
	// + proposals[i].getClass());
	// // assertEquals("first charactor must be 'B'", 'B',
	// // proposals[i].getName().charAt(0));
	// }
	//
	// System.out.println("==================================");
	// }
	//
	// public void testFrom00() {
	// read("testSelc00.txt");
	//
	// fUtil.setRowColumn(new RowColumn(3, 9));
	// ASTProposalableAssist assist = fUtil.getASTProposalableAssist();
	// System.out.println("----------------------------------------");
	// // fUtil.dump();
	// // fUtil.dumpNodes();
	//
	// System.out.println("----------------------------------------");
	// assertEquals("Assist type is table？", ASTAssist.ASSIST_TABLE,
	// assist.getType());
	// IDBResource[] proposals = assist.proposalDBResources();
	// assertTrue("must have proposals", proposals.length > 0);
	// for (int i = 0; i < proposals.length; i++) {
	// System.out.println("[" + i + "]"
	// + proposals[i].getNameWithComment() + "/"
	// + proposals[i].getClass());
	// // assertEquals("first charactor must be 'B'", 'B',
	// // proposals[i].getName().charAt(0));
	// }
	//
	// System.out.println("==================================");
	// }
	//
	// public void test01() {
	// read("testSelc01.txt");
	//
	// fUtil.setRowColumn(new RowColumn(3, 12));
	// ASTProposalableAssist assist = fUtil.getASTProposalableAssist();
	// System.out.println("----------------------------------------");
	// // fUtil.dump();
	// // fUtil.dumpNodes();
	//
	// System.out.println("----------------------------------------");
	// assertEquals("Assist type is table？", ASTAssist.ASSIST_TABLE,
	// assist.getType());
	// IDBResource[] proposals = assist.proposalDBResources();
	// assertTrue("must have proposals", proposals.length > 0);
	// for (int i = 0; i < proposals.length; i++) {
	// assertEquals("starts with 'M_CODE'", "M_CODE",
	// proposals[i].getName());
	// }
	// System.out.println("==================================");
	//
	// }
	//
	// public void test_A00() {
	// read("testSelcA00.txt");
	//
	// fUtil.setRowColumn(new RowColumn(2, 16));
	// ASTProposalableAssist assist = fUtil.getASTProposalableAssist();
	// System.out.println("----------------------------------------");
	// // fUtil.dump();
	// // fUtil.dumpNodes();
	//
	// System.out.println("----------------------------------------");
	// assertEquals("Assist type is column？", ASTAssist.ASSIST_COLUMN,
	// assist.getType());
	// IDBResource[] proposals = assist.proposalDBResources();
	// assertTrue("must have proposals", proposals.length > 0);
	// for (int i = 0; i < proposals.length; i++) {
	// System.out.println("[" + i + "]=" + proposals[i].getName());
	// }
	//
	// }

	public void test_A01() {
		read("testSelcA01.txt");

		fUtil.setRowColumn(new RowColumn(2, 17));
		ASTProposalableAssist assist = fUtil.getASTProposalableAssist();
		System.out.println("----------------------------------------");
		// fUtil.dump();
		// fUtil.dumpNodes();

		System.out.println("----------------------------------------");
		assertEquals("Assist type is column？", ASTAssist.ASSIST_COLUMN,
				assist.getType());
		IDBResource[] proposals = assist.proposalDBResources();
		assertTrue("must have proposals", proposals.length > 0);
		for (int i = 0; i < proposals.length; i++) {
			System.out.println("[" + i + "]=" + proposals[i].getName());
		}

	}

	public void test02() {
		read("testSelc02.txt");
		Logger.global.getParent().setLevel(Level.FINER);
		fUtil.setRowColumn(new RowColumn(2, 19));
		ASTProposalableAssist assist = fUtil.getASTProposalableAssist();
		System.out.println("----------------------------------------");
		assertEquals("Assist type is column？", ASTAssist.ASSIST_COLUMN,
				assist.getType());
		List<CompletionProposal> list = assist.getProposalList();
		for (int i = 0; i < list.size(); i++) {
			System.out.println(list.get(i));
		}

	}

}