The Unified and Autonomous Development Platform
midwork
robin shine423fda348268
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 bc80557963..92d6ec067f 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@@ -4,8 +4,10 @@ import java.io.Serializable;import java.util.ArrayList;import java.util.HashSet;import java.util.Iterator;+import java.util.LinkedHashMap;import java.util.LinkedHashSet;import java.util.List;+import java.util.Map;import java.util.Set;import javax.annotation.Nullable;@@ -75,79 +77,97 @@ public abstract class CodeAssist implements Serializable {}return new ArrayList<>(hints);}++ private String appendMandatories(InputStatus inputStatus, ElementCompletion completion) {+ String inputContent = inputStatus.getContent();+ String content = inputContent.substring(0, completion.getReplaceBegin())+ + completion.getReplaceContent();+ if (completion.isComplete() && completion.getReplaceEnd() == inputStatus.getCaret()) {+ ParentedElement parentElement = completion.getExpectedElement().getParent();+ ElementSpec elementSpec = completion.getExpectedElement().getSpec();+ for (String mandatory: getMandatoriesAfter(parentElement, elementSpec)) {+ String prevContent = content;+ content += mandatory;++ if (grammar.getTokenTypeByLiteral(mandatory) != null) {+ /*+ * if mandatory can be appended without space, the last token+ * position should remain unchanged in concatenated content+ */+ List<Token> tokens = grammar.lex(content);+ if (!tokens.isEmpty()) {+ Token lastToken = tokens.get(tokens.size()-1);+ if (lastToken.getStartIndex() != content.length() - mandatory.length()+ || lastToken.getStopIndex() != content.length()-1) {+ content = prevContent + " " + mandatory;+ }+ } else {+ content = prevContent + " " + mandatory;+ }+ }+ }+ }+ return content + inputContent.substring(completion.getReplaceEnd());+ }public List<InputCompletion> suggest(InputStatus inputStatus, String ruleName, int count) {RuleSpec rule = Preconditions.checkNotNull(grammar.getRule(ruleName));- String inputContent = inputStatus.getContent();List<InputCompletion> inputCompletions = new ArrayList<>();- Set<String> labels = new HashSet<>();+ Map<String, List<ElementCompletion>> label2completions = new LinkedHashMap<>();for (ElementCompletion completion: suggest(rule, inputStatus, count)) {- if (!labels.contains(completion.getLabel())) {- labels.add(completion.getLabel());- String content = inputContent.substring(0, completion.getReplaceBegin())- + completion.getReplaceContent();- boolean mandatoriesAdded = false;- if (completion.isComplete() && completion.getReplaceEnd() == inputStatus.getCaret()) {+ List<ElementCompletion> completionsWithLabel = label2completions.get(completion.getLabel());+ if (completionsWithLabel == null) {+ completionsWithLabel = new ArrayList<>();+ label2completions.put(completion.getLabel(), completionsWithLabel);+ }+ completionsWithLabel.add(completion);+ }+ String inputContent = inputStatus.getContent();+ for (Map.Entry<String, List<ElementCompletion>> entry: label2completions.entrySet()) {+ ElementCompletion completion = entry.getValue().get(0);+ String content = appendMandatories(inputStatus, completion);+ for (int i=1; i<entry.getValue().size(); i++) {+ String eachContent = appendMandatories(inputStatus, entry.getValue().get(i));+ if (!eachContent.equals(content)) {+ // we have multiple mandatories attached to same label, so they are no longer+ // mandatories any more+ content = completion.complete(inputStatus).getContent();+ break;+ }+ }++ /*+ * Adjust caret to move it to next place expecting user input if suggestion is+ * complete, that is, we move it after all mandatory tokens after the replacement,+ * unless user puts caret explicitly in the middle of replacement via suggestion,+ * indicating the replacement has some place holders expecting user input.+ */+ int caret = completion.getCaret();+ if (completion.isComplete() && caret == -1) {+ // caret is not at the middle of replacement, so we need to move it to+ // be after mandatory tokens if provided suggestion is complete+ caret = content.length() - inputContent.length() + completion.getReplaceEnd();+ if (content.equals(completion.complete(inputStatus).getContent())) {+ // in case mandatory tokens are not added after replacement,+ // we skip existing mandatory tokens in current input+ String contentAfterCaret = content.substring(caret);ParentedElement parentElement = completion.getExpectedElement().getParent();ElementSpec elementSpec = completion.getExpectedElement().getSpec();- for (String mandatory: getMandatoriesAfter(parentElement, elementSpec)) {- String prevContent = content;- content += mandatory;- mandatoriesAdded = true;-- if (grammar.getTokenTypeByLiteral(mandatory) != null) {- /*- * if mandatory can be appended without space, the last token- * position should remain unchanged in concatenated content- */- List<Token> tokens = grammar.lex(content);- if (!tokens.isEmpty()) {- Token lastToken = tokens.get(tokens.size()-1);- if (lastToken.getStartIndex() != content.length() - mandatory.length()- || lastToken.getStopIndex() != content.length()-1) {- content = prevContent + " " + mandatory;- }- } else {- content = prevContent + " " + mandatory;- }- }- }+ caret += skipMandatories(contentAfterCaret, getMandatoriesAfter(parentElement, elementSpec));}- content += inputContent.substring(completion.getReplaceEnd());-- /*- * Adjust caret to move it to next place expecting user input if suggestion is- * complete, that is, we move it after all mandatory tokens after the replacement,- * unless user puts caret explicitly in the middle of replacement via suggestion,- * indicating the replacement has some place holders expecting user input.- */- int caret = completion.getCaret();- if (completion.isComplete() && caret == -1) {- // caret is not at the middle of replacement, so we need to move it to- // be after mandatory tokens if provided suggestion is complete- caret = content.length() - inputContent.length() + completion.getReplaceEnd();- if (!mandatoriesAdded) {- // in case mandatory tokens are not added after replacement,- // we skip existing mandatory tokens in current input- String contentAfterCaret = content.substring(caret);- ParentedElement parentElement = completion.getExpectedElement().getParent();- ElementSpec elementSpec = completion.getExpectedElement().getSpec();- caret += skipMandatories(contentAfterCaret, getMandatoriesAfter(parentElement, elementSpec));- }- } else {- if (caret == -1)- caret = completion.getReplaceContent().length();- caret += completion.getReplaceBegin();- }-- String replaceContent = content.substring(completion.getReplaceBegin(),- content.length()-inputContent.length()+completion.getReplaceEnd());- inputCompletions.add(new InputCompletion(completion.getReplaceBegin(),- completion.getReplaceEnd(), replaceContent, caret, completion.getLabel(),- completion.getDescription(), completion.getMatchRange()));+ } else {+ if (caret == -1)+ caret = completion.getReplaceContent().length();+ caret += completion.getReplaceBegin();}++ String replaceContent = content.substring(completion.getReplaceBegin(),+ content.length()-inputContent.length()+completion.getReplaceEnd());+ inputCompletions.add(new InputCompletion(completion.getReplaceBegin(),+ completion.getReplaceEnd(), replaceContent, caret, completion.getLabel(),+ completion.getDescription(), completion.getMatchRange()));}/*@@ -253,11 +273,18 @@ public abstract class CodeAssist implements Serializable {private String getMatchWith(Chart chart, InputStatus inputStatus) {String matchWith;Token token = chart.getOriginatingToken();+ int endCharIndex;if (token != null) {- int endCharIndex = token.getStopIndex()+1;- matchWith = inputStatus.getContent().substring(endCharIndex, inputStatus.getCaret());+ endCharIndex = token.getStopIndex()+1;} else {- matchWith = inputStatus.getContentBeforeCaret();+ endCharIndex = 0;+ }+ matchWith = inputStatus.getContent().substring(endCharIndex, inputStatus.getCaret());+ for (Token each: chart.getParser().getTokens()) {+ if (each.getStartIndex() == endCharIndex) {+ // we can not trim leading space as it is not optional+ return matchWith;+ }}return StringUtils.trimStart(matchWith);}@@ -529,7 +556,10 @@ public abstract class CodeAssist implements Serializable {@Nullableprotected InputSuggestion wrapAsSuggestion(ParentedElement expectedElement,String suggestedLiteral, boolean complete) {- return new InputSuggestion(suggestedLiteral, -1, complete, null, null);+ if (StringUtils.isNotBlank(suggestedLiteral))+ return new InputSuggestion(suggestedLiteral, -1, complete, null, null);+ else+ return new InputSuggestion(suggestedLiteral, -1, complete, "space", null);}}diff --git a/commons.antlr/src/main/java/com/pmease/commons/antlr/codeassist/FenceAware.java b/commons.antlr/src/main/java/com/pmease/commons/antlr/codeassist/FenceAware.javaindex 2ab81f9f35..299c6cd721 100644--- a/commons.antlr/src/main/java/com/pmease/commons/antlr/codeassist/FenceAware.java+++ b/commons.antlr/src/main/java/com/pmease/commons/antlr/codeassist/FenceAware.java@@ -1,103 +1,103 @@-package com.pmease.commons.antlr.codeassist;--import java.util.ArrayList;-import java.util.List;--import javax.annotation.Nullable;--import org.antlr.v4.runtime.Token;--import com.pmease.commons.antlr.grammar.ElementSpec;-import com.pmease.commons.antlr.grammar.Grammar;-import com.pmease.commons.util.Range;--public abstract class FenceAware {-- private final Grammar grammar;-- private final String open;-- private final String close;-- public FenceAware(Grammar grammar, String open, String close) {- this.grammar = grammar;- this.open = open;- this.close = close;- }-- private boolean matches(ElementSpec spec, String content) {- List<Token> tokens = grammar.lex(content);- if (tokens.isEmpty()) {- return content.length() == 0 && spec.isAllowEmpty();- } else {- int start = tokens.get(0).getStartIndex();- int stop = tokens.get(tokens.size()-1).getStopIndex()+1;- return start == 0 && stop == content.length() && spec.getEndOfMatch(tokens) == tokens.size();- }- }-- public List<InputSuggestion> suggest(ElementSpec spec, String matchWith) {- String unfencedMatchWith = matchWith;- if (matchWith.startsWith(open))- unfencedMatchWith = unfencedMatchWith.substring(open.length());- unfencedMatchWith = unfencedMatchWith.trim();-- List<InputSuggestion> suggestions = match(unfencedMatchWith);- if (suggestions != null) {- List<InputSuggestion> checkedSuggestions = new ArrayList<>();-- for (InputSuggestion suggestion: suggestions) {- String content = suggestion.getContent();- int caret = suggestion.getCaret();- if (!matches(spec, content)) {- content = open + content + close;- Range matchRange = suggestion.getMatchRange();- if (caret != -1)- caret += open.length();- if (matchRange != null)- matchRange = new Range(matchRange.getFrom()+open.length(), matchRange.getTo()+open.length());- checkedSuggestions.add(new InputSuggestion(content, caret, true, suggestion.getDescription(), matchRange));- } else {- checkedSuggestions.add(suggestion);- }- }-- /*- * 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() && matchWith.length() != 0 && !matches(spec, unfencedMatchWith)) {- unfencedMatchWith = open + unfencedMatchWith + close;- if (matches(spec, unfencedMatchWith)) {- Range matchRange = new Range(1, unfencedMatchWith.length()-1);- checkedSuggestions.add(new InputSuggestion(unfencedMatchWith, getFencingDescription(), matchRange));- }- }-- if (checkedSuggestions.isEmpty() && matchWith.length() == 0)- checkedSuggestions.add(new InputSuggestion(open, null, null));- return checkedSuggestions;- } else {- return null;- }- }-- protected String getFencingDescription() {- return null;- }-- /**- * Match with provided string to give a list of suggestions- *- * @param unfencedMatchWith- * string with fencing literals removed- * @return- * a list of suggestions. If you do not have any suggestions and want code assist to- * drill down the element to provide default suggestions, return a <tt>null</tt> value- * instead of an empty list- */- @Nullable- protected abstract List<InputSuggestion> match(String unfencedMatchWith);-}+package com.pmease.commons.antlr.codeassist;++import java.util.ArrayList;+import java.util.List;++import javax.annotation.Nullable;++import org.antlr.v4.runtime.Token;++import com.pmease.commons.antlr.grammar.ElementSpec;+import com.pmease.commons.antlr.grammar.Grammar;+import com.pmease.commons.util.Range;++public abstract class FenceAware {++ private final Grammar grammar;++ private final String open;++ private final String close;++ public FenceAware(Grammar grammar, String open, String close) {+ this.grammar = grammar;+ this.open = open;+ this.close = close;+ }++ private boolean matches(ElementSpec spec, String content) {+ List<Token> tokens = grammar.lex(content);+ if (tokens.isEmpty()) {+ return content.length() == 0 && spec.isAllowEmpty();+ } else {+ int start = tokens.get(0).getStartIndex();+ int stop = tokens.get(tokens.size()-1).getStopIndex()+1;+ return start == 0 && stop == content.length() && spec.getEndOfMatch(tokens) == tokens.size();+ }+ }++ public List<InputSuggestion> suggest(ElementSpec spec, String matchWith, int count) {+ String unfencedMatchWith = matchWith;+ if (matchWith.startsWith(open))+ unfencedMatchWith = unfencedMatchWith.substring(open.length());+ unfencedMatchWith = unfencedMatchWith.trim();++ List<InputSuggestion> suggestions = match(unfencedMatchWith, count);+ if (suggestions != null) {+ List<InputSuggestion> checkedSuggestions = new ArrayList<>();++ for (InputSuggestion suggestion: suggestions) {+ String content = suggestion.getContent();+ int caret = suggestion.getCaret();+ if (!matches(spec, content)) {+ content = open + content + close;+ Range matchRange = suggestion.getMatchRange();+ if (caret != -1)+ caret += open.length();+ if (matchRange != null)+ matchRange = new Range(matchRange.getFrom()+open.length(), matchRange.getTo()+open.length());+ checkedSuggestions.add(new InputSuggestion(content, caret, true, suggestion.getDescription(), matchRange));+ } else {+ checkedSuggestions.add(suggestion);+ }+ }++ /*+ * 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() && matchWith.length() != 0 && !matches(spec, unfencedMatchWith)) {+ unfencedMatchWith = open + unfencedMatchWith + close;+ if (matches(spec, unfencedMatchWith)) {+ Range matchRange = new Range(1, unfencedMatchWith.length()-1);+ checkedSuggestions.add(new InputSuggestion(unfencedMatchWith, getFencingDescription(), matchRange));+ }+ }++ if (checkedSuggestions.isEmpty() && matchWith.length() == 0)+ checkedSuggestions.add(new InputSuggestion(open, null, null));+ return checkedSuggestions;+ } else {+ return null;+ }+ }++ protected String getFencingDescription() {+ return null;+ }++ /**+ * Match with provided string to give a list of suggestions+ *+ * @param unfencedMatchWith+ * string with fencing literals removed+ * @return+ * a list of suggestions. If you do not have any suggestions and want code assist to+ * drill down the element to provide default suggestions, return a <tt>null</tt> value+ * instead of an empty list+ */+ @Nullable+ protected abstract List<InputSuggestion> match(String unfencedMatchWith, int count);+}diff --git a/commons.antlr/src/main/java/com/pmease/commons/antlr/grammar/LiteralElementSpec.java b/commons.antlr/src/main/java/com/pmease/commons/antlr/grammar/LiteralElementSpec.javaindex 8397d5c1d8..c61f61359f 100644--- a/commons.antlr/src/main/java/com/pmease/commons/antlr/grammar/LiteralElementSpec.java+++ b/commons.antlr/src/main/java/com/pmease/commons/antlr/grammar/LiteralElementSpec.java@@ -3,8 +3,6 @@ package com.pmease.commons.antlr.grammar;import java.util.LinkedHashSet;import java.util.Set;-import org.apache.commons.lang3.StringUtils;-import com.google.common.collect.Lists;import com.pmease.commons.antlr.codeassist.MandatoryScan;@@ -38,8 +36,7 @@ public class LiteralElementSpec extends TokenElementSpec {@Overridepublic Set<String> getPossiblePrefixes() {Set<String> possiblePrefixes = new LinkedHashSet<>();- if (StringUtils.isNotBlank(literal))- possiblePrefixes.add(literal);+ possiblePrefixes.add(literal);return possiblePrefixes;}diff --git a/commons.antlr/src/test/java/com/pmease/commons/antlr/codeassist/test/CodeAssistTest1.java b/commons.antlr/src/test/java/com/pmease/commons/antlr/codeassist/test/CodeAssistTest1.javaindex 43ff0d067d..2f1a26a5a5 100644--- a/commons.antlr/src/test/java/com/pmease/commons/antlr/codeassist/test/CodeAssistTest1.java+++ b/commons.antlr/src/test/java/com/pmease/commons/antlr/codeassist/test/CodeAssistTest1.java@@ -37,18 +37,18 @@ public class CodeAssistTest1 {public void test() {List<InputStatus> suggestions;+ suggestions = suggest(new InputStatus(""), "selfReference");+ assertEquals(1, suggestions.size());+ assertEquals("ab:2", suggestions.get(0).toString());+suggestions = suggest(new InputStatus("ab"), "selfReference");assertEquals(0, suggestions.size());suggestions = suggest(new InputStatus("ab "), "selfReference");assertEquals(1, suggestions.size());- assertEquals("ab cd cd:8", suggestions.get(0).toString());+ assertEquals("ab cd:5", suggestions.get(0).toString());- suggestions = suggest(new InputStatus(""), "selfReference");- assertEquals(1, suggestions.size());- assertEquals("ab:2", suggestions.get(0).toString());-suggestions = suggest(new InputStatus(""), "mandatories");assertEquals(2, suggestions.size());assertEquals("ab c:4", suggestions.get(0).toString());diff --git a/commons.antlr/src/test/java/com/pmease/commons/antlr/codeassist/test/CodeAssistTest2.java b/commons.antlr/src/test/java/com/pmease/commons/antlr/codeassist/test/CodeAssistTest2.javaindex e1ca344d61..ec4f7e2ba8 100644--- a/commons.antlr/src/test/java/com/pmease/commons/antlr/codeassist/test/CodeAssistTest2.java+++ b/commons.antlr/src/test/java/com/pmease/commons/antlr/codeassist/test/CodeAssistTest2.java@@ -24,14 +24,14 @@ public class CodeAssistTest2 {private static final long serialVersionUID = 1L;@Override- protected List<InputSuggestion> suggest(final ParentedElement element, String matchWith, int count) {+ protected List<InputSuggestion> suggest(ParentedElement element, String matchWith, int count) {if (element.getSpec() instanceof LexerRuleRefElementSpec) {LexerRuleRefElementSpec spec = (LexerRuleRefElementSpec) element.getSpec();if (spec.getRuleName().equals("Value")) {return new FenceAware(codeAssist.getGrammar(), "(", ")") {@Override- protected List<InputSuggestion> match(String matchWith) {+ protected List<InputSuggestion> match(String matchWith, int count) {if (element.getRoot().getLastMatchedToken().getType() == CodeAssistTest2Lexer.BRANCH) {List<InputSuggestion> suggestions = new ArrayList<>();for (String value: BRANCHS) {@@ -44,7 +44,7 @@ public class CodeAssistTest2 {}}- }.suggest(element.getSpec(), matchWith);+ }.suggest(element.getSpec(), matchWith, count);}}return null;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 9e73f09f00..63906e6fab 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@@ -32,7 +32,7 @@ public class CodeAssistTest3 {return new FenceAware(codeAssist.getGrammar(), "\"", "\"") {@Override- protected List<InputSuggestion> match(String matchWith) {+ protected List<InputSuggestion> match(String matchWith, int count) {List<InputSuggestion> suggestions = new ArrayList<>();Element criteriaElement = element.findParentByRule("criteria");if (criteriaElement.getFirstMatchedToken().getText().equals("author")) {@@ -44,7 +44,7 @@ public class CodeAssistTest3 {return suggestions;}- }.suggest(element.getSpec(), matchWith);+ }.suggest(element.getSpec(), matchWith, count);}}return null;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 a980329bf8..b9638c76cf 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@@ -231,7 +231,10 @@ public abstract class ANTLRAssistBehavior extends InputAssistBehavior {@Nullableprotected InputSuggestion wrapAsSuggestion(ParentedElement expectedElement,String suggestedLiteral, boolean complete) {- return new InputSuggestion(suggestedLiteral, -1, complete, null, null);+ if (StringUtils.isNotBlank(suggestedLiteral))+ return new InputSuggestion(suggestedLiteral, -1, complete, null, null);+ else+ return new InputSuggestion(suggestedLiteral, -1, complete, "space", null);}}diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/util/fullbranchmatch/FullBranchMatch.g4 b/gitplex.core/src/main/java/com/pmease/gitplex/core/util/fullbranchmatch/FullBranchMatch.g4index 95007418b2..64189c2900 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/util/fullbranchmatch/FullBranchMatch.g4+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/util/fullbranchmatch/FullBranchMatch.g4@@ -1,6 +1,6 @@grammar FullBranchMatch;-match: criteria+ EOF;+match: ' '* criteria (' '+ criteria)* ' '* EOF;criteria: includeMatch | excludeMatch;@@ -18,6 +18,4 @@ EXCLUDE: 'exclude';Value: (ESCAPE|~[:() \\])+;fragment-ESCAPE: '\\'[:()\\];--WS: [ \t\r\n]+ -> skip;\ No newline at end of file+ESCAPE: '\\'[:()\\];\ No newline at end of filediff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/util/includeexclude/IncludeExclude.g4 b/gitplex.core/src/main/java/com/pmease/gitplex/core/util/includeexclude/IncludeExclude.g4index 631f1ae88c..e6e131e696 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/util/includeexclude/IncludeExclude.g4+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/util/includeexclude/IncludeExclude.g4@@ -1,6 +1,6 @@grammar IncludeExclude;-match: criteria+ EOF;+match: criteria (' ' (criteria|' '*))* ' '* EOF;criteria: includeMatch | excludeMatch;@@ -14,5 +14,3 @@ Value: '(' (ESCAPE|~[()\\])+? ')';fragmentESCAPE: '\\'[()\\];--WS: [ \t\r\n]+ -> skip;\ No newline at end of filediff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/branchmatch/BranchMatchBehavior.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/branchmatch/BranchMatchBehavior.javaindex 36c46ff709..86887e0b26 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/branchmatch/BranchMatchBehavior.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/branchmatch/BranchMatchBehavior.java@@ -37,14 +37,14 @@ public class BranchMatchBehavior extends ANTLRAssistBehavior {}@Override- protected List<InputSuggestion> suggest(final ParentedElement expectedElement, String matchWith, final int count) {+ protected List<InputSuggestion> suggest(final ParentedElement expectedElement, String matchWith, int count) {if (expectedElement.getSpec() instanceof LexerRuleRefElementSpec) {LexerRuleRefElementSpec spec = (LexerRuleRefElementSpec) expectedElement.getSpec();if (spec.getRuleName().equals("Value")) {return new FenceAware(codeAssist.getGrammar(), VALUE_OPEN, VALUE_CLOSE) {@Override- protected List<InputSuggestion> match(String unfencedMatchWith) {+ protected List<InputSuggestion> match(String unfencedMatchWith, int count) {return SuggestionUtils.suggestBranch(depotModel.getObject(), unfencedMatchWith, count,null, "any branch");}@@ -54,7 +54,7 @@ public class BranchMatchBehavior extends ANTLRAssistBehavior {return "value needs to be enclosed in brackets";}- }.suggest(expectedElement.getSpec(), matchWith);+ }.suggest(expectedElement.getSpec(), matchWith, count);}}return null;diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/pathmatch/PathMatchBehavior.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/pathmatch/PathMatchBehavior.javaindex 6c3380c64d..e64f988694 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/pathmatch/PathMatchBehavior.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/pathmatch/PathMatchBehavior.java@@ -37,14 +37,14 @@ public class PathMatchBehavior extends ANTLRAssistBehavior {}@Override- protected List<InputSuggestion> suggest(final ParentedElement expectedElement, String matchWith, final int count) {+ protected List<InputSuggestion> suggest(final ParentedElement expectedElement, String matchWith, int count) {if (expectedElement.getSpec() instanceof LexerRuleRefElementSpec) {LexerRuleRefElementSpec spec = (LexerRuleRefElementSpec) expectedElement.getSpec();if (spec.getRuleName().equals("Value")) {return new FenceAware(codeAssist.getGrammar(), VALUE_OPEN, VALUE_CLOSE) {@Override- protected List<InputSuggestion> match(String unfencedMatchWith) {+ protected List<InputSuggestion> match(String unfencedMatchWith, int count) {return SuggestionUtils.suggestPath(depotModel.getObject(), unfencedMatchWith, count);}@@ -53,7 +53,7 @@ public class PathMatchBehavior extends ANTLRAssistBehavior {return "value needs to be enclosed in brackets";}- }.suggest(expectedElement.getSpec(), matchWith);+ }.suggest(expectedElement.getSpec(), matchWith, count);}}return null;diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/refmatch/RefMatchBehavior.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/refmatch/RefMatchBehavior.javaindex ac483f2919..210c8eac7b 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/refmatch/RefMatchBehavior.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/refmatch/RefMatchBehavior.java@@ -44,14 +44,14 @@ public class RefMatchBehavior extends ANTLRAssistBehavior {}@Override- protected List<InputSuggestion> suggest(final ParentedElement expectedElement, String matchWith, final int count) {+ protected List<InputSuggestion> suggest(final ParentedElement expectedElement, String matchWith, int count) {if (expectedElement.getSpec() instanceof LexerRuleRefElementSpec) {LexerRuleRefElementSpec spec = (LexerRuleRefElementSpec) expectedElement.getSpec();if (spec.getRuleName().equals("Value")) {return new FenceAware(codeAssist.getGrammar(), VALUE_OPEN, VALUE_CLOSE) {@Override- protected List<InputSuggestion> match(String unfencedMatchWith) {+ protected List<InputSuggestion> match(String unfencedMatchWith, int count) {List<InputSuggestion> suggestions = new ArrayList<>();Depot depot = depotModel.getObject();@@ -80,7 +80,9 @@ public class RefMatchBehavior extends ANTLRAssistBehavior {}}- if (!unfencedMatchWith.contains(VALUE_CLOSE) && unfencedMatchWith.length() != 0) {+ if (numSuggestions++<count+ && !unfencedMatchWith.contains(VALUE_CLOSE)+ && unfencedMatchWith.length() != 0) {String fenced = VALUE_OPEN + unfencedMatchWith + VALUE_CLOSE;Range matchRange = new Range(0, fenced.length());suggestions.add(new InputSuggestion(fenced, -1, true, getFencingDescription(), matchRange));@@ -93,7 +95,7 @@ public class RefMatchBehavior extends ANTLRAssistBehavior {return "value needs to be enclosed in brackets";}- }.suggest(expectedElement.getSpec(), matchWith);+ }.suggest(expectedElement.getSpec(), matchWith, count);}}return null;diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/CommitQuery.g4 b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/CommitQuery.g4index 1439c2429f..65f9e15d8b 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/CommitQuery.g4+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/CommitQuery.g4@@ -1,6 +1,6 @@grammar CommitQuery;-query: criteria+ EOF;+query: ' '* criteria (' '+ criteria)* ' '* EOF;criteria: revisionCriteria | before | after | committer | author | path | message;@@ -40,5 +40,3 @@ Value: '(' (ESCAPE|~[()\\])+? ')';fragmentESCAPE: '\\'[()\\];--WS: [ \t\r\n]+ -> skip;\ No newline at end of filediff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/DepotCommitsPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/DepotCommitsPage.javaindex c6c3e1f436..03f018903a 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/DepotCommitsPage.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/DepotCommitsPage.java@@ -65,6 +65,7 @@ import com.pmease.gitplex.web.page.depot.commit.CommitQueryParser.QueryContext;import com.pmease.gitplex.web.page.depot.compare.RevisionComparePage;import de.agilecoders.wicket.core.markup.html.bootstrap.common.NotificationPanel;+import jersey.repackaged.com.google.common.collect.Lists;@SuppressWarnings("serial")public class DepotCommitsPage extends DepotPage {@@ -623,8 +624,11 @@ public class DepotCommitsPage extends DepotPage {logCommand.count(step*COUNT);QueryContext parseTree = getParseTree();- if (parseTree != null)+ if (parseTree != null) {new ParseTreeWalker().walk(new LogCommandFiller(logCommand), parseTree);+ if (logCommand.revisions().isEmpty() && compareWith != null)+ logCommand.revisions(Lists.newArrayList(compareWith));+ }}}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/QueryAssistBehavior.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/QueryAssistBehavior.javaindex e08d889640..1618eb32d4 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/QueryAssistBehavior.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/QueryAssistBehavior.java@@ -51,14 +51,14 @@ public class QueryAssistBehavior extends ANTLRAssistBehavior {}@Override- protected List<InputSuggestion> suggest(final ParentedElement expectedElement, String matchWith, final int count) {+ protected List<InputSuggestion> suggest(final ParentedElement expectedElement, String matchWith, int count) {if (expectedElement.getSpec() instanceof LexerRuleRefElementSpec) {LexerRuleRefElementSpec spec = (LexerRuleRefElementSpec) expectedElement.getSpec();if (spec.getRuleName().equals("Value")) {return new FenceAware(codeAssist.getGrammar(), VALUE_OPEN, VALUE_CLOSE) {@Override- protected List<InputSuggestion> match(String unfencedMatchWith) {+ protected List<InputSuggestion> match(String unfencedMatchWith, int count) {int tokenType = expectedElement.getRoot().getLastMatchedToken().getType();String unfencedLowerCaseMatchWith = unfencedMatchWith.toLowerCase();List<InputSuggestion> suggestions = new ArrayList<>();@@ -99,12 +99,17 @@ public class QueryAssistBehavior extends ANTLRAssistBehavior {if (unfencedMatchWith.length() != 0) {String fenced = VALUE_OPEN + unfencedMatchWith + VALUE_CLOSE;Range matchRange = new Range(0, fenced.length());- suggestions.add(new InputSuggestion(fenced, -1, true, getFencingDescription(), matchRange));+ if (suggestions.size() < count)+ suggestions.add(new InputSuggestion(fenced, -1, true, getFencingDescription(), matchRange));+ }+ if (suggestions.size() < count)+ suggestions.add(new InputSuggestion(Constants.DATETIME_FORMATTER.print(System.currentTimeMillis())));+ if (suggestions.size() < count)+ suggestions.add(new InputSuggestion(Constants.DATE_FORMATTER.print(System.currentTimeMillis())));+ for (String dateExample: DATE_EXAMPLES) {+ if (suggestions.size() < count)+ suggestions.add(new InputSuggestion(dateExample));}- suggestions.add(new InputSuggestion(Constants.DATETIME_FORMATTER.print(System.currentTimeMillis())));- suggestions.add(new InputSuggestion(Constants.DATE_FORMATTER.print(System.currentTimeMillis())));- for (String dateExample: DATE_EXAMPLES)- suggestions.add(new InputSuggestion(dateExample));}break;case CommitQueryParser.PATH:@@ -119,7 +124,7 @@ public class QueryAssistBehavior extends ANTLRAssistBehavior {return "value needs to be enclosed in brackets";}- }.suggest(expectedElement.getSpec(), matchWith);+ }.suggest(expectedElement.getSpec(), matchWith, count);}}return null;@@ -195,6 +200,9 @@ public class QueryAssistBehavior extends ANTLRAssistBehavior {case "...":description = "revision range";break;+ case " ":+ description = "space";+ break;default:description = null;}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/commit-detail.css b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/commit-detail.cssindex ac24551144..567af8887a 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/commit-detail.css+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/commit-detail.css@@ -41,8 +41,8 @@border-bottom: 1px solid #DDD;}#commit-detail>.info>.refs .branch:before {- font-family: FontExt;- content: "\f221";+ font-family: Fontawesome;+ content: "\f126";color: #444;}#commit-detail>.info>.refs .tag:before {diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/file/LastCommitPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/file/LastCommitPanel.javaindex 8eefb98a5e..4acdddf90c 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/file/LastCommitPanel.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/file/LastCommitPanel.java@@ -52,9 +52,7 @@ class LastCommitPanel extends Panel {String commitHash = depotModel.getObject().getObjectId(blobIdent.revision).name();state.setCompareWith(commitHash);if (blobIdent.path != null)- state.setQuery(String.format("id(%s) path(%s)", commitHash, blobIdent.path));- else- state.setQuery(String.format("id(%s)", commitHash));+ state.setQuery(String.format("path(%s)", blobIdent.path));setResponsePage(DepotCommitsPage.class, DepotCommitsPage.paramsOf(depotModel.getObject(), state));}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/tags/DepotTagsPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/tags/DepotTagsPage.javaindex 6cd9af1cbf..bffc54cd79 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/tags/DepotTagsPage.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/tags/DepotTagsPage.java@@ -327,7 +327,7 @@ public class DepotTagsPage extends DepotPage {}DepotAndRevision source = new DepotAndRevision(getDepot(),GitUtils.ref2tag(item.getModelObject().getName()));- PageParameters params = RevisionComparePage.paramsOf(getDepot(), target, source, true, null);+ PageParameters params = RevisionComparePage.paramsOf(getDepot(), target, source, true, "");setResponsePage(RevisionComparePage.class, params);} catch (IOException e) {throw new RuntimeException(e);