|
From: SVN by r. <sv...@ca...> - 2007-10-28 11:13:54
|
Author: roy
Date: 2007-10-28 12:12:50 +0100 (Sun, 28 Oct 2007)
New Revision: 187
Added:
src/main/java/nl/improved/sqlclient/TabCompletionInfo.java
Modified:
src/main/java/nl/improved/sqlclient/SQLShell.java
src/main/java/nl/improved/sqlclient/SQLUtil.java
src/main/java/nl/improved/sqlclient/commands/Command.java
src/main/java/nl/improved/sqlclient/commands/DescCommand.java
src/main/java/nl/improved/sqlclient/commands/InfoCommand.java
src/main/java/nl/improved/sqlclient/commands/ShowCommand.java
src/test/java/nl/improved/sqlclient/SQLUtilTest.java
Log:
initial refactor step to add support to tab completion of commands...
NOTE: currently tab completion for desc is broken because of this
Modified: src/main/java/nl/improved/sqlclient/SQLShell.java
===================================================================
--- src/main/java/nl/improved/sqlclient/SQLShell.java 2007-10-28 10:42:25 UTC (rev 186)
+++ src/main/java/nl/improved/sqlclient/SQLShell.java 2007-10-28 11:12:50 UTC (rev 187)
@@ -553,15 +553,15 @@
* @return the tab completion value.
*/
protected CharSequence getTabCompletion(SQLCommand commandLines, Point cursorPosition) {
- SQLUtil.TabCompletionInfo info = SQLUtil.getTabCompletionInfo(commandLines, cursorPosition);
- if (info.getMatchType() == SQLUtil.TabCompletionInfo.MatchType.SQL_KEYWORD) {
+ TabCompletionInfo info = SQLUtil.getTabCompletionInfo(commandLines, cursorPosition);
+ if (info.getMatchType() == TabCompletionInfo.MatchType.SQL_KEYWORD) {
return nullToEmpty(findMatch(info.getPossibleMatches(), info.getStart()));
}
- if (info.getMatchType() == SQLUtil.TabCompletionInfo.MatchType.TABLE_NAMES) {
+ if (info.getMatchType() == TabCompletionInfo.MatchType.TABLE_NAMES) {
//debug("table completion for \""+info.getStart()+"\"");
return nullToEmpty(findMatch(getTableNames(), info.getStart()));
}
- if (info.getMatchType() == SQLUtil.TabCompletionInfo.MatchType.COLUMN_NAMES) {
+ if (info.getMatchType() == TabCompletionInfo.MatchType.COLUMN_NAMES) {
return nullToEmpty(findMatch(getColumnNames(info.getPossibleMatches()), info.getStart()));
}
Toolkit.beep();
@@ -789,6 +789,16 @@
return "connect";
}
+ /**
+ * Returns some tab completion info for the specified command.
+ * @param commandInfo the command lines
+ * @param commandPoint the cursor position
+ * @return some tab completion info for the specified command.
+ */
+ public TabCompletionInfo getTabCompletion(List<? extends CharSequence> commandInfo, Point commandPoint) {
+ return null;
+ }
+
public CharSequence getHelp() {
StringBuffer buf = new StringBuffer();
Iterator<String> idents = DBConnector.getInstance().getPredefinedConnectionIdentifiers().iterator();
@@ -830,6 +840,15 @@
return "disconnect";
}
+ /**
+ * Returns some tab completion info for the specified command.
+ * @param commandInfo the command lines
+ * @param commandPoint the cursor position
+ * @return some tab completion info for the specified command.
+ */
+ public TabCompletionInfo getTabCompletion(List<? extends CharSequence> commandInfo, Point commandPoint) {
+ return null;
+ }
public CharSequence getHelp() {
return "Close the current conection to the database";
}
@@ -853,6 +872,15 @@
return "window";
}
+ /**
+ * Returns some tab completion info for the specified command.
+ * @param commandInfo the command lines
+ * @param commandPoint the cursor position
+ * @return some tab completion info for the specified command.
+ */
+ public TabCompletionInfo getTabCompletion(List<? extends CharSequence> commandInfo, Point commandPoint) {
+ return null;
+ }
public CharSequence getHelp() {
return "window resize: notify the sql client of a screen resize";
}
@@ -876,6 +904,15 @@
return "history";
}
+ /**
+ * Returns some tab completion info for the specified command.
+ * @param commandInfo the command lines
+ * @param commandPoint the cursor position
+ * @return some tab completion info for the specified command.
+ */
+ public TabCompletionInfo getTabCompletion(List<? extends CharSequence> commandInfo, Point commandPoint) {
+ return null;
+ }
public CharSequence getHelp() {
return "Show history of executed statements\n" +
"By using '/<search>' you can search the command history" ;
@@ -896,6 +933,15 @@
public CharSequence getCommandString() {
return "quit";
}
+ /**
+ * Returns some tab completion info for the specified command.
+ * @param commandInfo the command lines
+ * @param commandPoint the cursor position
+ * @return some tab completion info for the specified command.
+ */
+ public TabCompletionInfo getTabCompletion(List<? extends CharSequence> commandInfo, Point commandPoint) {
+ return null;
+ }
}
/**
* Provide help to the user.
@@ -968,6 +1014,15 @@
return "help";
}
+ /**
+ * Returns some tab completion info for the specified command.
+ * @param commandInfo the command lines
+ * @param commandPoint the cursor position
+ * @return some tab completion info for the specified command.
+ */
+ public TabCompletionInfo getTabCompletion(List<? extends CharSequence> commandInfo, Point commandPoint) {
+ return null;
+ }
public CharSequence getHelp() {
return "this command. Please use 'help' to get a list of available commands you can use.";
}
@@ -1018,6 +1073,15 @@
return "spool";
}
+ /**
+ * Returns some tab completion info for the specified command.
+ * @param commandInfo the command lines
+ * @param commandPoint the cursor position
+ * @return some tab completion info for the specified command.
+ */
+ public TabCompletionInfo getTabCompletion(List<? extends CharSequence> commandInfo, Point commandPoint) {
+ return null;
+ }
public CharSequence getHelp() {
return "filename: Spool all output and queries to the specified file\n"+
"off : Stop spooling data to the file.\n" +
@@ -1058,6 +1122,15 @@
return "@";
}
+ /**
+ * Returns some tab completion info for the specified command.
+ * @param commandInfo the command lines
+ * @param commandPoint the cursor position
+ * @return some tab completion info for the specified command.
+ */
+ public TabCompletionInfo getTabCompletion(List<? extends CharSequence> commandInfo, Point commandPoint) {
+ return null;
+ }
public CharSequence getHelp() {
return "Specify filename to execute a 'batch' command.\n"+
"For example '@mystatements.sql' executes all statements part of the mystatements.sql file in the current directory."+
Modified: src/main/java/nl/improved/sqlclient/SQLUtil.java
===================================================================
--- src/main/java/nl/improved/sqlclient/SQLUtil.java 2007-10-28 10:42:25 UTC (rev 186)
+++ src/main/java/nl/improved/sqlclient/SQLUtil.java 2007-10-28 11:12:50 UTC (rev 187)
@@ -134,13 +134,13 @@
public static TabCompletionInfo getTabCompletionInfo(List<? extends CharSequence> commandInfo, Point commandPoint) {
if (commandInfo.size() == 1 && commandInfo.get(0).length() == 0) {
return new TabCompletionInfo(TabCompletionInfo.MatchType.SQL_KEYWORD
- , Arrays.asList(new String[]{"SELECT", "INSERT INTO", "DELETE FROM", "UPDATE", "DESC"}));
+ , Arrays.asList(new String[]{"SELECT", "INSERT INTO", "DELETE FROM", "UPDATE"}));
}
String startOfCommand = getStartOfCommand(commandInfo, commandPoint);
String lastKeyword = getLastKeyWord(startOfCommand);
if (lastKeyword == null) {
return new TabCompletionInfo(TabCompletionInfo.MatchType.SQL_KEYWORD
- , Arrays.asList(new String[]{"SELECT", "INSERT INTO", "DELETE FROM", "UPDATE", "DESC"}), startOfCommand);
+ , Arrays.asList(new String[]{"SELECT", "INSERT INTO", "DELETE FROM", "UPDATE"}), startOfCommand);
}
if (lastKeyword.equalsIgnoreCase("UPDATE")) {
String end = startOfCommand.substring(startOfCommand.lastIndexOf(' ')+1);
@@ -258,13 +258,11 @@
return new TabCompletionInfo(TabCompletionInfo.MatchType.SQL_KEYWORD
, Arrays.asList(new String[]{"AND", "OR", "IN", "GROUP BY", "ORDER BY"}));
} else if (lastKeyword.equalsIgnoreCase("DESC")) {
- String end = startOfCommand.substring(startOfCommand.lastIndexOf(' ')+1);
- return new TabCompletionInfo(TabCompletionInfo.MatchType.TABLE_NAMES, new ArrayList<String>(), end);
}
return new TabCompletionInfo(TabCompletionInfo.MatchType.UNKNOWN, Arrays.asList(new String[0]));
}
- private static String getStartOfCommand(List<? extends CharSequence> commandInfo, Point commandPoint) {
+ public static String getStartOfCommand(List<? extends CharSequence> commandInfo, Point commandPoint) {
StringBuffer buff = new StringBuffer();
for (int i = 0; i <= commandPoint.y; i++) {
if (i == commandPoint.y) {
@@ -291,33 +289,4 @@
}
return spaceIndex;
}
-
- public static class TabCompletionInfo {
- public enum MatchType {SQL_KEYWORD, TABLE_NAMES, COLUMN_NAMES, UNKNOWN}
-
- private MatchType type;
- private List<String> possibleMatches;
- private String start;
-
- private TabCompletionInfo(MatchType type, List<String> possibleMatches) {
- this(type, possibleMatches, "");
- }
-
- private TabCompletionInfo(MatchType type, List<String> possibleMatches, String start) {
- this.type = type;
- this.possibleMatches = possibleMatches;
- this.start = start;
- }
-
- public MatchType getMatchType() {
- return type;
- }
- public List<String> getPossibleMatches() {
- return possibleMatches;
- }
- public String getStart() {
- return start;
- }
-
- }
}
Added: src/main/java/nl/improved/sqlclient/TabCompletionInfo.java
===================================================================
--- src/main/java/nl/improved/sqlclient/TabCompletionInfo.java (rev 0)
+++ src/main/java/nl/improved/sqlclient/TabCompletionInfo.java 2007-10-28 11:12:50 UTC (rev 187)
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2007 Roy van der Kuil (ro...@va...) and Stefan Rotman (st...@ro...)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package nl.improved.sqlclient;
+
+import java.util.List;
+
+public class TabCompletionInfo {
+ public enum MatchType {SQL_KEYWORD, TABLE_NAMES, COLUMN_NAMES, UNKNOWN}
+
+ private MatchType type;
+ private List<String> possibleMatches;
+ private String start;
+
+ public TabCompletionInfo(MatchType type, List<String> possibleMatches) {
+ this(type, possibleMatches, "");
+ }
+
+ public TabCompletionInfo(MatchType type, List<String> possibleMatches, String start) {
+ this.type = type;
+ this.possibleMatches = possibleMatches;
+ this.start = start;
+ }
+
+ public MatchType getMatchType() {
+ return type;
+ }
+ public List<String> getPossibleMatches() {
+ return possibleMatches;
+ }
+ public String getStart() {
+ return start;
+ }
+
+}
Modified: src/main/java/nl/improved/sqlclient/commands/Command.java
===================================================================
--- src/main/java/nl/improved/sqlclient/commands/Command.java 2007-10-28 10:42:25 UTC (rev 186)
+++ src/main/java/nl/improved/sqlclient/commands/Command.java 2007-10-28 11:12:50 UTC (rev 187)
@@ -15,7 +15,11 @@
*/
package nl.improved.sqlclient.commands;
+import java.util.List;
import nl.improved.sqlclient.SQLCommand;
+import nl.improved.sqlclient.Point;
+import nl.improved.sqlclient.SQLUtil;
+import nl.improved.sqlclient.TabCompletionInfo;
/**
* Implement this interface to add a specific command to the sql client.
*/
@@ -31,7 +35,15 @@
* @return the command key that should show up in the help list.
*/
CharSequence getCommandString();
+
/**
+ * Returns some tab completion info for the specified command.
+ * @param commandInfo the command lines
+ * @param commandPoint the cursor position
+ * @return some tab completion info for the specified command.
+ */
+ TabCompletionInfo getTabCompletion(List<? extends CharSequence> commandInfo, Point commandPoint);
+ /**
* Returns a explenation string of how to use this command.
* @return a explenation string of how to use this command.
*/
Modified: src/main/java/nl/improved/sqlclient/commands/DescCommand.java
===================================================================
--- src/main/java/nl/improved/sqlclient/commands/DescCommand.java 2007-10-28 10:42:25 UTC (rev 186)
+++ src/main/java/nl/improved/sqlclient/commands/DescCommand.java 2007-10-28 11:12:50 UTC (rev 187)
@@ -15,6 +15,11 @@
*/
package nl.improved.sqlclient.commands;
+import java.util.List;
+import java.util.ArrayList;
+import nl.improved.sqlclient.Point;
+import nl.improved.sqlclient.SQLUtil;
+import nl.improved.sqlclient.TabCompletionInfo;
import nl.improved.sqlclient.SQLCommand;
import nl.improved.sqlclient.DBConnector;
import nl.improved.sqlclient.util.ResultBuilder;
@@ -100,6 +105,12 @@
return "desc";
}
+
+ public TabCompletionInfo getTabCompletion(List<? extends CharSequence> commandInfo, Point commandPoint) {
+ String startOfCommand = SQLUtil.getStartOfCommand(commandInfo, commandPoint);
+ String end = startOfCommand.substring(startOfCommand.lastIndexOf(' ')+1);
+ return new TabCompletionInfo(TabCompletionInfo.MatchType.TABLE_NAMES, new ArrayList<String>(), end);
+ }
/**
* Return the command help.
* @return the command help.
Modified: src/main/java/nl/improved/sqlclient/commands/InfoCommand.java
===================================================================
--- src/main/java/nl/improved/sqlclient/commands/InfoCommand.java 2007-10-28 10:42:25 UTC (rev 186)
+++ src/main/java/nl/improved/sqlclient/commands/InfoCommand.java 2007-10-28 11:12:50 UTC (rev 187)
@@ -15,6 +15,9 @@
*/
package nl.improved.sqlclient.commands;
+import java.util.List;
+import nl.improved.sqlclient.Point;
+import nl.improved.sqlclient.TabCompletionInfo;
import nl.improved.sqlclient.SQLCommand;
import nl.improved.sqlclient.DBConnector;
import java.sql.SQLException;
@@ -66,6 +69,16 @@
}
/**
+ * Returns some tab completion info for the specified command.
+ * @param commandInfo the command lines
+ * @param commandPoint the cursor position
+ * @return some tab completion info for the specified command.
+ */
+ public TabCompletionInfo getTabCompletion(List<? extends CharSequence> commandInfo, Point commandPoint) {
+ return null;
+ }
+
+ /**
* Return the command help.
* @return the command help.
*/
Modified: src/main/java/nl/improved/sqlclient/commands/ShowCommand.java
===================================================================
--- src/main/java/nl/improved/sqlclient/commands/ShowCommand.java 2007-10-28 10:42:25 UTC (rev 186)
+++ src/main/java/nl/improved/sqlclient/commands/ShowCommand.java 2007-10-28 11:12:50 UTC (rev 187)
@@ -17,6 +17,9 @@
import nl.improved.sqlclient.SQLCommand;
import nl.improved.sqlclient.DBConnector;
+import nl.improved.sqlclient.Point;
+import nl.improved.sqlclient.SQLUtil;
+import nl.improved.sqlclient.TabCompletionInfo;
import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;
@@ -94,6 +97,16 @@
}
/**
+ * Returns some tab completion info for the specified command.
+ * @param commandInfo the command lines
+ * @param commandPoint the cursor position
+ * @return some tab completion info for the specified command.
+ */
+ public TabCompletionInfo getTabCompletion(List<? extends CharSequence> commandInfo, Point commandPoint) {
+ return null;
+ }
+
+ /**
* Return the command help.
* @return the command help.
*/
Modified: src/test/java/nl/improved/sqlclient/SQLUtilTest.java
===================================================================
--- src/test/java/nl/improved/sqlclient/SQLUtilTest.java 2007-10-28 10:42:25 UTC (rev 186)
+++ src/test/java/nl/improved/sqlclient/SQLUtilTest.java 2007-10-28 11:12:50 UTC (rev 187)
@@ -38,32 +38,31 @@
assertEquals("from", SQLUtil.getLastKeyWord(sql));
sql = "SELECT * FROM";
assertEquals("FROM", SQLUtil.getLastKeyWord(sql));
- sql = "DESC indummy";
- assertEquals("DESC", SQLUtil.getLastKeyWord(sql));
- sql = "DESC dummyin ";
- assertEquals("DESC", SQLUtil.getLastKeyWord(sql));
+// sql = "DESC indummy";
+// assertEquals("DESC", SQLUtil.getLastKeyWord(sql));
+// sql = "DESC dummyin ";
+// assertEquals("DESC", SQLUtil.getLastKeyWord(sql));
}
public void testTabCompletionInfoBLANK() {
List<String> sqlCommand = Arrays.asList(new String[]{""});
Point cursorPos = new Point(0,0);
- SQLUtil.TabCompletionInfo info = SQLUtil.getTabCompletionInfo(sqlCommand, cursorPos);
+ TabCompletionInfo info = SQLUtil.getTabCompletionInfo(sqlCommand, cursorPos);
assertNotNull(info);
- assertEquals(SQLUtil.TabCompletionInfo.MatchType.SQL_KEYWORD, info.getMatchType());
+ assertEquals(TabCompletionInfo.MatchType.SQL_KEYWORD, info.getMatchType());
List<String> matches = info.getPossibleMatches();
assertTrue(matches.contains("SELECT"));
assertTrue(matches.contains("INSERT INTO"));
assertTrue(matches.contains("DELETE FROM"));
assertTrue(matches.contains("UPDATE"));
- assertTrue(matches.contains("DESC"));
}
public void testTabCompletionInfoSELECT() {
List<String> sqlCommand = Arrays.asList(new String[]{"SELECT A"});
Point cursorPos = new Point(sqlCommand.get(0).length(),0);
- SQLUtil.TabCompletionInfo info = SQLUtil.getTabCompletionInfo(sqlCommand, cursorPos);
+ TabCompletionInfo info = SQLUtil.getTabCompletionInfo(sqlCommand, cursorPos);
assertNotNull(info);
- assertEquals(SQLUtil.TabCompletionInfo.MatchType.TABLE_NAMES, info.getMatchType());
+ assertEquals(TabCompletionInfo.MatchType.TABLE_NAMES, info.getMatchType());
List<String> matches = info.getPossibleMatches();
assertEquals(0, matches.size());
assertEquals("A", info.getStart());
@@ -72,7 +71,7 @@
cursorPos = new Point(sqlCommand.get(0).length(),0);
info = SQLUtil.getTabCompletionInfo(sqlCommand, cursorPos);
assertNotNull(info);
- assertEquals(SQLUtil.TabCompletionInfo.MatchType.TABLE_NAMES, info.getMatchType());
+ assertEquals(TabCompletionInfo.MatchType.TABLE_NAMES, info.getMatchType());
matches = info.getPossibleMatches();
assertEquals(0, matches.size());
@@ -80,7 +79,7 @@
cursorPos = new Point(sqlCommand.get(0).length(),0);
info = SQLUtil.getTabCompletionInfo(sqlCommand, cursorPos);
assertNotNull(info);
- assertEquals(SQLUtil.TabCompletionInfo.MatchType.SQL_KEYWORD, info.getMatchType());
+ assertEquals(TabCompletionInfo.MatchType.SQL_KEYWORD, info.getMatchType());
matches = info.getPossibleMatches();
assertEquals(1, matches.size());
assertTrue(matches.contains("FROM"));
@@ -89,7 +88,7 @@
cursorPos = new Point(sqlCommand.get(0).length(),0);
info = SQLUtil.getTabCompletionInfo(sqlCommand, cursorPos);
assertNotNull(info);
- assertEquals(SQLUtil.TabCompletionInfo.MatchType.SQL_KEYWORD, info.getMatchType());
+ assertEquals(TabCompletionInfo.MatchType.SQL_KEYWORD, info.getMatchType());
matches = info.getPossibleMatches();
assertEquals(1, matches.size());
assertTrue(matches.contains("FROM"));
@@ -99,7 +98,7 @@
cursorPos = new Point(sqlCommand.get(0).length(),0);
info = SQLUtil.getTabCompletionInfo(sqlCommand, cursorPos);
assertNotNull(info);
- assertEquals(SQLUtil.TabCompletionInfo.MatchType.SQL_KEYWORD, info.getMatchType());
+ assertEquals(TabCompletionInfo.MatchType.SQL_KEYWORD, info.getMatchType());
matches = info.getPossibleMatches();
assertEquals(1, matches.size());
assertTrue(matches.contains("FROM"));
@@ -109,7 +108,7 @@
cursorPos = new Point(sqlCommand.get(0).length(),0);
info = SQLUtil.getTabCompletionInfo(sqlCommand, cursorPos);
assertNotNull(info);
- assertEquals(SQLUtil.TabCompletionInfo.MatchType.SQL_KEYWORD, info.getMatchType());
+ assertEquals(TabCompletionInfo.MatchType.SQL_KEYWORD, info.getMatchType());
matches = info.getPossibleMatches();
assertEquals(1, matches.size());
assertTrue(matches.contains("FROM"));
@@ -119,7 +118,7 @@
cursorPos = new Point(sqlCommand.get(0).length(),0);
info = SQLUtil.getTabCompletionInfo(sqlCommand, cursorPos);
assertNotNull(info);
- assertEquals(SQLUtil.TabCompletionInfo.MatchType.COLUMN_NAMES, info.getMatchType());
+ assertEquals(TabCompletionInfo.MatchType.COLUMN_NAMES, info.getMatchType());
matches = info.getPossibleMatches();
assertEquals(1, matches.size());
assertEquals("A", matches.get(0));
@@ -129,9 +128,9 @@
public void testTabCompletionInfoFROM() {
List<String> sqlCommand = Arrays.asList(new String[]{"SELECT * FROM A"});
Point cursorPos = new Point(sqlCommand.get(0).length(),0);
- SQLUtil.TabCompletionInfo info = SQLUtil.getTabCompletionInfo(sqlCommand, cursorPos);
+ TabCompletionInfo info = SQLUtil.getTabCompletionInfo(sqlCommand, cursorPos);
assertNotNull(info);
- assertEquals(SQLUtil.TabCompletionInfo.MatchType.TABLE_NAMES, info.getMatchType());
+ assertEquals(TabCompletionInfo.MatchType.TABLE_NAMES, info.getMatchType());
List<String> matches = info.getPossibleMatches();
assertEquals(0, matches.size());
assertEquals("A", info.getStart());
@@ -140,7 +139,7 @@
cursorPos = new Point(sqlCommand.get(0).length(),0);
info = SQLUtil.getTabCompletionInfo(sqlCommand, cursorPos);
assertNotNull(info);
- assertEquals(SQLUtil.TabCompletionInfo.MatchType.TABLE_NAMES, info.getMatchType());
+ assertEquals(TabCompletionInfo.MatchType.TABLE_NAMES, info.getMatchType());
matches = info.getPossibleMatches();
assertEquals(0, matches.size());
assertEquals("B", info.getStart());
@@ -149,7 +148,7 @@
cursorPos = new Point(sqlCommand.get(0).length(),0);
info = SQLUtil.getTabCompletionInfo(sqlCommand, cursorPos);
assertNotNull(info);
- assertEquals(SQLUtil.TabCompletionInfo.MatchType.TABLE_NAMES, info.getMatchType());
+ assertEquals(TabCompletionInfo.MatchType.TABLE_NAMES, info.getMatchType());
matches = info.getPossibleMatches();
assertEquals(0, matches.size());
assertEquals("B", info.getStart());
@@ -158,7 +157,7 @@
cursorPos = new Point("SELECT * FROM A".length(),0);
info = SQLUtil.getTabCompletionInfo(sqlCommand, cursorPos);
assertNotNull(info);
- assertEquals(SQLUtil.TabCompletionInfo.MatchType.TABLE_NAMES, info.getMatchType());
+ assertEquals(TabCompletionInfo.MatchType.TABLE_NAMES, info.getMatchType());
matches = info.getPossibleMatches();
assertEquals(0, matches.size());
assertEquals("A", info.getStart());
@@ -167,7 +166,7 @@
cursorPos = new Point(sqlCommand.get(0).length(),0);
info = SQLUtil.getTabCompletionInfo(sqlCommand, cursorPos);
assertNotNull(info);
- assertEquals(SQLUtil.TabCompletionInfo.MatchType.TABLE_NAMES, info.getMatchType());
+ assertEquals(TabCompletionInfo.MatchType.TABLE_NAMES, info.getMatchType());
matches = info.getPossibleMatches();
assertEquals(0, matches.size());
assertEquals("A", info.getStart());
@@ -176,9 +175,9 @@
public void testTabCompletionInfoWHERE() {
List<String> sqlCommand = Arrays.asList(new String[]{"SELECT * FROM A,B "});
Point cursorPos = new Point(sqlCommand.get(0).length(),0);
- SQLUtil.TabCompletionInfo info = SQLUtil.getTabCompletionInfo(sqlCommand, cursorPos);
+ TabCompletionInfo info = SQLUtil.getTabCompletionInfo(sqlCommand, cursorPos);
assertNotNull(info);
- assertEquals(SQLUtil.TabCompletionInfo.MatchType.SQL_KEYWORD, info.getMatchType());
+ assertEquals(TabCompletionInfo.MatchType.SQL_KEYWORD, info.getMatchType());
List<String> matches = info.getPossibleMatches();
assertEquals(1, matches.size());
assertTrue(matches.contains("WHERE"));
@@ -187,7 +186,7 @@
cursorPos = new Point(sqlCommand.get(0).length(),0);
info = SQLUtil.getTabCompletionInfo(sqlCommand, cursorPos);
assertNotNull(info);
- assertEquals(SQLUtil.TabCompletionInfo.MatchType.SQL_KEYWORD, info.getMatchType());
+ assertEquals(TabCompletionInfo.MatchType.SQL_KEYWORD, info.getMatchType());
matches = info.getPossibleMatches();
assertEquals(1, matches.size());
assertTrue(matches.contains("WHERE"));
@@ -197,9 +196,9 @@
public void testTabCompletionInfoWHEREConditions() {
List<String> sqlCommand = Arrays.asList(new String[]{"SELECT * FROM A,B WHERE "});
Point cursorPos = new Point(sqlCommand.get(0).length(),0);
- SQLUtil.TabCompletionInfo info = SQLUtil.getTabCompletionInfo(sqlCommand, cursorPos);
+ TabCompletionInfo info = SQLUtil.getTabCompletionInfo(sqlCommand, cursorPos);
assertNotNull(info);
- assertEquals(SQLUtil.TabCompletionInfo.MatchType.COLUMN_NAMES, info.getMatchType());
+ assertEquals(TabCompletionInfo.MatchType.COLUMN_NAMES, info.getMatchType());
List<String> matches = info.getPossibleMatches();
assertEquals(2, matches.size());
assertTrue(matches.contains("A"));
@@ -209,7 +208,7 @@
cursorPos = new Point(sqlCommand.get(0).length(),0);
info = SQLUtil.getTabCompletionInfo(sqlCommand, cursorPos);
assertNotNull(info);
- assertEquals(SQLUtil.TabCompletionInfo.MatchType.COLUMN_NAMES, info.getMatchType());
+ assertEquals(TabCompletionInfo.MatchType.COLUMN_NAMES, info.getMatchType());
matches = info.getPossibleMatches();
assertEquals(2, matches.size());
assertTrue(matches.contains("A"));
@@ -220,7 +219,7 @@
cursorPos = new Point(sqlCommand.get(0).length(),0);
info = SQLUtil.getTabCompletionInfo(sqlCommand, cursorPos);
assertNotNull(info);
- assertEquals(SQLUtil.TabCompletionInfo.MatchType.COLUMN_NAMES, info.getMatchType());
+ assertEquals(TabCompletionInfo.MatchType.COLUMN_NAMES, info.getMatchType());
matches = info.getPossibleMatches();
assertEquals(2, matches.size());
assertTrue(matches.contains("A"));
@@ -231,7 +230,7 @@
cursorPos = new Point(sqlCommand.get(0).length(),0);
info = SQLUtil.getTabCompletionInfo(sqlCommand, cursorPos);
assertNotNull(info);
- assertEquals(SQLUtil.TabCompletionInfo.MatchType.COLUMN_NAMES, info.getMatchType());
+ assertEquals(TabCompletionInfo.MatchType.COLUMN_NAMES, info.getMatchType());
matches = info.getPossibleMatches();
assertEquals(1, matches.size());
assertTrue(matches.contains("A"));
@@ -242,7 +241,7 @@
cursorPos = new Point(sqlCommand.get(0).length(),0);
info = SQLUtil.getTabCompletionInfo(sqlCommand, cursorPos);
assertNotNull(info);
- assertEquals(SQLUtil.TabCompletionInfo.MatchType.COLUMN_NAMES, info.getMatchType());
+ assertEquals(TabCompletionInfo.MatchType.COLUMN_NAMES, info.getMatchType());
matches = info.getPossibleMatches();
assertEquals(2, matches.size());
assertTrue(matches.contains("A"));
@@ -253,7 +252,7 @@
cursorPos = new Point(sqlCommand.get(0).length(),0);
info = SQLUtil.getTabCompletionInfo(sqlCommand, cursorPos);
assertNotNull(info);
- assertEquals(SQLUtil.TabCompletionInfo.MatchType.COLUMN_NAMES, info.getMatchType());
+ assertEquals(TabCompletionInfo.MatchType.COLUMN_NAMES, info.getMatchType());
matches = info.getPossibleMatches();
assertEquals(2, matches.size());
assertTrue(matches.contains("A"));
@@ -264,7 +263,7 @@
cursorPos = new Point(sqlCommand.get(0).length(),0);
info = SQLUtil.getTabCompletionInfo(sqlCommand, cursorPos);
assertNotNull(info);
- assertEquals(SQLUtil.TabCompletionInfo.MatchType.COLUMN_NAMES, info.getMatchType());
+ assertEquals(TabCompletionInfo.MatchType.COLUMN_NAMES, info.getMatchType());
matches = info.getPossibleMatches();
assertTrue(matches.contains("A"));
assertTrue(matches.contains("B"));
@@ -274,7 +273,7 @@
cursorPos = new Point(sqlCommand.get(0).length(),0);
info = SQLUtil.getTabCompletionInfo(sqlCommand, cursorPos);
assertNotNull(info);
- assertEquals(SQLUtil.TabCompletionInfo.MatchType.COLUMN_NAMES, info.getMatchType());
+ assertEquals(TabCompletionInfo.MatchType.COLUMN_NAMES, info.getMatchType());
matches = info.getPossibleMatches();
assertTrue(matches.contains("A"));
assertTrue(matches.contains("B"));
@@ -284,7 +283,7 @@
cursorPos = new Point(sqlCommand.get(0).length(),0);
info = SQLUtil.getTabCompletionInfo(sqlCommand, cursorPos);
assertNotNull(info);
- assertEquals(SQLUtil.TabCompletionInfo.MatchType.SQL_KEYWORD, info.getMatchType());
+ assertEquals(TabCompletionInfo.MatchType.SQL_KEYWORD, info.getMatchType());
matches = info.getPossibleMatches();
assertTrue(matches.contains("AND"));
assertTrue(matches.contains("OR"));
@@ -323,9 +322,9 @@
public void testUpdateTabCompletion() {
List<String> sqlCommand = Arrays.asList(new String[]{"UPDATE A"});
Point cursorPos = new Point(sqlCommand.get(0).length(),0);
- SQLUtil.TabCompletionInfo info = SQLUtil.getTabCompletionInfo(sqlCommand, cursorPos);
+ TabCompletionInfo info = SQLUtil.getTabCompletionInfo(sqlCommand, cursorPos);
assertNotNull(info);
- assertEquals(SQLUtil.TabCompletionInfo.MatchType.TABLE_NAMES, info.getMatchType());
+ assertEquals(TabCompletionInfo.MatchType.TABLE_NAMES, info.getMatchType());
List<String> matches = info.getPossibleMatches();
assertEquals(0, matches.size());
assertEquals("A", info.getStart());
@@ -334,7 +333,7 @@
cursorPos = new Point(sqlCommand.get(0).length(),0);
info = SQLUtil.getTabCompletionInfo(sqlCommand, cursorPos);
assertNotNull(info);
- assertEquals(SQLUtil.TabCompletionInfo.MatchType.SQL_KEYWORD, info.getMatchType());
+ assertEquals(TabCompletionInfo.MatchType.SQL_KEYWORD, info.getMatchType());
matches = info.getPossibleMatches();
assertEquals(1, matches.size());
assertEquals("SET", matches.get(0));
@@ -344,20 +343,21 @@
cursorPos = new Point(sqlCommand.get(0).length(),0);
info = SQLUtil.getTabCompletionInfo(sqlCommand, cursorPos);
assertNotNull(info);
- assertEquals(SQLUtil.TabCompletionInfo.MatchType.COLUMN_NAMES, info.getMatchType());
+ assertEquals(TabCompletionInfo.MatchType.COLUMN_NAMES, info.getMatchType());
matches = info.getPossibleMatches();
assertEquals(1, matches.size());
assertEquals("A", matches.get(0));
assertEquals("", info.getStart());
}
- public void testTabCompletionInfoDESC() {
+/* public void testTabCompletionInfoDESC() {
List<String> sqlCommand = Arrays.asList(new String[]{"DESC "});
Point cursorPos = new Point(sqlCommand.get(0).length(),0);
- SQLUtil.TabCompletionInfo info = SQLUtil.getTabCompletionInfo(sqlCommand, cursorPos);
+ TabCompletionInfo info = SQLUtil.getTabCompletionInfo(sqlCommand, cursorPos);
assertNotNull(info);
- assertEquals(SQLUtil.TabCompletionInfo.MatchType.TABLE_NAMES, info.getMatchType());
+ assertEquals(TabCompletionInfo.MatchType.TABLE_NAMES, info.getMatchType());
List<String> matches = info.getPossibleMatches();
assertEquals(0, matches.size());
}
+*/
}
|