You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by ji...@apache.org on 2017/05/22 22:00:43 UTC
geode git commit: GEODE-1597: fix auto-complete when user input ends
with space
Repository: geode
Updated Branches:
refs/heads/develop b47450667 -> ae1c56f70
GEODE-1597: fix auto-complete when user input ends with space
Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/ae1c56f7
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/ae1c56f7
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/ae1c56f7
Branch: refs/heads/develop
Commit: ae1c56f7077eb807584af58c8755a74c753db442
Parents: b474506
Author: Jinmei Liao <ji...@pivotal.io>
Authored: Thu May 18 12:40:41 2017 -0700
Committer: Jinmei Liao <ji...@pivotal.io>
Committed: Mon May 22 14:59:12 2017 -0700
----------------------------------------------------------------------
.../management/internal/cli/GfshParser.java | 22 ++++++++++----------
.../cli/GfshParserAutoCompletionTest.java | 18 ++++++++++++----
.../internal/cli/GfshParserJUnitTest.java | 11 ++++++++++
3 files changed, 36 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/geode/blob/ae1c56f7/geode-core/src/main/java/org/apache/geode/management/internal/cli/GfshParser.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/GfshParser.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/GfshParser.java
index f9adeb3..288ea05 100755
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/GfshParser.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/GfshParser.java
@@ -237,17 +237,9 @@ public class GfshParser extends SimpleParser {
// initially assume we are trying to complete the last token
List<Completion> potentials = getCandidates(buffer);
- if (potentials.size() > 0) {
- if (lastTokenIsOption) {
- candidateBeginAt = buffer.length() - lastToken.length();
- } else {
- // need to return the index before the "=" sign, since later on we are going to add the
- // "=" sign to the completion candidates
- candidateBeginAt = buffer.length() - lastToken.length() - 1;
- }
- }
- // if the last token is already complete, add either space or " --" and try again
- else {
+ // if the last token is already complete (or user deliberately ends with a space denoting the
+ // last token is complete, then add either space or " --" and try again
+ if (potentials.size() == 0 || userInput.endsWith(" ")) {
candidateBeginAt = buffer.length();
// last token is an option
if (lastTokenIsOption) {
@@ -260,6 +252,14 @@ public class GfshParser extends SimpleParser {
potentials = getCandidates(buffer + " --");
lastTokenIsOption = true;
}
+ } else {
+ if (lastTokenIsOption) {
+ candidateBeginAt = buffer.length() - lastToken.length();
+ } else {
+ // need to return the index before the "=" sign, since later on we are going to add the
+ // "=" sign to the completion candidates
+ candidateBeginAt = buffer.length() - lastToken.length() - 1;
+ }
}
// manipulate the candidate strings
http://git-wip-us.apache.org/repos/asf/geode/blob/ae1c56f7/geode-core/src/test/java/org/apache/geode/management/internal/cli/GfshParserAutoCompletionTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/GfshParserAutoCompletionTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/GfshParserAutoCompletionTest.java
index 31a5ceb..a122de0 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/GfshParserAutoCompletionTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/GfshParserAutoCompletionTest.java
@@ -250,10 +250,20 @@ public class GfshParserAutoCompletionTest {
}
@Test
- public void testCompletHelp() throws Exception {
- buffer = "create region --name=test --type LO";
- cursor = parser.completeSuperAdvanced(buffer, candidates);
- System.out.println("");
+ public void testCompletWithRegionTypeWithNoSpace() throws Exception {
+ buffer = "create region --name=test --type=REPLICATE";
+ cursor = parser.completeAdvanced(buffer, candidates);
+ assertThat(candidates.size()).isEqualTo(5);
+ assertThat(getCompleted(buffer, cursor, candidates.get(0))).isEqualTo(buffer + "_HEAP_LRU");
+ }
+
+ @Test
+ public void testCompletWithRegionTypeWithSpace() throws Exception {
+ buffer = "create region --name=test --type=REPLICATE ";
+ cursor = parser.completeAdvanced(buffer, candidates);
+ assertThat(candidates.size()).isEqualTo(37);
+ assertThat(getCompleted(buffer, cursor, candidates.get(0)))
+ .isEqualTo(buffer + "--async-event-queue-id");
}
@Test
http://git-wip-us.apache.org/repos/asf/geode/blob/ae1c56f7/geode-core/src/test/java/org/apache/geode/management/internal/cli/GfshParserJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/GfshParserJUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/GfshParserJUnitTest.java
index 2fd8c2f..95d5292 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/GfshParserJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/GfshParserJUnitTest.java
@@ -61,6 +61,17 @@ public class GfshParserJUnitTest {
}
@Test
+ public void testSplitUserInputWithMixedQuotes() {
+ input = "command option='test1 \"test \" test1'";
+ tokens = GfshParser.splitUserInput(input);
+ assertThat(tokens.size()).isEqualTo(3);
+ assertThat(tokens.get(0)).isEqualTo("command");
+ assertThat(tokens.get(1)).isEqualTo("option");
+ assertThat(tokens.get(2)).isEqualTo("'test1 \"test \" test1'");
+ }
+
+
+ @Test
public void testSplitUserInputWithJ() {
input =
"start server --name=server1 --J=\"-Dgemfire.start-dev-rest-api=true\" --J='-Dgemfire.http-service-port=8080' --J='-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=30000'";