The Unified and Autonomous Development Platform
midwork
robin shine3d91e1815162
diff --git a/commons.antlr/src/main/java/com/pmease/commons/antlr/codeassist/AlternativeSpec.java b/commons.antlr/src/main/java/com/pmease/commons/antlr/codeassist/AlternativeSpec.javaindex 87694be3ef..510c740cd6 100644--- a/commons.antlr/src/main/java/com/pmease/commons/antlr/codeassist/AlternativeSpec.java+++ b/commons.antlr/src/main/java/com/pmease/commons/antlr/codeassist/AlternativeSpec.java@@ -31,24 +31,31 @@ public class AlternativeSpec extends Spec {}@Override- public SpecMatch match(AssistStream stream, Node parent, Node previous,+ public List<TokenNode> match(AssistStream stream, Node parent, Node previous,Map<String, Integer> checkedIndexes) {parent = new Node(this, parent, previous);List<TokenNode> paths = new ArrayList<>();+ int index = stream.getIndex();for (ElementSpec elementSpec: elements) {if (!paths.isEmpty())previous = paths.get(paths.size()-1);elseprevious = parent;- SpecMatch elementMatch = elementSpec.match(stream, parent, previous,- new HashMap<>(checkedIndexes));-- if (!elementMatch.getPaths().isEmpty())- paths = elementMatch.getPaths();- if (!elementMatch.isMatched())- return new SpecMatch(paths, false);+ List<TokenNode> elementPaths = elementSpec.match(stream, parent, previous, new HashMap<>(checkedIndexes));+ if (elementPaths == null) {+ stream.setIndex(index);+ return null;+ } else if (elementPaths.isEmpty()) {+ if (stream.isEof())+ return paths;+ } else {+ if (stream.isEof())+ return elementPaths;+ else+ paths = elementPaths;+ }}- return new SpecMatch(paths, true);+ return paths;}@Overridediff --git a/commons.antlr/src/main/java/com/pmease/commons/antlr/codeassist/AnyTokenElementSpec.java b/commons.antlr/src/main/java/com/pmease/commons/antlr/codeassist/AnyTokenElementSpec.javaindex 064af1871a..13720ff79a 100644--- a/commons.antlr/src/main/java/com/pmease/commons/antlr/codeassist/AnyTokenElementSpec.java+++ b/commons.antlr/src/main/java/com/pmease/commons/antlr/codeassist/AnyTokenElementSpec.java@@ -29,20 +29,20 @@ public class AnyTokenElementSpec extends ElementSpec {}@Override- protected SpecMatch matchOnce(AssistStream stream,+ public List<TokenNode> matchOnce(AssistStream stream,Node parent, Node previous, Map<String, Integer> checkedIndexes) {if (stream.isEof()) {- return new SpecMatch(new ArrayList<TokenNode>(), false);+ return null;} else {Token token = stream.getCurrentToken();stream.increaseIndex();TokenNode tokenNode = new TokenNode(this, parent, previous, token);- return new SpecMatch(Lists.newArrayList(tokenNode), true);+ return Lists.newArrayList(tokenNode);}}@Override- public String toString() {+ protected String asString() {return "any";}diff --git a/commons.antlr/src/main/java/com/pmease/commons/antlr/codeassist/CodeAssist.java b/commons.antlr/src/main/java/com/pmease/commons/antlr/codeassist/CodeAssist.javaindex 8b9a6dfc70..53f8f0044a 100644--- a/commons.antlr/src/main/java/com/pmease/commons/antlr/codeassist/CodeAssist.java+++ b/commons.antlr/src/main/java/com/pmease/commons/antlr/codeassist/CodeAssist.java@@ -512,14 +512,14 @@ public abstract class CodeAssist implements Serializable {return inputSuggestions;}- private List<ElementSuggestion> suggest(InputStatus inputStatus, List<TokenNode> matches) {+ private List<ElementSuggestion> suggest(InputStatus inputStatus, List<TokenNode> paths) {List<ElementSuggestion> suggestions = new ArrayList<>();- for (TokenNode match: matches) {+ for (TokenNode path: paths) {String matchWith = inputStatus.getContent().substring(- match.getToken().getStopIndex()+1, inputStatus.getCaret());+ path.getToken().getStopIndex()+1, inputStatus.getCaret());matchWith = StringUtils.trimStart(matchWith);- ElementSpec matchSpec = (ElementSpec) match.getSpec();- suggestions.addAll(matchSpec.suggestNext(new ParseTree(match), match.getParent(), matchWith));+ ElementSpec matchSpec = (ElementSpec) path.getSpec();+ suggestions.addAll(matchSpec.suggestNext(new ParseTree(path), path.getParent(), matchWith));}return suggestions;}@@ -528,44 +528,45 @@ public abstract class CodeAssist implements Serializable {List<ElementReplacement> elementReplacements = new ArrayList<>();List<ElementSuggestion> elementSuggestions = new ArrayList<>();- if (stream.isEof()) {- String matchWith = StringUtils.trimStart(inputStatus.getContentBeforeCaret());- elementSuggestions.addAll(spec.suggestFirst(null, null, matchWith, new HashSet<String>()));+ List<TokenNode> paths = spec.match(stream, null, null, new HashMap<String, Integer>());+ boolean suggestFirst = false;+ if (paths == null || paths.isEmpty()) {+ // if there is not any common parts between the rule and the input+ suggestFirst = true;} else {- SpecMatch match = spec.match(stream, null, null, new HashMap<String, Integer>());- if (match.getPaths().isEmpty()) {- // if there is not any common parts between the rule and the input- String matchWith = StringUtils.trimStart(inputStatus.getContentBeforeCaret());- elementSuggestions.addAll(spec.suggestFirst(null, null, matchWith, new HashSet<String>()));+ elementSuggestions.addAll(suggest(inputStatus, paths));++ /*+ * do another match by not considering the last token. This is necessary for+ * instance for below cases:+ * 1. when the last token matches either a keyword or part of an identifier.+ * For instance, the last token can be keyword 'for', but can also match+ * identifier 'forme' if the spec allows.+ * 2. assume we have a query rule containing multiple criterias, with each+ * criteria composed of key/value pair key:value. value needs to be quoted+ * if it contains spaces. In this case, we want to achieve the effect that+ * if user input value containing spaces without surrounding quotes, we+ * suggest the user to quote the value.+ */+ int index = stream.getTokenIndex(paths.get(0).getToken());+ if (index>0) {+ List<Token> tokens = new ArrayList<>();+ for (int i=0; i<index; i++)+ tokens.add(stream.getToken(i));+ tokens.add(stream.getToken(stream.size()-1));+ paths = spec.match(new AssistStream(tokens), null, null, new HashMap<String, Integer>());+ if (paths != null && !paths.isEmpty())+ elementSuggestions.addAll(suggest(inputStatus, paths));+ else+ suggestFirst = true;} else {- elementSuggestions.addAll(suggest(inputStatus, match.getPaths()));-- /*- * do another match by not considering the last token. This is necessary for- * instance for below cases:- * 1. when the last token matches either a keyword or part of an identifier.- * For instance, the last token can be keyword 'for', but can also match- * identifier 'forme' if the spec allows.- * 2. assume we have a query rule containing multiple criterias, with each- * criteria composed of key/value pair key:value. value needs to be quoted- * if it contains spaces. In this case, we want to achieve the effect that- * if user input value containing spaces without surrounding quotes, we- * suggest the user to quote the value.- */- int index = stream.getTokenIndex(match.getPaths().get(0).getToken());- if (index>0) {- List<Token> tokens = new ArrayList<>();- for (int i=0; i<index; i++)- tokens.add(stream.getToken(i));- tokens.add(stream.getToken(stream.size()-1));- match = spec.match(new AssistStream(tokens), null, null, new HashMap<String, Integer>());- elementSuggestions.addAll(suggest(inputStatus, match.getPaths()));- } else {- String matchWith = StringUtils.trimStart(inputStatus.getContentBeforeCaret());- elementSuggestions.addAll(spec.suggestFirst(null, null, matchWith, new HashSet<String>()));- }+ suggestFirst = true;}}+ if (suggestFirst) {+ String matchWith = StringUtils.trimStart(inputStatus.getContentBeforeCaret());+ elementSuggestions.addAll(spec.suggestFirst(null, null, matchWith, new HashSet<String>()));+ }String inputContent = inputStatus.getContent();for (ElementSuggestion elementSuggestion: elementSuggestions) {@@ -581,12 +582,12 @@ public abstract class CodeAssist implements Serializable {*/if (!streamAfterReplaceStart.isEof() && streamAfterReplaceStart.getToken(0).getStartIndex() == 0) {ElementSpec elementSpec = (ElementSpec) elementSuggestion.getNode().getSpec();- if (elementSpec.matchesOnce(streamAfterReplaceStart)) {- if (streamAfterReplaceStart.getIndex() != 0) {- int lastTokenIndex = streamAfterReplaceStart.getPreviousToken().getStopIndex()+1;- if (replaceStart + lastTokenIndex > replaceEnd)- replaceEnd = replaceStart + lastTokenIndex;- }+ paths = elementSpec.matchOnce(streamAfterReplaceStart,+ null, null, new HashMap<String, Integer>());+ if (paths != null && !paths.isEmpty()) {+ int lastTokenIndex = streamAfterReplaceStart.getPreviousToken().getStopIndex()+1;+ if (replaceStart + lastTokenIndex > replaceEnd)+ replaceEnd = replaceStart + lastTokenIndex;}}diff --git a/commons.antlr/src/main/java/com/pmease/commons/antlr/codeassist/ElementSpec.java b/commons.antlr/src/main/java/com/pmease/commons/antlr/codeassist/ElementSpec.javaindex 223e265f24..3de5dbe08d 100644--- a/commons.antlr/src/main/java/com/pmease/commons/antlr/codeassist/ElementSpec.java+++ b/commons.antlr/src/main/java/com/pmease/commons/antlr/codeassist/ElementSpec.java@@ -1,7 +1,6 @@package com.pmease.commons.antlr.codeassist;import java.util.ArrayList;-import java.util.HashMap;import java.util.HashSet;import java.util.List;import java.util.Map;@@ -36,103 +35,48 @@ public abstract class ElementSpec extends Spec {return multiplicity;}- private Node getPrevious(SpecMatch match, Node currentPrevious) {- if (match.getPaths().isEmpty())- return currentPrevious;- else- return match.getPaths().get(match.getPaths().size()-1);- }-@Override- public SpecMatch match(AssistStream stream,+ public List<TokenNode> match(AssistStream stream,Node parent, Node previous, Map<String, Integer> checkedIndexes) {if (multiplicity == Multiplicity.ONE) {return matchOnce(stream, parent, previous, checkedIndexes);} else if (multiplicity == Multiplicity.ONE_OR_MORE) {- SpecMatch match = matchOnce(stream, parent, previous, checkedIndexes);- if (!match.isMatched()) {- return new SpecMatch(match.getPaths(), false);- } else if (match.getPaths().isEmpty()) {- /*- * does not consume any token of the stream but match is successful? This- * tells us the element spec does not match the stream but itself (or- * everything inside it) is optional, so we do not waste any cpu cycles- * here- */- return new SpecMatch(match.getPaths(), true);+ List<TokenNode> paths = matchOnce(stream, parent, previous, checkedIndexes);+ if (paths == null || paths.isEmpty() || stream.isEof()) {+ return paths;} else {- List<TokenNode> paths = match.getPaths();while (true) {- previous = getPrevious(match, previous);- match = matchOnce(stream, parent, previous, checkedIndexes);- if (!match.isMatched()) {- if (!match.getPaths().isEmpty()) {- /*- * we are always greedy when matching specs against stream for performance- * reason, so if there are any tokens consumed in the stream, we use those- * tokens, and consider the whole spec as not-matched although previous- * iteration matches. This false-positive is acceptable as our purpose is- * for auto-completion...- */- paths = match.getPaths();- return new SpecMatch(paths, false);- } else {- /*- * does not consume any token from stream, so we will return result of- * previous match- */- return new SpecMatch(paths, true);- }- } else if (match.getPaths().isEmpty()) {- /*- * does not consume any tokens of the stream, so further iteration will be- * meaningless, let's return result of previous match- */- return new SpecMatch(paths, true);- } else {- /*- * can still consume tokens from stream, let's continue...- */- paths = match.getPaths();- }+ previous = paths.get(paths.size()-1);+ List<TokenNode> nextPaths = matchOnce(stream, parent, previous, checkedIndexes);+ if (nextPaths == null || nextPaths.isEmpty())+ return paths;+ else if (stream.isEof())+ return nextPaths;+ else+ paths = nextPaths;}}} else if (multiplicity == Multiplicity.ZERO_OR_MORE) {List<TokenNode> paths = new ArrayList<>();while (true) {- SpecMatch match = matchOnce(stream, parent, previous, checkedIndexes);- if (!match.isMatched()) {- if (!match.getPaths().isEmpty()) {- paths = match.getPaths();- return new SpecMatch(paths, false);- } else {- return new SpecMatch(paths, true);- }- } else if (match.getPaths().isEmpty()) {- return new SpecMatch(paths, true);- } else {- paths = match.getPaths();- }- previous = getPrevious(match, previous);- }- } else {- SpecMatch match = matchOnce(stream, parent, previous, checkedIndexes);- if (!match.isMatched()) {- if (!match.getPaths().isEmpty())- return new SpecMatch(match.getPaths(), false);+ if (!paths.isEmpty())+ previous = paths.get(paths.size()-1);+ List<TokenNode> nextPaths = matchOnce(stream, parent, previous, checkedIndexes);+ if (nextPaths == null || nextPaths.isEmpty() || stream.isEof())+ return paths;else- return new SpecMatch(match.getPaths(), true);- } else {- return match;+ paths = nextPaths;}+ } else {+ List<TokenNode> paths = matchOnce(stream, parent, previous, checkedIndexes);+ if (paths != null)+ return paths;+ else+ return new ArrayList<>();}}- public boolean matchesOnce(AssistStream stream) {- return matchOnce(stream, null, null, new HashMap<String, Integer>()).isMatched();- }-- protected abstract SpecMatch matchOnce(AssistStream stream,+ public abstract List<TokenNode> matchOnce(AssistStream stream,Node parent, Node previous, Map<String, Integer> checkedIndexes);public abstract MandatoryScan scanMandatories(Set<String> checkedRules);@@ -203,5 +147,17 @@ public abstract class ElementSpec extends Spec {protected abstract List<ElementSuggestion> doSuggestFirst(@Nullable ParseTree parseTree,Node parent, String matchWith, Set<String> checkedRules);++ public final String toString() {+ if (multiplicity == Multiplicity.ONE)+ return asString();+ else if (multiplicity == Multiplicity.ONE_OR_MORE)+ return "(" + asString() + ")+";+ else if (multiplicity == Multiplicity.ZERO_OR_MORE)+ return "(" + asString() + ")*";+ else+ return "(" + asString() + ")?";+ }+ protected abstract String asString();}diff --git a/commons.antlr/src/main/java/com/pmease/commons/antlr/codeassist/EofElementSpec.java b/commons.antlr/src/main/java/com/pmease/commons/antlr/codeassist/EofElementSpec.javaindex 66b00fff4c..41f29647b1 100644--- a/commons.antlr/src/main/java/com/pmease/commons/antlr/codeassist/EofElementSpec.java+++ b/commons.antlr/src/main/java/com/pmease/commons/antlr/codeassist/EofElementSpec.java@@ -27,13 +27,13 @@ public class EofElementSpec extends TokenElementSpec {}@Override- protected SpecMatch matchOnce(AssistStream stream,+ public List<TokenNode> matchOnce(AssistStream stream,Node parent, Node previous, Map<String, Integer> checkedIndexes) {- return new SpecMatch(new ArrayList<TokenNode>(), stream.isEof());+ return new ArrayList<>();}@Override- public String toString() {+ protected String asString() {return "EOF";}diff --git a/commons.antlr/src/main/java/com/pmease/commons/antlr/codeassist/LexerRuleRefElementSpec.java b/commons.antlr/src/main/java/com/pmease/commons/antlr/codeassist/LexerRuleRefElementSpec.javaindex db9c1bfc3e..b3367c9f4b 100644--- a/commons.antlr/src/main/java/com/pmease/commons/antlr/codeassist/LexerRuleRefElementSpec.java+++ b/commons.antlr/src/main/java/com/pmease/commons/antlr/codeassist/LexerRuleRefElementSpec.java@@ -86,20 +86,20 @@ public class LexerRuleRefElementSpec extends TokenElementSpec {}@Override- protected SpecMatch matchOnce(AssistStream stream,+ public List<TokenNode> matchOnce(AssistStream stream,Node parent, Node previous, Map<String, Integer> checkedIndexes) {Token token = stream.getCurrentToken();if (token.getType() == type) {stream.increaseIndex();TokenNode tokenNode = new TokenNode(this, parent, previous, token);- return new SpecMatch(Lists.newArrayList(tokenNode), true);+ return Lists.newArrayList(tokenNode);} else {- return new SpecMatch(new ArrayList<TokenNode>(), false);+ return null;}}@Override- public String toString() {+ protected String asString() {return "lexer_rule_ref: " + ruleName;}diff --git a/commons.antlr/src/main/java/com/pmease/commons/antlr/codeassist/LiteralElementSpec.java b/commons.antlr/src/main/java/com/pmease/commons/antlr/codeassist/LiteralElementSpec.javaindex adabbbe7cd..620989b4fb 100644--- a/commons.antlr/src/main/java/com/pmease/commons/antlr/codeassist/LiteralElementSpec.java+++ b/commons.antlr/src/main/java/com/pmease/commons/antlr/codeassist/LiteralElementSpec.java@@ -44,20 +44,20 @@ public class LiteralElementSpec extends TokenElementSpec {}@Override- protected SpecMatch matchOnce(AssistStream stream, Node parent,+ public List<TokenNode> matchOnce(AssistStream stream, Node parent,Node previous, Map<String, Integer> checkedIndexes) {Token token = stream.getCurrentToken();if (token.getType() == type) {stream.increaseIndex();TokenNode tokenNode = new TokenNode(this, parent, previous, token);- return new SpecMatch(Lists.newArrayList(tokenNode), true);+ return Lists.newArrayList(tokenNode);} else {- return new SpecMatch(new ArrayList<TokenNode>(), false);+ return null;}}@Override- public String toString() {+ protected String asString() {return "literal: '" + literal + "'";}diff --git a/commons.antlr/src/main/java/com/pmease/commons/antlr/codeassist/NotTokenElementSpec.java b/commons.antlr/src/main/java/com/pmease/commons/antlr/codeassist/NotTokenElementSpec.javaindex 30083c0d69..60d85d1349 100644--- a/commons.antlr/src/main/java/com/pmease/commons/antlr/codeassist/NotTokenElementSpec.java+++ b/commons.antlr/src/main/java/com/pmease/commons/antlr/codeassist/NotTokenElementSpec.java@@ -38,24 +38,24 @@ public class NotTokenElementSpec extends ElementSpec {}@Override- protected SpecMatch matchOnce(AssistStream stream,+ public List<TokenNode> matchOnce(AssistStream stream,Node parent, Node previous, Map<String, Integer> checkedIndexes) {if (stream.isEof()) {- return new SpecMatch(new ArrayList<TokenNode>(), false);+ return null;} else {Token token = stream.getCurrentToken();if (!notTokenTypes.contains(token.getType())) {stream.increaseIndex();TokenNode tokenNode = new TokenNode(this, parent, previous, token);- return new SpecMatch(Lists.newArrayList(tokenNode), true);+ return Lists.newArrayList(tokenNode);} else {- return new SpecMatch(new ArrayList<TokenNode>(), false);+ return null;}}}@Override- public String toString() {+ protected String asString() {return "not: " + notTokenTypes;}diff --git a/commons.antlr/src/main/java/com/pmease/commons/antlr/codeassist/RuleRefElementSpec.java b/commons.antlr/src/main/java/com/pmease/commons/antlr/codeassist/RuleRefElementSpec.javaindex 1706e228cc..c92213903c 100644--- a/commons.antlr/src/main/java/com/pmease/commons/antlr/codeassist/RuleRefElementSpec.java+++ b/commons.antlr/src/main/java/com/pmease/commons/antlr/codeassist/RuleRefElementSpec.java@@ -82,11 +82,11 @@ public class RuleRefElementSpec extends ElementSpec {}@Override- protected SpecMatch matchOnce(AssistStream stream,+ public List<TokenNode> matchOnce(AssistStream stream,Node parent, Node previous, Map<String, Integer> checkedIndexes) {Integer index = checkedIndexes.get(ruleName);if (index != null && index.intValue() == stream.getIndex()) {- return new SpecMatch(new ArrayList<TokenNode>(), false);+ return null;} else {checkedIndexes.put(ruleName, stream.getIndex());parent = new Node(this, parent, previous);@@ -95,7 +95,7 @@ public class RuleRefElementSpec extends ElementSpec {}@Override- public String toString() {+ protected String asString() {return "rule_ref: " + ruleName;}diff --git a/commons.antlr/src/main/java/com/pmease/commons/antlr/codeassist/RuleSpec.java b/commons.antlr/src/main/java/com/pmease/commons/antlr/codeassist/RuleSpec.javaindex 55b0df424f..1415642d42 100644--- a/commons.antlr/src/main/java/com/pmease/commons/antlr/codeassist/RuleSpec.java+++ b/commons.antlr/src/main/java/com/pmease/commons/antlr/codeassist/RuleSpec.java@@ -41,46 +41,31 @@ public class RuleSpec extends Spec {}@Override- public SpecMatch match(AssistStream stream,+ public List<TokenNode> match(AssistStream stream,Node parent, Node previous, Map<String, Integer> checkedIndexes) {- List<TokenNode> matchedPaths = new ArrayList<>();- List<TokenNode> unmatchedPaths = new ArrayList<>();- boolean matched = false;- int maxMatchIndex = -1;- int maxUnmatchIndex = -1;+ List<TokenNode> paths = null;+ int maxIndex = -1;int index = stream.getIndex();parent = new Node(this, parent, previous);for (AlternativeSpec alternative: alternatives) {- SpecMatch match = alternative.match(stream, parent, parent, new HashMap<>(checkedIndexes));- if (match.isMatched()) {- if (stream.getIndex() > maxMatchIndex) {- maxMatchIndex = stream.getIndex();- matchedPaths = match.getPaths();- } else if (stream.getIndex() == maxMatchIndex) {- matchedPaths.addAll(match.getPaths());- }- matched = true;- } else {- if (stream.getIndex() > maxUnmatchIndex) {- maxUnmatchIndex = stream.getIndex();- unmatchedPaths = match.getPaths();- } else if (stream.getIndex() == maxUnmatchIndex) {- unmatchedPaths.addAll(match.getPaths());+ List<TokenNode> alternativePaths = alternative.match(stream, parent, parent, new HashMap<>(checkedIndexes));+ if (stream.getIndex() > maxIndex) {+ maxIndex = stream.getIndex();+ paths = alternativePaths;+ } else if (stream.getIndex() == maxIndex) {+ if (alternativePaths != null) {+ if (paths == null)+ paths = alternativePaths;+ else+ paths.addAll(alternativePaths);}}stream.setIndex(index);}- // always select the path matching most tokens in the stream- stream.setIndex(Math.max(maxMatchIndex, maxUnmatchIndex));- if (maxMatchIndex == maxUnmatchIndex) {- matchedPaths.addAll(unmatchedPaths);- return new SpecMatch(matchedPaths, matched);- } else if (maxMatchIndex > maxUnmatchIndex) {- return new SpecMatch(matchedPaths, matched);- } else {- return new SpecMatch(unmatchedPaths, matched);- }+ if (maxIndex != -1)+ stream.setIndex(maxIndex);+ return paths;}@Overridediff --git a/commons.antlr/src/main/java/com/pmease/commons/antlr/codeassist/Spec.java b/commons.antlr/src/main/java/com/pmease/commons/antlr/codeassist/Spec.javaindex dbc1525ed8..15e37d094c 100644--- a/commons.antlr/src/main/java/com/pmease/commons/antlr/codeassist/Spec.java+++ b/commons.antlr/src/main/java/com/pmease/commons/antlr/codeassist/Spec.java@@ -6,6 +6,8 @@ import java.util.List;import java.util.Map;import java.util.Set;+import javax.annotation.Nullable;+public abstract class Spec implements Serializable {private static final long serialVersionUID = 1L;@@ -25,7 +27,7 @@ public abstract class Spec implements Serializable {* true if there is an exact match between spec and stream*/public boolean matches(AssistStream stream) {- return match(stream, null, null, new HashMap<String, Integer>()).isMatched() && stream.isEof();+ return match(stream, null, null, new HashMap<String, Integer>()) != null && stream.isEof();}/**@@ -44,7 +46,8 @@ public abstract class Spec implements Serializable {* that we can have match paths even if the whole spec is not matched, and in* that case, the paths tells to which point the match goes to*/- public abstract SpecMatch match(AssistStream stream,+ @Nullable+ public abstract List<TokenNode> match(AssistStream stream,Node parent, Node previous, Map<String, Integer> checkedIndexes);public abstract List<ElementSuggestion> suggestFirst(ParseTree parseTree, Node parent,diff --git a/commons.antlr/src/main/java/com/pmease/commons/antlr/codeassist/SpecMatch.java b/commons.antlr/src/main/java/com/pmease/commons/antlr/codeassist/SpecMatch.javadeleted file mode 100644index 86b8b636a5..0000000000--- a/commons.antlr/src/main/java/com/pmease/commons/antlr/codeassist/SpecMatch.java+++ /dev/null@@ -1,47 +0,0 @@-package com.pmease.commons.antlr.codeassist;--import java.util.List;--public class SpecMatch {-- private final List<TokenNode> paths;-- private final boolean matched;-- public SpecMatch(List<TokenNode> paths, boolean matched) {- this.paths = paths;- this.matched = matched;- }-- /**- * Get different paths in this match- *- * @return- * get different match paths, each path represents an alternative match- * (full or partial) between the spec and the stream, and each of them- * represents parse tree (nodes of the parse tree can be deducted by calling- * {@link TokenNode#getPrevious()}. Also all these path point to the same token- * as those shorter paths have been discarded due to our greedy match strategy.- * A parse tree can be deducted from each path via- * {@link TokenNode#getPrevious()} Note that this list may not be empty even if- * {@link #isMatched()} return false, and in this case, the spec is only- * partially matched, and these paths represent to which point this partial- * match goes.- * Specifically if the list is empty, no tokens are consumed from the stream- */- public List<TokenNode> getPaths() {- return paths;- }-- /**- * Whether or not there is a match in above paths.- *- * @return- * true as long as one of paths above represents a full match (the whole spec- * can be matched)- */- public boolean isMatched() {- return matched;- }--}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 cf4103c1b2..ba47069ea3 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,16 @@ public class CodeAssistTest3 {public void test() {List<InputSuggestion> suggestions;+ suggestions = codeAssist.suggest(new InputStatus("title: hello author:"), "query");+ assertEquals(3, suggestions.size());+ 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());++ 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(""), "query");assertEquals(2, suggestions.size());assertEquals("title::6", suggestions.get(0).toString());@@ -64,10 +74,6 @@ public class CodeAssistTest3 {suggestions = codeAssist.suggest(new InputStatus("title:"), "query");assertEquals(0, suggestions.size());- 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");assertEquals(0, suggestions.size());@@ -88,12 +94,6 @@ public class CodeAssistTest3 {assertEquals(2, suggestions.size());assertEquals("title: hello title::19", suggestions.get(0).toString());assertEquals("title: hello author::20", suggestions.get(1).toString());-- suggestions = codeAssist.suggest(new InputStatus("title: hello author:"), "query");- assertEquals(3, suggestions.size());- 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());}}diff --git a/gitplex.product/src/test/java/gitplex/product/Test.java b/gitplex.product/src/test/java/gitplex/product/Test.javaindex 1b2d765636..b254f6cd3d 100644--- a/gitplex.product/src/test/java/gitplex/product/Test.java+++ b/gitplex.product/src/test/java/gitplex/product/Test.java@@ -1,14 +1,13 @@package gitplex.product;import java.io.IOException;-import java.util.HashMap;import java.util.List;import com.pmease.commons.antlr.codeassist.CodeAssist;+import com.pmease.commons.antlr.codeassist.InputStatus;import com.pmease.commons.antlr.codeassist.InputSuggestion;import com.pmease.commons.antlr.codeassist.Node;import com.pmease.commons.antlr.codeassist.ParseTree;-import com.pmease.commons.antlr.codeassist.SpecMatch;import com.pmease.commons.lang.extractors.java.JavaLexer;public class Test {@@ -26,8 +25,8 @@ public class Test {};- SpecMatch match = codeAssist.getRule("blockStatement").match(codeAssist.lex("a(b.c());"), null, null, new HashMap<String, Integer>());- System.out.println(match.isMatched());+ List<InputSuggestion> suggestions = codeAssist.suggest(new InputStatus("a(b.c());"), "blockStatement");+ System.out.println(suggestions);}}\ No newline at end of file