The Unified and Autonomous Development Platform
midwork
robin shinee36b69b25cff
diff --git a/commons.antlr/src/main/java/com/pmease/commons/antlr/codeassist/SurroundingAware.java b/commons.antlr/src/main/java/com/pmease/commons/antlr/codeassist/SurroundingAware.javaindex b59c025320..0f5a7325e4 100644--- a/commons.antlr/src/main/java/com/pmease/commons/antlr/codeassist/SurroundingAware.java+++ b/commons.antlr/src/main/java/com/pmease/commons/antlr/codeassist/SurroundingAware.java@@ -18,11 +18,14 @@ public abstract class SurroundingAware {}public List<InputSuggestion> suggest(Node elementNode, String matchWith) {- if (matchWith.startsWith(prefix))- matchWith = matchWith.substring(prefix.length());- matchWith = matchWith.trim();+ String surroundlessMatchWith = matchWith;+ if (surroundlessMatchWith.startsWith(prefix))+ surroundlessMatchWith = surroundlessMatchWith.substring(prefix.length());+ if (surroundlessMatchWith.endsWith(suffix))+ surroundlessMatchWith = surroundlessMatchWith.substring(0, surroundlessMatchWith.length()-suffix.length());+ surroundlessMatchWith = surroundlessMatchWith.trim();- List<InputSuggestion> suggestions = match(matchWith);+ List<InputSuggestion> suggestions = match(surroundlessMatchWith);List<InputSuggestion> checkedSuggestions = new ArrayList<>();boolean matchFound = false;@@ -39,12 +42,13 @@ public abstract class SurroundingAware {} else {checkedSuggestions.add(suggestion);}- if (suggestion.getContent().equals(matchWith))+ if (suggestion.getContent().equals(surroundlessMatchWith))matchFound = true;}- if (!matchFound && !elementNode.getSpec().matches(codeAssist.lex(matchWith))) {- String surroundedMatchWith = prefix + matchWith + suffix;- if (elementNode.getSpec().matches(codeAssist.lex(surroundedMatchWith))) {+ if (!matchFound && !elementNode.getSpec().matches(codeAssist.lex(surroundlessMatchWith))) {+ String surroundedMatchWith = prefix + surroundlessMatchWith + suffix;+ if (!surroundedMatchWith.equals(matchWith)+ && elementNode.getSpec().matches(codeAssist.lex(surroundedMatchWith))) {checkedSuggestions.add(new InputSuggestion(surroundedMatchWith,surroundedMatchWith.length(), surroundedMatchWith));}@@ -52,5 +56,5 @@ public abstract class SurroundingAware {return checkedSuggestions;}- protected abstract List<InputSuggestion> match(String matchWith);+ protected abstract List<InputSuggestion> match(String surroundlessMatchWith);}diff --git a/commons.antlr/src/test/java/com/pmease/commons/antlr/codeassist/test/CodeAssistTest3.java b/commons.antlr/src/test/java/com/pmease/commons/antlr/codeassist/test/CodeAssistTest3.javaindex 57991a01c7..466224cd6d 100644--- a/commons.antlr/src/test/java/com/pmease/commons/antlr/codeassist/test/CodeAssistTest3.java+++ b/commons.antlr/src/test/java/com/pmease/commons/antlr/codeassist/test/CodeAssistTest3.java@@ -56,6 +56,7 @@ public class CodeAssistTest3 {public void test() {List<InputSuggestion> suggestions;+ /*suggestions = codeAssist.suggest(new InputStatus(""), "query");assertEquals(2, suggestions.size());assertEquals("title::6", suggestions.get(0).toString());@@ -64,7 +65,15 @@ public class CodeAssistTest3 {suggestions = codeAssist.suggest(new InputStatus("title: hello world"), "query");assertEquals(1, suggestions.size());assertEquals("title: \"hello world\":20", suggestions.get(0).toString());+ */+ suggestions = codeAssist.suggest(new InputStatus("author: dustin"), "query");+ System.out.println(suggestions);+ assertEquals(2, suggestions.size());+ assertEquals("title: \"hello world\"title::26", suggestions.get(0).toString());+ assertEquals("title: \"hello world\"author::27", suggestions.get(1).toString());++ /*suggestions = codeAssist.suggest(new InputStatus("title: hello"), "query");assertEquals(2, suggestions.size());assertEquals("title: hello title::19", suggestions.get(0).toString());@@ -75,6 +84,7 @@ public class CodeAssistTest3 {assertEquals("title: hello author:\"robin shen\":32", suggestions.get(0).toString());assertEquals("title: hello author:\"steve luo\":31", suggestions.get(1).toString());assertEquals("title: hello author:justin:26", suggestions.get(2).toString());+ */}}