The Unified and Autonomous Development Platform
midwork
robin shine857de3c6d2d9
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 fb061dc68a..bf1a065ea4 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@@ -39,7 +39,7 @@ public abstract class CodeAssist implements Serializable {public CodeAssist(Grammar grammar) {this.grammar = grammar;}-+/*** Code assist constructor* @param lexerClass@@ -64,6 +64,22 @@ public abstract class CodeAssist implements Serializable {this(new Grammar(lexerClass, grammarFiles, tokenFile));}+ public List<String> getHints(InputStatus inputStatus, String ruleName) {+ RuleSpec rule = Preconditions.checkNotNull(grammar.getRule(ruleName));+ List<Token> tokens = grammar.lex(inputStatus.getContentBeforeCaret());+ EarleyParser parser = new EarleyParser(rule, tokens);++ List<String> hints = new ArrayList<>();+ for (Chart chart: getTerminatingCharts(parser)) {+ String matchWith = getMatchWith(chart, inputStatus);+ for (List<ParentedElement> expectChain: getExpectChains(chart)) {+ for (ParentedElement element: expectChain)+ hints.addAll(getHints(element, matchWith));+ }+ }+ return hints;+ }+public List<InputCompletion> suggest(InputStatus inputStatus, String ruleName, int count) {RuleSpec rule = Preconditions.checkNotNull(grammar.getRule(ruleName));@@ -82,23 +98,19 @@ public abstract class CodeAssist implements Serializable {*/Map<String, List<ElementCompletion>> grouped = new LinkedHashMap<>();for (ElementCompletion elementCompletion: suggest(rule, inputStatus, count)) {- if (elementCompletion.getReplaceContent().length() == 0) { // if this is input hint- inputCompletions.add(new InputCompletion(elementCompletion));- } else {- /*- * key will be the new input (without considering mandatories of course), and we use- * this to group suggestions to facilitate mandatories calculation and exclusion- * logic- */- String key = inputContent.substring(0, elementCompletion.getReplaceBegin())- + elementCompletion.getReplaceContent() + inputContent.substring(elementCompletion.getReplaceEnd());- List<ElementCompletion> value = grouped.get(key);- if (value == null) {- value = new ArrayList<>();- grouped.put(key, value);- }- value.add(elementCompletion);+ /*+ * key will be the new input (without considering mandatories of course), and we use+ * this to group suggestions to facilitate mandatories calculation and exclusion+ * logic+ */+ String key = inputContent.substring(0, elementCompletion.getReplaceBegin())+ + elementCompletion.getReplaceContent() + inputContent.substring(elementCompletion.getReplaceEnd());+ List<ElementCompletion> value = grouped.get(key);+ if (value == null) {+ value = new ArrayList<>();+ grouped.put(key, value);}+ value.add(elementCompletion);}for (Map.Entry<String, List<ElementCompletion>> entry: grouped.entrySet()) {@@ -187,14 +199,11 @@ public abstract class CodeAssist implements Serializable {*/Set<String> suggestedContents = Sets.newHashSet(inputStatus.getContent());for (Iterator<InputCompletion> it = inputCompletions.iterator(); it.hasNext();) {- InputCompletion completion = it.next();- if (completion.getReplaceContent().length() != 0) { // remove non-hint duplicate suggestions- String content = completion.complete(inputStatus).getContent();- if (suggestedContents.contains(content))- it.remove();- else- suggestedContents.add(content);- }+ String content = it.next().complete(inputStatus).getContent();+ if (suggestedContents.contains(content))+ it.remove();+ else+ suggestedContents.add(content);}return inputCompletions;}@@ -234,19 +243,10 @@ public abstract class CodeAssist implements Serializable {}}- private List<ElementSuggestion> suggest(EarleyParser parser, Chart chart, InputStatus inputStatus, int count) {- List<ElementSuggestion> suggestions = new ArrayList<>();+ private List<List<ParentedElement>> getExpectChains(Chart chart) {int position = chart.getPosition();- String matchWith;- Token token = chart.getOriginatingToken();- if (token != null) {- int endCharIndex = token.getStopIndex()+1;- matchWith = inputStatus.getContent().substring(endCharIndex, inputStatus.getCaret());- } else {- matchWith = inputStatus.getContentBeforeCaret();- }- matchWith = StringUtils.trimStart(matchWith);-+ EarleyParser parser = chart.getParser();+ List<List<ParentedElement>> expectChains = new ArrayList<>();for (State stateExpectingTerminal: chart.getStatesExpectingTerminal()) {List<Element> elements = new ArrayList<>(stateExpectingTerminal.getElements());elements.add(new Element(parser, stateExpectingTerminal.getExpectedElementSpec(), 0, null));@@ -266,10 +266,10 @@ public abstract class CodeAssist implements Serializable {if (stateAssumeCompleted.getRuleSpec().getName().equals(parser.getRule().getName())&& stateAssumeCompleted.getOriginPosition() == 0) {Element rootElement = new Element(parser, null, position, stateAssumeCompleted);- List<ParentedElement> expectedElements = new ArrayList<>();+ List<ParentedElement> expectChain = new ArrayList<>();ParentedElement elementExpectingTerminal = getElementExpectingTerminal(null, rootElement);- expectedElements.add(elementExpectingTerminal);+ expectChain.add(elementExpectingTerminal);/** Find out all parent elements not containing any matched tokens, and we will@@ -280,46 +280,69 @@ public abstract class CodeAssist implements Serializable {ParentedElement expectedElement = elementExpectingTerminal.getParent();while (expectedElement != null) {if (expectedElement.getState().getElements().size() == 1) {- expectedElements.add(expectedElement);+ expectChain.add(expectedElement);expectedElement = expectedElement.getParent();} else {break;}}- // go from top to down to check if there are suggestions for expected element- List<InputSuggestion> inputSuggestions = null;- for (ParentedElement element: expectedElements) {- inputSuggestions = suggest(element, matchWith, count);- if (inputSuggestions != null) {- for (Iterator<InputSuggestion> it = inputSuggestions.iterator(); it.hasNext();) {- InputSuggestion suggestion = it.next();- if (suggestion.getContent().length() != 0 && suggestion.getContent().equals(matchWith))- it.remove();- }- if (!inputSuggestions.isEmpty())- suggestions.add(new ElementSuggestion(element, matchWith, inputSuggestions));- break;- }+ expectChains.add(expectChain);+ }+ }+ }+ return expectChains;+ }++ private String getMatchWith(Chart chart, InputStatus inputStatus) {+ String matchWith;+ Token token = chart.getOriginatingToken();+ if (token != null) {+ int endCharIndex = token.getStopIndex()+1;+ matchWith = inputStatus.getContent().substring(endCharIndex, inputStatus.getCaret());+ } else {+ matchWith = inputStatus.getContentBeforeCaret();+ }+ return StringUtils.trimStart(matchWith);+ }++ private List<ElementSuggestion> suggest(Chart chart, InputStatus inputStatus, int count) {+ List<ElementSuggestion> suggestions = new ArrayList<>();+ String matchWith = getMatchWith(chart, inputStatus);++ for (List<ParentedElement> expectChain: getExpectChains(chart)) {+ // goes through the expect chain to check if there are suggestions for expected element+ List<InputSuggestion> inputSuggestions = null;+ for (ParentedElement element: expectChain) {+ inputSuggestions = suggest(element, matchWith, count);+ if (inputSuggestions != null) {+ for (Iterator<InputSuggestion> it = inputSuggestions.iterator(); it.hasNext();) {+ InputSuggestion suggestion = it.next();+ if (suggestion.getContent().length() != 0 && suggestion.getContent().equals(matchWith))+ it.remove();}-- // no suggestions, let's see if we can provide some default suggestions- if (inputSuggestions == null && elementExpectingTerminal.getSpec() instanceof TokenElementSpec) {- inputSuggestions = new ArrayList<>();- TokenElementSpec spec = (TokenElementSpec) elementExpectingTerminal.getSpec();- for (String leadingLiteral: spec.getLeadingLiterals()) {- if (leadingLiteral.startsWith(matchWith) && leadingLiteral.length()>matchWith.length()) {- List<Token> tokens = grammar.lex(leadingLiteral);- boolean complete = tokens.size() == 1 && tokens.get(0).getType() == spec.getTokenType();- InputSuggestion suggestion = wrapAsSuggestion(elementExpectingTerminal, leadingLiteral, complete);- if (suggestion != null)- inputSuggestions.add(suggestion);- }- }- if (!inputSuggestions.isEmpty())- suggestions.add(new ElementSuggestion(elementExpectingTerminal, matchWith, inputSuggestions));+ if (!inputSuggestions.isEmpty())+ suggestions.add(new ElementSuggestion(element, matchWith, inputSuggestions));+ break;+ }+ }++ ParentedElement elementExpectingTerminal = expectChain.get(0);+ // no suggestions, let's see if we can provide some default suggestions+ if (inputSuggestions == null && elementExpectingTerminal.getSpec() instanceof TokenElementSpec) {+ inputSuggestions = new ArrayList<>();+ TokenElementSpec spec = (TokenElementSpec) elementExpectingTerminal.getSpec();+ for (String leadingLiteral: spec.getLeadingLiterals()) {+ if (leadingLiteral.startsWith(matchWith) && leadingLiteral.length()>matchWith.length()) {+ List<Token> tokens = grammar.lex(leadingLiteral);+ boolean complete = tokens.size() == 1 && tokens.get(0).getType() == spec.getTokenType();+ InputSuggestion suggestion = wrapAsSuggestion(elementExpectingTerminal, leadingLiteral, complete);+ if (suggestion != null)+ inputSuggestions.add(suggestion);}}+ if (!inputSuggestions.isEmpty())+ suggestions.add(new ElementSuggestion(elementExpectingTerminal, matchWith, inputSuggestions));}}@@ -355,18 +378,11 @@ public abstract class CodeAssist implements Serializable {return suggestions;}- private List<ElementCompletion> suggest(RuleSpec spec, InputStatus inputStatus, int count) {- List<ElementCompletion> completions = new ArrayList<>();-- List<ElementSuggestion> suggestions = new ArrayList<>();+ private List<Chart> getTerminatingCharts(EarleyParser parser) {+ List<Chart> terminatingCharts = new ArrayList<>();- List<Token> tokens = grammar.lex(inputStatus.getContentBeforeCaret());- EarleyParser parser = new EarleyParser(spec, tokens);-- if (parser.getCharts().size() >= 1) {- Chart lastState = parser.getCharts().get(parser.getCharts().size()-1);- suggestions.addAll(suggest(parser, lastState, inputStatus, count));- }+ if (parser.getCharts().size() >= 1)+ terminatingCharts.add(parser.getCharts().get(parser.getCharts().size()-1));/** do another match by not considering the last matched token. This is useful@@ -380,11 +396,23 @@ public abstract class CodeAssist implements Serializable {* if user input value containing spaces without surrounding quotes, we* suggest the user to quote the value.*/- if (parser.getCharts().size() >= 2) {- Chart stateBeforeLast = parser.getCharts().get(parser.getCharts().size()-2);- suggestions.addAll(suggest(parser, stateBeforeLast, inputStatus, count));- }+ if (parser.getCharts().size() >= 2)+ terminatingCharts.add(parser.getCharts().get(parser.getCharts().size()-2));++ return terminatingCharts;+ }++ private List<ElementCompletion> suggest(RuleSpec spec, InputStatus inputStatus, int count) {+ List<ElementCompletion> completions = new ArrayList<>();++ List<ElementSuggestion> suggestions = new ArrayList<>();+ List<Token> tokens = grammar.lex(inputStatus.getContentBeforeCaret());+ EarleyParser parser = new EarleyParser(spec, tokens);++ for (Chart chart: getTerminatingCharts(parser))+ suggestions.addAll(suggest(chart, inputStatus, count));+String inputContent = inputStatus.getContent();for (ElementSuggestion suggestion: suggestions) {int replaceBegin = inputStatus.getCaret() - suggestion.getMatchWith().length();@@ -523,6 +551,10 @@ public abstract class CodeAssist implements Serializable {*/@Nullableprotected abstract List<InputSuggestion> suggest(ParentedElement expectedElement, String matchWith, int count);++ protected List<String> getHints(ParentedElement expectedElement, String matchWith) {+ return new ArrayList<>();+ }/*** Wrap specified literal of specified terminal element as suggestion.diff --git a/commons.antlr/src/main/java/com/pmease/commons/antlr/codeassist/InputSuggestion.java b/commons.antlr/src/main/java/com/pmease/commons/antlr/codeassist/InputSuggestion.javaindex adc5c2a278..43da66c5f1 100644--- a/commons.antlr/src/main/java/com/pmease/commons/antlr/codeassist/InputSuggestion.java+++ b/commons.antlr/src/main/java/com/pmease/commons/antlr/codeassist/InputSuggestion.java@@ -64,8 +64,4 @@ public class InputSuggestion extends InputStatus {return highlight;}- public static InputSuggestion hint(String hint) {- return new InputSuggestion("", -1, false, hint, null);- }-}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 654d3545d4..e42ddf3f0e 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@@ -48,44 +48,33 @@ public abstract class SurroundingAware {if (suggestions != null) {List<InputSuggestion> checkedSuggestions = new ArrayList<>();- boolean matchWithIncluded = false;- boolean hasNonHintSuggestions = false;for (InputSuggestion suggestion: suggestions) {String content = suggestion.getContent();- if (content.length() != 0) { // process non-hint suggestions- int caret = suggestion.getCaret();- if (!matches(spec, content)) {- content = prefix + content + suffix;- Highlight highlight = suggestion.getHighlight();- if (caret != -1)- caret += prefix.length();- if (highlight != null)- highlight = new Highlight(highlight.getFrom()+prefix.length(), highlight.getTo()+prefix.length());- checkedSuggestions.add(new InputSuggestion(content, caret, true, suggestion.getDescription(), highlight));- } else {- checkedSuggestions.add(suggestion);- }- if (suggestion.getContent().equals(matchWith))- matchWithIncluded = true;- hasNonHintSuggestions = true;+ int caret = suggestion.getCaret();+ if (!matches(spec, content)) {+ content = prefix + content + suffix;+ Highlight highlight = suggestion.getHighlight();+ if (caret != -1)+ caret += prefix.length();+ if (highlight != null)+ highlight = new Highlight(highlight.getFrom()+prefix.length(), highlight.getTo()+prefix.length());+ checkedSuggestions.add(new InputSuggestion(content, caret, true, suggestion.getDescription(), highlight));} else {checkedSuggestions.add(suggestion);}}- if (!hasNonHintSuggestions) {- /*- * if matchWith does not appear in suggestion list, we check to see if it should be surrounded.- * For instance, you may have a rule requiring that value containing spaces should be quoted,- * in this case, below code will suggest you to quote the value if it contains spaces as- * otherwise it will fail the match below- */- if (!matchWithIncluded && !matches(spec, matchWith)) {- matchWith = prefix + matchWith + suffix;- if (matches(spec, matchWith)) {- Highlight highlight = new Highlight(1, matchWith.length()-1);- checkedSuggestions.add(new InputSuggestion(matchWith, getSurroundingDescription(), highlight));- }+ /*+ * Check to see if the matchWith should be surrounded and return as a suggestion if no other+ * suggestions. For instance, you may have a rule requiring that value containing spaces+ * should be quoted, in this case, below code will suggest you to quote the value if it+ * contains spaces as otherwise it will fail the match below+ */+ if (checkedSuggestions.isEmpty() && !matches(spec, matchWith)) {+ matchWith = prefix + matchWith + suffix;+ if (matches(spec, matchWith)) {+ Highlight highlight = new Highlight(1, matchWith.length()-1);+ checkedSuggestions.add(new InputSuggestion(matchWith, getSurroundingDescription(), highlight));}}return checkedSuggestions;diff --git a/commons.antlr/src/main/java/com/pmease/commons/antlr/parser/Chart.java b/commons.antlr/src/main/java/com/pmease/commons/antlr/parser/Chart.javaindex bbd6b86532..74704a4398 100644--- a/commons.antlr/src/main/java/com/pmease/commons/antlr/parser/Chart.java+++ b/commons.antlr/src/main/java/com/pmease/commons/antlr/parser/Chart.java@@ -41,6 +41,10 @@ public class Chart {this.states = states;}+ public EarleyParser getParser() {+ return parser;+ }+/*** Get position of this chart*diff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/inputassist/ANTLRAssistBehavior.java b/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/inputassist/ANTLRAssistBehavior.javaindex 7218df301a..1984fdf24f 100644--- a/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/inputassist/ANTLRAssistBehavior.java+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/inputassist/ANTLRAssistBehavior.java@@ -68,6 +68,11 @@ public abstract class ANTLRAssistBehavior extends InputAssistBehavior {return ANTLRAssistBehavior.this.suggest(element, matchWith, count);}+ @Override+ protected List<String> getHints(ParentedElement expectedElement, String matchWith) {+ return ANTLRAssistBehavior.this.getHints(expectedElement, matchWith);+ }+@Overrideprotected InputSuggestion wrapAsSuggestion(ParentedElement expectedElement, String suggestedLiteral,boolean complete) {@@ -193,6 +198,15 @@ public abstract class ANTLRAssistBehavior extends InputAssistBehavior {protected abstract List<InputSuggestion> suggest(ParentedElement element, String matchWith, int count);+ @Override+ protected final List<String> getHints(InputStatus inputStatus) {+ return codeAssist.getHints(inputStatus, ruleName);+ }++ protected List<String> getHints(ParentedElement expectedElement, String matchWith) {+ return new ArrayList<>();+ }+@Nullableprotected InputSuggestion wrapAsSuggestion(ParentedElement expectedElement,String suggestedLiteral, boolean complete) {diff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/inputassist/AssistPanel.html b/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/inputassist/AssistPanel.htmlindex 0b1021e4c9..d086c74f49 100644--- a/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/inputassist/AssistPanel.html+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/inputassist/AssistPanel.html@@ -13,8 +13,8 @@</tr></table></div>- <ul class="hint list-unstyled">- <li wicket:id="contextHints"></li>+ <ul class="help list-unstyled">+ <li wicket:id="hints"></li><li class="completion"></li></ul></div>diff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/inputassist/AssistPanel.java b/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/inputassist/AssistPanel.javaindex 890386ed52..f8f56918b6 100644--- a/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/inputassist/AssistPanel.java+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/inputassist/AssistPanel.java@@ -27,16 +27,19 @@ class AssistPanel extends Panel {private List<InputCompletion> suggestions;+ private List<String> hints;+private RepeatingView suggestionsView;private int page = 1;- public AssistPanel(String id, InputAssistBehavior assistBehavior,- InputStatus inputStatus, List<InputCompletion> suggestions) {+ public AssistPanel(String id, InputAssistBehavior assistBehavior, InputStatus inputStatus,+ List<InputCompletion> suggestions, List<String> hints) {super(id);this.assistBehavior = assistBehavior;this.inputStatus = inputStatus;this.suggestions = suggestions;+ this.hints = hints;}@Override@@ -45,14 +48,13 @@ class AssistPanel extends Panel {suggestionsView = new RepeatingView("suggestions");add(suggestionsView);- RepeatingView contextHintsView = new RepeatingView("contextHints");- add(contextHintsView);- for (InputCompletion suggestion: suggestions) {- if (suggestion.getReplaceContent().length() != 0)- suggestionsView.add(newSuggestionItem(suggestionsView.newChildId(), suggestion));- else if (suggestion.getDescription() != null)- contextHintsView.add(new Label(contextHintsView.newChildId(), suggestion.getDescription()));- }+ for (InputCompletion suggestion: suggestions)+ suggestionsView.add(newSuggestionItem(suggestionsView.newChildId(), suggestion));++ RepeatingView hintsView = new RepeatingView("hints");+ add(hintsView);+ for (String hint: hints)+ hintsView.add(new Label(hintsView.newChildId(), hint));add(new AbstractDefaultAjaxBehavior() {diff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/inputassist/InputAssistBehavior.java b/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/inputassist/InputAssistBehavior.javaindex 6cdb434f62..660adce816 100644--- a/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/inputassist/InputAssistBehavior.java+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/inputassist/InputAssistBehavior.java@@ -159,7 +159,8 @@ public abstract class InputAssistBehavior extends AbstractDefaultAjaxBehavior {@Overrideprotected Component newContent(String id) {- return new AssistPanel(id, InputAssistBehavior.this, inputStatus, suggestions);+ return new AssistPanel(id, InputAssistBehavior.this, inputStatus,+ suggestions, getHints(inputStatus));}@Override@@ -174,7 +175,8 @@ public abstract class InputAssistBehavior extends AbstractDefaultAjaxBehavior {target.appendJavaScript(script);} else {Component content = dropdown.getContent();- Component newContent = new AssistPanel(content.getId(), InputAssistBehavior.this, inputStatus, suggestions);+ Component newContent = new AssistPanel(content.getId(), InputAssistBehavior.this,+ inputStatus, suggestions, getHints(inputStatus));content.replaceWith(newContent);target.add(newContent);@@ -226,8 +228,8 @@ public abstract class InputAssistBehavior extends AbstractDefaultAjaxBehavior {protected abstract List<InputCompletion> getSuggestions(InputStatus inputStatus, int count);- protected String getHelp(InputStatus inputStatus) {- return null;+ protected List<String> getHints(InputStatus inputStatus) {+ return new ArrayList<>();}protected abstract List<InputError> getErrors(String inputContent);diff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/inputassist/input-assist.css b/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/inputassist/input-assist.cssindex 2bcd5396f6..df99d3ccb9 100644--- a/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/inputassist/input-assist.css+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/inputassist/input-assist.css@@ -29,7 +29,7 @@font-family: monospace;font-size: 13px;}-.input-assist .hint {+.input-assist .help {margin-top: 8px;margin-bottom: 0;background: #F0F0F0;diff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/inputassist/input-assist.js b/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/inputassist/input-assist.jsindex 36a0412bda..c6e4985739 100644--- a/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/inputassist/input-assist.js+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/inputassist/input-assist.js@@ -157,9 +157,9 @@ pmease.commons.inputassist = {updateHelp: function($dropdown) {if ($dropdown.find("tr.active").length != 0) {- $dropdown.find(".hint>.completion").empty().append("Press 'enter' to complete selected item");+ $dropdown.find(".help>.completion").empty().append("Press 'enter' to complete selected item");} else {- $dropdown.find(".hint>.completion").empty().append("Press 'tab' to complete first item");+ $dropdown.find(".help>.completion").empty().append("Press 'tab' to complete first item");}}}\ No newline at end of filediff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/commit/QueryAssistBehavior.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/commit/QueryAssistBehavior.javaindex 41c8765305..e9f992fee3 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/commit/QueryAssistBehavior.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/commit/QueryAssistBehavior.java@@ -47,9 +47,9 @@ public class QueryAssistBehavior extends ANTLRAssistBehavior {}@Override- protected List<InputSuggestion> suggest(final ParentedElement element, String matchWith, final int count) {- if (element.getSpec() instanceof LexerRuleRefElementSpec) {- LexerRuleRefElementSpec spec = (LexerRuleRefElementSpec) element.getSpec();+ protected List<InputSuggestion> suggest(final ParentedElement expectedElement, String matchWith, final int count) {+ if (expectedElement.getSpec() instanceof LexerRuleRefElementSpec) {+ LexerRuleRefElementSpec spec = (LexerRuleRefElementSpec) expectedElement.getSpec();if (spec.getRuleName().equals("Value")) {return new SurroundingAware(codeAssist.getGrammar(), "(", ")") {@@ -58,7 +58,7 @@ public class QueryAssistBehavior extends ANTLRAssistBehavior {matchWith = matchWith.toLowerCase();int numSuggestions = 0;List<InputSuggestion> suggestions = new ArrayList<>();- int tokenType = element.getRoot().getLastMatchedToken().getType();+ int tokenType = expectedElement.getRoot().getLastMatchedToken().getType();if (tokenType == CommitQueryParser.BRANCH) {for (String value: repoModel.getObject().getBranches()) {int index = value.toLowerCase().indexOf(matchWith);@@ -77,7 +77,6 @@ public class QueryAssistBehavior extends ANTLRAssistBehavior {}} else if (tokenType == CommitQueryParser.AUTHOR|| tokenType == CommitQueryParser.COMMITTER) {- suggestions.add(InputSuggestion.hint("Use * to match any string in name/email"));Map<String, Highlight> suggestedInputs = new LinkedHashMap<>();AuxiliaryManager auxiliaryManager = GitPlex.getInstance(AuxiliaryManager.class);List<NameAndEmail> contributors = auxiliaryManager.getContributors(repoModel.getObject());@@ -106,7 +105,6 @@ public class QueryAssistBehavior extends ANTLRAssistBehavior {suggestions.add(new InputSuggestion(dateExample));}} else if (tokenType == CommitQueryParser.PATH) {- suggestions.add(InputSuggestion.hint("Use * to match any string in path"));List<WildcardApplied> allApplied = new ArrayList<>();AuxiliaryManager auxiliaryManager = GitPlex.getInstance(AuxiliaryManager.class);for (String path: auxiliaryManager.getFiles(repoModel.getObject())) {@@ -151,12 +149,33 @@ public class QueryAssistBehavior extends ANTLRAssistBehavior {return suggestions;}- }.suggest(element.getSpec(), matchWith);+ }.suggest(expectedElement.getSpec(), matchWith);}}return null;}+ @Override+ protected List<String> getHints(ParentedElement expectedElement, String matchWith) {+ List<String> hints = new ArrayList<>();+ if (expectedElement.getSpec() instanceof LexerRuleRefElementSpec) {+ LexerRuleRefElementSpec spec = (LexerRuleRefElementSpec) expectedElement.getSpec();+ if (spec.getRuleName().equals("Value")) {+ int tokenType = expectedElement.getRoot().getLastMatchedToken().getType();+ if (tokenType == CommitQueryParser.COMMITTER) {+ hints.add("Use * to match any part of committer");+ } else if (tokenType == CommitQueryParser.AUTHOR) {+ hints.add("Use * to match any part of author");+ } else if (tokenType == CommitQueryParser.PATH) {+ hints.add("Use * to match any part of path");+ } else if (tokenType == CommitQueryParser.MESSAGE) {+ hints.add("Use * to match any part of message");+ }+ }+ }+ return hints;+ }+@Overrideprotected InputSuggestion wrapAsSuggestion(ParentedElement expectedElement,String suggestedLiteral, boolean complete) {