|
From: SVN by r. <sv...@ca...> - 2007-10-08 12:16:15
|
Author: rotman
Date: 2007-10-08 14:16:13 +0200 (Mon, 08 Oct 2007)
New Revision: 166
Modified:
ChangeLog
src/main/java/nl/improved/sqlclient/SQLUtil.java
src/test/java/nl/improved/sqlclient/SQLUtilTest.java
Log:
Fix tab completion for in-word keyword matches
Modified: ChangeLog
===================================================================
--- ChangeLog 2007-10-08 10:50:54 UTC (rev 165)
+++ ChangeLog 2007-10-08 12:16:13 UTC (rev 166)
@@ -1,11 +1,12 @@
0.3 (Unreleased)
* focus fix in login dialog
* Improve desc table to show primary key
- * fix to stop spooled lines being appended to each other.
+ * BUGFIX: fix to stop spooled lines being appended to each other.
* Improve tab completion for update
- * NullPointerException fix when not running from jar.
+ * BUGFIX: NullPointerException fix when not running from jar.
* Quit with ^D (on empty commandline)
- * Added tab-completion for DESC command
+ * Added tab completion for DESC command
+ * BUGFIX: fix tab completion when a "keyword" was found as part of a name.
0.2 (17-09-2007)
* Search in history (for example by entering '/query' to make the current command the last command with query in it)
Modified: src/main/java/nl/improved/sqlclient/SQLUtil.java
===================================================================
--- src/main/java/nl/improved/sqlclient/SQLUtil.java 2007-10-08 10:50:54 UTC (rev 165)
+++ src/main/java/nl/improved/sqlclient/SQLUtil.java 2007-10-08 12:16:13 UTC (rev 166)
@@ -27,13 +27,17 @@
public class SQLUtil {
/**
+ * A regular expression statement for name chars.
+ */
+ private static final String NAMING_CHAR = "(_|-|[0-9]|[A-Z])";
+ /**
* A table name regular expression statement.
*/
- private static final String TABLE = "[A-Z]+(_|-|[0-9]|[A-Z])*";
+ private static final String TABLE = "[A-Z]+"+NAMING_CHAR+"*";
/**
* A column name regular expression statement.
*/
- private static final String COLUMN = "[A-Z]+(_|-|[0-9]|[A-Z])*";
+ private static final String COLUMN = "[A-Z]+"+NAMING_CHAR+"*";
/**
* A variable (table name + columnname) regular expression statement.
*/
@@ -69,6 +73,15 @@
while (iKeywords.hasNext()) {
String keyword = iKeywords.next();
int tmpIndex = seqUpper.indexOf(keyword);
+ int tmpEndIndex = tmpIndex+keyword.length();
+
+ //Ensuring the keyword is not a in-word match
+ if (tmpIndex > 0 && seqUpper.substring(tmpIndex-1, tmpIndex).matches(NAMING_CHAR)) {
+ continue;
+ } else if (tmpIndex != -1 && tmpEndIndex < seqUpper.length() && seqUpper.substring(tmpEndIndex, tmpEndIndex+1).matches(NAMING_CHAR)) {
+ continue;
+ }
+
if (tmpIndex > maxIndex) {
maxIndex = tmpIndex;
lastKeyWord = seq.substring(maxIndex, maxIndex+keyword.length());
Modified: src/test/java/nl/improved/sqlclient/SQLUtilTest.java
===================================================================
--- src/test/java/nl/improved/sqlclient/SQLUtilTest.java 2007-10-08 10:50:54 UTC (rev 165)
+++ src/test/java/nl/improved/sqlclient/SQLUtilTest.java 2007-10-08 12:16:13 UTC (rev 166)
@@ -38,6 +38,10 @@
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));
}
public void testTabCompletionInfoBLANK() {
|