The Unified and Autonomous Development Platform
midwork
robin shine8e983ee508f4
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 7e9fe39882..f523496eb2 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@@ -24,10 +24,10 @@ import com.pmease.commons.antlr.grammar.Grammar;import com.pmease.commons.antlr.grammar.RuleRefElementSpec;import com.pmease.commons.antlr.grammar.RuleSpec;import com.pmease.commons.antlr.grammar.TokenElementSpec;+import com.pmease.commons.antlr.parser.Chart;import com.pmease.commons.antlr.parser.EarleyParser;import com.pmease.commons.antlr.parser.Element;import com.pmease.commons.antlr.parser.State;-import com.pmease.commons.antlr.parser.Chart;import com.pmease.commons.util.StringUtils;public abstract class CodeAssist implements Serializable {@@ -104,7 +104,8 @@ public abstract class CodeAssist implements Serializable {* logic*/String key = inputContent.substring(0, elementCompletion.getReplaceBegin())- + elementCompletion.getReplaceContent() + inputContent.substring(elementCompletion.getReplaceEnd());+ + elementCompletion.getReplaceContent()+ + inputContent.substring(elementCompletion.getReplaceEnd());List<ElementCompletion> value = grouped.get(key);if (value == null) {value = new ArrayList<>();@@ -113,7 +114,7 @@ public abstract class CodeAssist implements Serializable {value.add(elementCompletion);}- for (Map.Entry<String, List<ElementCompletion>> entry: grouped.entrySet()) {+ for (Map.Entry<String, List<ElementCompletion>> entry: grouped.entrySet()) {List<ElementCompletion> value = entry.getValue();ElementCompletion completion = value.get(0);String description = completion.getDescription();@@ -189,9 +190,12 @@ public abstract class CodeAssist implements Serializable {String replaceContent = content.substring(completion.getReplaceBegin(),content.length()-inputContent.length()+completion.getReplaceEnd());+ String label = completion.getLabel();+ if (label == null)+ label = completion.getReplaceContent();inputCompletions.add(new InputCompletion(completion.getReplaceBegin(),- completion.getReplaceEnd(), replaceContent, caret, description,- completion.getMatchRange()));+ completion.getReplaceEnd(), replaceContent, caret, label,+ description, completion.getMatchRange()));}/*@@ -462,7 +466,7 @@ public abstract class CodeAssist implements Serializable {inputSuggestion.isComplete()?replaceEnd:inputStatus.getCaret(),inputSuggestion.getContent(), inputSuggestion.getCaret(),inputSuggestion.isComplete(), inputSuggestion.getDescription(),- inputSuggestion.getMatchRange()));+ inputSuggestion.getLabel(), inputSuggestion.getMatchRange()));}}return completions;diff --git a/commons.antlr/src/main/java/com/pmease/commons/antlr/codeassist/ElementCompletion.java b/commons.antlr/src/main/java/com/pmease/commons/antlr/codeassist/ElementCompletion.javaindex 15373b8f8c..c3ff877847 100644--- a/commons.antlr/src/main/java/com/pmease/commons/antlr/codeassist/ElementCompletion.java+++ b/commons.antlr/src/main/java/com/pmease/commons/antlr/codeassist/ElementCompletion.java@@ -1,32 +1,32 @@-package com.pmease.commons.antlr.codeassist;--import javax.annotation.Nullable;--import com.pmease.commons.util.Range;--public class ElementCompletion extends InputCompletion {-- private static final long serialVersionUID = 1L;-- private final boolean complete;-- private final ParentedElement expectedElement;-- public ElementCompletion(ParentedElement expectedElement, int replaceBegin,- int replaceEnd, String replaceContent, int caret, boolean complete,- @Nullable String description, @Nullable Range highlight) {- super(replaceBegin, replaceEnd, replaceContent, caret, description, highlight);-- this.complete = complete;- this.expectedElement = expectedElement;- }-- public ParentedElement getExpectedElement() {- return expectedElement;- }-- public boolean isComplete() {- return complete;- }-+package com.pmease.commons.antlr.codeassist;++import javax.annotation.Nullable;++import com.pmease.commons.util.Range;++public class ElementCompletion extends InputCompletion {++ private static final long serialVersionUID = 1L;++ private final boolean complete;++ private final ParentedElement expectedElement;++ public ElementCompletion(ParentedElement expectedElement, int replaceBegin,+ int replaceEnd, String replaceContent, int caret, boolean complete,+ @Nullable String label, @Nullable String description, @Nullable Range highlight) {+ super(replaceBegin, replaceEnd, replaceContent, caret, label, description, highlight);++ this.complete = complete;+ this.expectedElement = expectedElement;+ }++ public ParentedElement getExpectedElement() {+ return expectedElement;+ }++ public boolean isComplete() {+ return complete;+ }+}\ No newline at end of filediff --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 609234ae94..36d46f5e4c 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@@ -1,66 +1,78 @@-package com.pmease.commons.antlr.codeassist;--import javax.annotation.Nullable;--import com.pmease.commons.util.Range;--public class InputSuggestion extends InputStatus {-- private static final long serialVersionUID = 1L;-- private final boolean complete;-- private final String description;-- private final Range matchRange;-- /**- * Construct the input suggestion.- *- * @param content- * content of the suggestion- * @param caret- * caret of the suggestion- * @param complete- * whether or not the suggested content is a complete representation of- * corresponding element spec- * @param description- * description of the suggestion- * @param matchRange- * optionally specifies range of the string being matched against user input- */- public InputSuggestion(String content, int caret, boolean complete, @Nullable String description,- @Nullable Range matchRange) {- super(content, caret);- this.complete = complete;- this.description = description;- this.matchRange = matchRange;- }-- public InputSuggestion(String content, @Nullable String description, @Nullable Range highlight) {- this(content, -1, true, description, highlight);- }-- public InputSuggestion(String content, @Nullable Range matchRange) {- this(content, null, matchRange);- }-- public InputSuggestion(String content) {- this(content, null);- }-- public boolean isComplete() {- return complete;- }-- @Nullable- public String getDescription() {- return description;- }-- @Nullable- public Range getMatchRange() {- return matchRange;- }--}+package com.pmease.commons.antlr.codeassist;++import javax.annotation.Nullable;++import com.pmease.commons.util.Range;++public class InputSuggestion extends InputStatus {++ private static final long serialVersionUID = 1L;++ private final boolean complete;++ private final String label;++ private final String description;++ private final Range matchRange;++ /**+ * Construct the input suggestion.+ *+ * @param content+ * content of the suggestion+ * @param caret+ * caret of the suggestion+ * @param complete+ * whether or not the suggested content is a complete representation of+ * corresponding element spec+ * @param description+ * description of the suggestion+ * @param matchRange+ * optionally specifies range of the string being matched against user input+ */+ public InputSuggestion(String content, int caret, boolean complete, @Nullable String label,+ @Nullable String description, @Nullable Range matchRange) {+ super(content, caret);+ this.complete = complete;+ this.label = label;+ this.description = description;+ this.matchRange = matchRange;+ }++ public InputSuggestion(String content, int caret, boolean complete,+ @Nullable String description, @Nullable Range matchRange) {+ this(content, caret, complete, null, description, matchRange);+ }++ public InputSuggestion(String content, @Nullable String description, @Nullable Range highlight) {+ this(content, -1, true, description, highlight);+ }++ public InputSuggestion(String content, @Nullable Range matchRange) {+ this(content, null, matchRange);+ }++ public InputSuggestion(String content) {+ this(content, null);+ }++ public boolean isComplete() {+ return complete;+ }++ public String getLabel() {+ return label;+ }++ @Nullable+ public String getDescription() {+ return description;+ }++ @Nullable+ public Range getMatchRange() {+ return matchRange;+ }++}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 122a57d7f6..9e73f09f00 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@@ -1,107 +1,107 @@-package com.pmease.commons.antlr.codeassist.test;--import static org.junit.Assert.assertEquals;--import java.util.ArrayList;-import java.util.List;--import org.junit.Test;--import com.pmease.commons.antlr.codeassist.CodeAssist;-import com.pmease.commons.antlr.codeassist.InputCompletion;-import com.pmease.commons.antlr.codeassist.InputStatus;-import com.pmease.commons.antlr.codeassist.InputSuggestion;-import com.pmease.commons.antlr.codeassist.ParentedElement;-import com.pmease.commons.antlr.codeassist.FenceAware;-import com.pmease.commons.antlr.grammar.RuleRefElementSpec;-import com.pmease.commons.antlr.parser.Element;--public class CodeAssistTest3 {-- private static final String[] AUTHORS = new String[]{"robin shen", "steve luo", "justin"};-- private CodeAssist codeAssist = new CodeAssist(CodeAssistTest3Lexer.class) {-- private static final long serialVersionUID = 1L;-- @Override- protected List<InputSuggestion> suggest(final ParentedElement element, String matchWith, int count) {- if (element.getSpec() instanceof RuleRefElementSpec) {- RuleRefElementSpec spec = (RuleRefElementSpec) element.getSpec();- if (spec.getRuleName().equals("value")) {- return new FenceAware(codeAssist.getGrammar(), "\"", "\"") {-- @Override- protected List<InputSuggestion> match(String matchWith) {- List<InputSuggestion> suggestions = new ArrayList<>();- Element criteriaElement = element.findParentByRule("criteria");- if (criteriaElement.getFirstMatchedToken().getText().equals("author")) {- for (String value: AUTHORS) {- if (value.toLowerCase().contains(matchWith.toLowerCase()))- suggestions.add(new InputSuggestion(value));- }- }- return suggestions;- }-- }.suggest(element.getSpec(), matchWith);- }- }- return null;- }-- };-- private List<InputStatus> suggest(InputStatus inputStatus, String ruleName) {- List<InputStatus> suggestions = new ArrayList<>();- for (InputCompletion completion: codeAssist.suggest(inputStatus, ruleName, Integer.MAX_VALUE))- suggestions.add(completion.complete(inputStatus));- return suggestions;- }-- @Test- public void test() {- List<InputStatus> suggestions;-- suggestions = 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 = suggest(new InputStatus("title: hello world"), "query");- assertEquals(1, suggestions.size());- assertEquals("title: \"hello world\":20", suggestions.get(0).toString());-- suggestions = suggest(new InputStatus(""), "query");- assertEquals(2, suggestions.size());- assertEquals("title::6", suggestions.get(0).toString());- assertEquals("author::7", suggestions.get(1).toString());-- suggestions = suggest(new InputStatus("title:"), "query");- assertEquals(1, suggestions.size());- assertEquals("title:\":7", suggestions.get(0).toString());-- suggestions = suggest(new InputStatus("author: dustin"), "query");- assertEquals(0, suggestions.size());-- suggestions = suggest(new InputStatus("author: dustin "), "query");- assertEquals(2, suggestions.size());- assertEquals("author: dustin title::21", suggestions.get(0).toString());- assertEquals("author: dustin author::22", suggestions.get(1).toString());-- suggestions = suggest(new InputStatus("author: \"robin shen\""), "query");- assertEquals(2, suggestions.size());- assertEquals("author: \"robin shen\"title::26", suggestions.get(0).toString());- assertEquals("author: \"robin shen\"author::27", suggestions.get(1).toString());-- suggestions = suggest(new InputStatus("title: hello"), "query");- assertEquals(0, suggestions.size());-- suggestions = suggest(new InputStatus("title: hello "), "query");- assertEquals(2, suggestions.size());- assertEquals("title: hello title::19", suggestions.get(0).toString());- assertEquals("title: hello author::20", suggestions.get(1).toString());- }--}+package com.pmease.commons.antlr.codeassist.test;++import static org.junit.Assert.assertEquals;++import java.util.ArrayList;+import java.util.List;++import org.junit.Test;++import com.pmease.commons.antlr.codeassist.CodeAssist;+import com.pmease.commons.antlr.codeassist.InputCompletion;+import com.pmease.commons.antlr.codeassist.InputStatus;+import com.pmease.commons.antlr.codeassist.InputSuggestion;+import com.pmease.commons.antlr.codeassist.ParentedElement;+import com.pmease.commons.antlr.codeassist.FenceAware;+import com.pmease.commons.antlr.grammar.RuleRefElementSpec;+import com.pmease.commons.antlr.parser.Element;++public class CodeAssistTest3 {++ private static final String[] AUTHORS = new String[]{"robin shen", "steve luo", "justin"};++ private CodeAssist codeAssist = new CodeAssist(CodeAssistTest3Lexer.class) {++ private static final long serialVersionUID = 1L;++ @Override+ protected List<InputSuggestion> suggest(final ParentedElement element, String matchWith, int count) {+ if (element.getSpec() instanceof RuleRefElementSpec) {+ RuleRefElementSpec spec = (RuleRefElementSpec) element.getSpec();+ if (spec.getRuleName().equals("value")) {+ return new FenceAware(codeAssist.getGrammar(), "\"", "\"") {++ @Override+ protected List<InputSuggestion> match(String matchWith) {+ List<InputSuggestion> suggestions = new ArrayList<>();+ Element criteriaElement = element.findParentByRule("criteria");+ if (criteriaElement.getFirstMatchedToken().getText().equals("author")) {+ for (String value: AUTHORS) {+ if (value.toLowerCase().contains(matchWith.toLowerCase()))+ suggestions.add(new InputSuggestion(value));+ }+ }+ return suggestions;+ }++ }.suggest(element.getSpec(), matchWith);+ }+ }+ return null;+ }++ };++ private List<InputStatus> suggest(InputStatus inputStatus, String ruleName) {+ List<InputStatus> suggestions = new ArrayList<>();+ for (InputCompletion completion: codeAssist.suggest(inputStatus, ruleName, Integer.MAX_VALUE))+ suggestions.add(completion.complete(inputStatus));+ return suggestions;+ }++ @Test+ public void test() {+ List<InputStatus> suggestions;++ suggestions = 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 = suggest(new InputStatus("title: hello world"), "query");+ assertEquals(1, suggestions.size());+ assertEquals("title: \"hello world\":20", suggestions.get(0).toString());++ suggestions = suggest(new InputStatus(""), "query");+ assertEquals(2, suggestions.size());+ assertEquals("title::6", suggestions.get(0).toString());+ assertEquals("author::7", suggestions.get(1).toString());++ suggestions = suggest(new InputStatus("title:"), "query");+ assertEquals(1, suggestions.size());+ assertEquals("title:\":7", suggestions.get(0).toString());++ suggestions = suggest(new InputStatus("author: dustin"), "query");+ assertEquals(0, suggestions.size());++ suggestions = suggest(new InputStatus("author: dustin "), "query");+ assertEquals(2, suggestions.size());+ assertEquals("author: dustin title::21", suggestions.get(0).toString());+ assertEquals("author: dustin author::22", suggestions.get(1).toString());++ suggestions = suggest(new InputStatus("author: \"robin shen\""), "query");+ assertEquals(2, suggestions.size());+ assertEquals("author: \"robin shen\"title::26", suggestions.get(0).toString());+ assertEquals("author: \"robin shen\"author::27", suggestions.get(1).toString());++ suggestions = suggest(new InputStatus("title: hello"), "query");+ assertEquals(0, suggestions.size());++ suggestions = suggest(new InputStatus("title: hello "), "query");+ assertEquals(2, suggestions.size());+ assertEquals("title: hello title::19", suggestions.get(0).toString());+ assertEquals("title: hello author::20", suggestions.get(1).toString());+ }++}diff --git a/commons.antlr/src/test/java/com/pmease/commons/antlr/codeassist/test/CodeAssistTest4.java b/commons.antlr/src/test/java/com/pmease/commons/antlr/codeassist/test/CodeAssistTest4.javaindex 67c04fa195..0f2558033b 100644--- a/commons.antlr/src/test/java/com/pmease/commons/antlr/codeassist/test/CodeAssistTest4.java+++ b/commons.antlr/src/test/java/com/pmease/commons/antlr/codeassist/test/CodeAssistTest4.java@@ -1,67 +1,67 @@-package com.pmease.commons.antlr.codeassist.test;--import static org.junit.Assert.assertEquals;--import java.util.ArrayList;-import java.util.List;--import org.junit.Test;--import com.pmease.commons.antlr.codeassist.CodeAssist;-import com.pmease.commons.antlr.codeassist.InputCompletion;-import com.pmease.commons.antlr.codeassist.InputStatus;-import com.pmease.commons.antlr.codeassist.InputSuggestion;-import com.pmease.commons.antlr.codeassist.ParentedElement;--public class CodeAssistTest4 {-- private CodeAssist codeAssist = new CodeAssist(CodeAssistTest4Lexer.class) {-- private static final long serialVersionUID = 1L;-- @Override- protected List<InputSuggestion> suggest(ParentedElement element, String matchWith, int count) {- return null;- }-- };-- private List<InputStatus> suggest(InputStatus inputStatus, String ruleName) {- List<InputStatus> suggestions = new ArrayList<>();- for (InputCompletion completion: codeAssist.suggest(inputStatus, ruleName, Integer.MAX_VALUE))- suggestions.add(completion.complete(inputStatus));- return suggestions;- }-- @Test- public void test() {- List<InputStatus> suggestions;-- suggestions = suggest(new InputStatus("a"), "stat");- assertEquals(6, suggestions.size());- assertEquals("a+:2", suggestions.get(0).toString());- assertEquals("a-:2", suggestions.get(1).toString());- assertEquals("a*:2", suggestions.get(2).toString());- assertEquals("a/:2", suggestions.get(3).toString());- assertEquals("a;:2", suggestions.get(4).toString());- assertEquals("a=:2", suggestions.get(5).toString());-- suggestions = suggest(new InputStatus(""), "stat");- assertEquals(2, suggestions.size());- assertEquals("(:1", suggestions.get(0).toString());- assertEquals(";:1", suggestions.get(1).toString());-- suggestions = suggest(new InputStatus("5*"), "stat");- assertEquals(1, suggestions.size());- assertEquals("5*(:3", suggestions.get(0).toString());-- suggestions = suggest(new InputStatus("5"), "stat");- assertEquals(5, suggestions.size());- assertEquals("5+:2", suggestions.get(0).toString());- assertEquals("5-:2", suggestions.get(1).toString());- assertEquals("5*:2", suggestions.get(2).toString());- assertEquals("5/:2", suggestions.get(3).toString());- assertEquals("5;:2", suggestions.get(4).toString());- }--}+package com.pmease.commons.antlr.codeassist.test;++import static org.junit.Assert.assertEquals;++import java.util.ArrayList;+import java.util.List;++import org.junit.Test;++import com.pmease.commons.antlr.codeassist.CodeAssist;+import com.pmease.commons.antlr.codeassist.InputCompletion;+import com.pmease.commons.antlr.codeassist.InputStatus;+import com.pmease.commons.antlr.codeassist.InputSuggestion;+import com.pmease.commons.antlr.codeassist.ParentedElement;++public class CodeAssistTest4 {++ private CodeAssist codeAssist = new CodeAssist(CodeAssistTest4Lexer.class) {++ private static final long serialVersionUID = 1L;++ @Override+ protected List<InputSuggestion> suggest(ParentedElement element, String matchWith, int count) {+ return null;+ }++ };++ private List<InputStatus> suggest(InputStatus inputStatus, String ruleName) {+ List<InputStatus> suggestions = new ArrayList<>();+ for (InputCompletion completion: codeAssist.suggest(inputStatus, ruleName, Integer.MAX_VALUE))+ suggestions.add(completion.complete(inputStatus));+ return suggestions;+ }++ @Test+ public void test() {+ List<InputStatus> suggestions;++ suggestions = suggest(new InputStatus("a"), "stat");+ assertEquals(6, suggestions.size());+ assertEquals("a+:2", suggestions.get(0).toString());+ assertEquals("a-:2", suggestions.get(1).toString());+ assertEquals("a*:2", suggestions.get(2).toString());+ assertEquals("a/:2", suggestions.get(3).toString());+ assertEquals("a;:2", suggestions.get(4).toString());+ assertEquals("a=:2", suggestions.get(5).toString());++ suggestions = suggest(new InputStatus(""), "stat");+ assertEquals(2, suggestions.size());+ assertEquals("(:1", suggestions.get(0).toString());+ assertEquals(";:1", suggestions.get(1).toString());++ suggestions = suggest(new InputStatus("5*"), "stat");+ assertEquals(1, suggestions.size());+ assertEquals("5*(:3", suggestions.get(0).toString());++ suggestions = suggest(new InputStatus("5"), "stat");+ assertEquals(5, suggestions.size());+ assertEquals("5+:2", suggestions.get(0).toString());+ assertEquals("5-:2", suggestions.get(1).toString());+ assertEquals("5*:2", suggestions.get(2).toString());+ assertEquals("5/:2", suggestions.get(3).toString());+ assertEquals("5;:2", suggestions.get(4).toString());+ }++}diff --git a/commons.antlr/src/test/java/com/pmease/commons/antlr/codeassist/test/CodeAssistTest5.java b/commons.antlr/src/test/java/com/pmease/commons/antlr/codeassist/test/CodeAssistTest5.javaindex 2ad9ddee95..e348b34fd2 100644--- a/commons.antlr/src/test/java/com/pmease/commons/antlr/codeassist/test/CodeAssistTest5.java+++ b/commons.antlr/src/test/java/com/pmease/commons/antlr/codeassist/test/CodeAssistTest5.java@@ -1,146 +1,146 @@-package com.pmease.commons.antlr.codeassist.test;--import static org.junit.Assert.assertEquals;--import java.util.ArrayList;-import java.util.LinkedHashMap;-import java.util.List;-import java.util.Map;--import org.junit.Test;--import com.google.common.collect.Lists;-import com.pmease.commons.antlr.codeassist.CodeAssist;-import com.pmease.commons.antlr.codeassist.InputCompletion;-import com.pmease.commons.antlr.codeassist.InputStatus;-import com.pmease.commons.antlr.codeassist.InputSuggestion;-import com.pmease.commons.antlr.codeassist.ParentedElement;-import com.pmease.commons.antlr.grammar.ElementSpec;-import com.pmease.commons.antlr.grammar.LexerRuleRefElementSpec;-import com.pmease.commons.antlr.grammar.RuleRefElementSpec;-import com.pmease.commons.antlr.parser.Element;--/**- * This test case uses MySQL select grammar.- *- * @author robin- *- */-public class CodeAssistTest5 {-- private static final Map<String, List<String>> SCHEMA_TABLES = new LinkedHashMap<>();-- private static final Map<String, List<String>> TABLE_COLUMNS = new LinkedHashMap<>();-- private static final String DEFAULT_SCHEMA = "schemaA";-- static {- SCHEMA_TABLES.put("schemaA", Lists.newArrayList("tableA", "tableB"));- SCHEMA_TABLES.put("schemaB", Lists.newArrayList("tableC", "tableD"));- TABLE_COLUMNS.put("tableA", Lists.newArrayList("columnA", "columnB"));- TABLE_COLUMNS.put("tableB", Lists.newArrayList("columnC", "columnD"));- TABLE_COLUMNS.put("tableC", Lists.newArrayList("columnE", "columnF"));- TABLE_COLUMNS.put("tableD", Lists.newArrayList("columnG", "columnH"));- }-- private CodeAssist codeAssist = new CodeAssist(CodeAssistTest5Lexer.class,- new String[]{- "com/pmease/commons/antlr/codeassist/test/CodeAssistTest5Lexer.g4",- "com/pmease/commons/antlr/codeassist/test/CodeAssistTest5Parser.g4"},- "CodeAssistTest5Parser.tokens") {-- private static final long serialVersionUID = 1L;-- @Override- protected List<InputSuggestion> suggest(final ParentedElement element, String matchWith, int count) {- ElementSpec spec = element.getSpec();- if (spec instanceof RuleRefElementSpec) {- RuleRefElementSpec ruleElementSpec = (RuleRefElementSpec) spec;- if (ruleElementSpec.getRuleName().equals("schema_name")) {- List<InputSuggestion> suggestions = new ArrayList<>();- for (String schemaName: SCHEMA_TABLES.keySet()) {- if (schemaName.startsWith(matchWith))- suggestions.add(new InputSuggestion(schemaName));- }- return suggestions;- }- } else if (spec instanceof LexerRuleRefElementSpec) {- LexerRuleRefElementSpec lexerRuleRefElementSpec = (LexerRuleRefElementSpec) spec;- if ("tableName".equals(lexerRuleRefElementSpec.getLabel())) {- List<InputSuggestion> suggestions = new ArrayList<>();- Element columnNameElement = element.findParentByRule("column_name");- String schemaName;- List<Element> schemaNameElements = columnNameElement.findChildrenByRule("schema_name", true);- if (!schemaNameElements.isEmpty())- schemaName = schemaNameElements.get(0).getMatchedText();- else- schemaName = DEFAULT_SCHEMA;- if (SCHEMA_TABLES.containsKey(schemaName)) {- for (String tableName: SCHEMA_TABLES.get(schemaName)) {- if (tableName.startsWith(matchWith))- suggestions.add(new InputSuggestion(tableName));- }- }- return suggestions;- } else if ("columnName".equals(lexerRuleRefElementSpec.getLabel())) {- List<InputSuggestion> suggestions = new ArrayList<>();- Element columnNameElement = element.findParentByRule("column_name");- List<Element> tableNameElements = columnNameElement.findChildrenByLabel("tableName", true);- if (!tableNameElements.isEmpty()) {- String tableName = tableNameElements.get(0).getMatchedText();- if (TABLE_COLUMNS.containsKey(tableName)) {- for (String columnName: TABLE_COLUMNS.get(tableName)) {- if (columnName.startsWith(matchWith))- suggestions.add(new InputSuggestion(columnName));- }- }- }- return suggestions;- }- }- return null;- }-- @Override- protected InputSuggestion wrapAsSuggestion(ParentedElement expectedElement, String literal, boolean complete) {- if (literal.length() > 1)- return super.wrapAsSuggestion(expectedElement, literal, complete);- else- return null;- }-- };-- private List<InputStatus> suggest(InputStatus inputStatus, String ruleName) {- List<InputStatus> suggestions = new ArrayList<>();- for (InputCompletion completion: codeAssist.suggest(inputStatus, ruleName, Integer.MAX_VALUE))- suggestions.add(completion.complete(inputStatus));- return suggestions;- }-- @Test- public void test() {- List<InputStatus> suggestions;-- suggestions = suggest(new InputStatus("select tableC."), "stat");- assertEquals(2, suggestions.size());- assertEquals("select tableC.columnE:21", suggestions.get(0).toString());- assertEquals("select tableC.columnF:21", suggestions.get(1).toString());-- suggestions = suggest(new InputStatus("select schemaB."), "stat");- assertEquals(2, suggestions.size());- assertEquals("select schemaB.tableC.:22", suggestions.get(0).toString());- assertEquals("select schemaB.tableD.:22", suggestions.get(1).toString());-- suggestions = suggest(new InputStatus("select schema"), "stat");- assertEquals(2, suggestions.size());- assertEquals("select schemaA.:15", suggestions.get(0).toString());- assertEquals("select schemaB.:15", suggestions.get(1).toString());-- suggestions = suggest(new InputStatus("select table"), "stat");- assertEquals(2, suggestions.size());- assertEquals("select tableA.:14", suggestions.get(0).toString());- assertEquals("select tableB.:14", suggestions.get(1).toString());- }--}+package com.pmease.commons.antlr.codeassist.test;++import static org.junit.Assert.assertEquals;++import java.util.ArrayList;+import java.util.LinkedHashMap;+import java.util.List;+import java.util.Map;++import org.junit.Test;++import com.google.common.collect.Lists;+import com.pmease.commons.antlr.codeassist.CodeAssist;+import com.pmease.commons.antlr.codeassist.InputCompletion;+import com.pmease.commons.antlr.codeassist.InputStatus;+import com.pmease.commons.antlr.codeassist.InputSuggestion;+import com.pmease.commons.antlr.codeassist.ParentedElement;+import com.pmease.commons.antlr.grammar.ElementSpec;+import com.pmease.commons.antlr.grammar.LexerRuleRefElementSpec;+import com.pmease.commons.antlr.grammar.RuleRefElementSpec;+import com.pmease.commons.antlr.parser.Element;++/**+ * This test case uses MySQL select grammar.+ *+ * @author robin+ *+ */+public class CodeAssistTest5 {++ private static final Map<String, List<String>> SCHEMA_TABLES = new LinkedHashMap<>();++ private static final Map<String, List<String>> TABLE_COLUMNS = new LinkedHashMap<>();++ private static final String DEFAULT_SCHEMA = "schemaA";++ static {+ SCHEMA_TABLES.put("schemaA", Lists.newArrayList("tableA", "tableB"));+ SCHEMA_TABLES.put("schemaB", Lists.newArrayList("tableC", "tableD"));+ TABLE_COLUMNS.put("tableA", Lists.newArrayList("columnA", "columnB"));+ TABLE_COLUMNS.put("tableB", Lists.newArrayList("columnC", "columnD"));+ TABLE_COLUMNS.put("tableC", Lists.newArrayList("columnE", "columnF"));+ TABLE_COLUMNS.put("tableD", Lists.newArrayList("columnG", "columnH"));+ }++ private CodeAssist codeAssist = new CodeAssist(CodeAssistTest5Lexer.class,+ new String[]{+ "com/pmease/commons/antlr/codeassist/test/CodeAssistTest5Lexer.g4",+ "com/pmease/commons/antlr/codeassist/test/CodeAssistTest5Parser.g4"},+ "CodeAssistTest5Parser.tokens") {++ private static final long serialVersionUID = 1L;++ @Override+ protected List<InputSuggestion> suggest(final ParentedElement element, String matchWith, int count) {+ ElementSpec spec = element.getSpec();+ if (spec instanceof RuleRefElementSpec) {+ RuleRefElementSpec ruleElementSpec = (RuleRefElementSpec) spec;+ if (ruleElementSpec.getRuleName().equals("schema_name")) {+ List<InputSuggestion> suggestions = new ArrayList<>();+ for (String schemaName: SCHEMA_TABLES.keySet()) {+ if (schemaName.startsWith(matchWith))+ suggestions.add(new InputSuggestion(schemaName));+ }+ return suggestions;+ }+ } else if (spec instanceof LexerRuleRefElementSpec) {+ LexerRuleRefElementSpec lexerRuleRefElementSpec = (LexerRuleRefElementSpec) spec;+ if ("tableName".equals(lexerRuleRefElementSpec.getLabel())) {+ List<InputSuggestion> suggestions = new ArrayList<>();+ Element columnNameElement = element.findParentByRule("column_name");+ String schemaName;+ List<Element> schemaNameElements = columnNameElement.findChildrenByRule("schema_name", true);+ if (!schemaNameElements.isEmpty())+ schemaName = schemaNameElements.get(0).getMatchedText();+ else+ schemaName = DEFAULT_SCHEMA;+ if (SCHEMA_TABLES.containsKey(schemaName)) {+ for (String tableName: SCHEMA_TABLES.get(schemaName)) {+ if (tableName.startsWith(matchWith))+ suggestions.add(new InputSuggestion(tableName));+ }+ }+ return suggestions;+ } else if ("columnName".equals(lexerRuleRefElementSpec.getLabel())) {+ List<InputSuggestion> suggestions = new ArrayList<>();+ Element columnNameElement = element.findParentByRule("column_name");+ List<Element> tableNameElements = columnNameElement.findChildrenByLabel("tableName", true);+ if (!tableNameElements.isEmpty()) {+ String tableName = tableNameElements.get(0).getMatchedText();+ if (TABLE_COLUMNS.containsKey(tableName)) {+ for (String columnName: TABLE_COLUMNS.get(tableName)) {+ if (columnName.startsWith(matchWith))+ suggestions.add(new InputSuggestion(columnName));+ }+ }+ }+ return suggestions;+ }+ }+ return null;+ }++ @Override+ protected InputSuggestion wrapAsSuggestion(ParentedElement expectedElement, String literal, boolean complete) {+ if (literal.length() > 1)+ return super.wrapAsSuggestion(expectedElement, literal, complete);+ else+ return null;+ }++ };++ private List<InputStatus> suggest(InputStatus inputStatus, String ruleName) {+ List<InputStatus> suggestions = new ArrayList<>();+ for (InputCompletion completion: codeAssist.suggest(inputStatus, ruleName, Integer.MAX_VALUE))+ suggestions.add(completion.complete(inputStatus));+ return suggestions;+ }++ @Test+ public void test() {+ List<InputStatus> suggestions;++ suggestions = suggest(new InputStatus("select tableC."), "stat");+ assertEquals(2, suggestions.size());+ assertEquals("select tableC.columnE:21", suggestions.get(0).toString());+ assertEquals("select tableC.columnF:21", suggestions.get(1).toString());++ suggestions = suggest(new InputStatus("select schemaB."), "stat");+ assertEquals(2, suggestions.size());+ assertEquals("select schemaB.tableC.:22", suggestions.get(0).toString());+ assertEquals("select schemaB.tableD.:22", suggestions.get(1).toString());++ suggestions = suggest(new InputStatus("select schema"), "stat");+ assertEquals(2, suggestions.size());+ assertEquals("select schemaA.:15", suggestions.get(0).toString());+ assertEquals("select schemaB.:15", suggestions.get(1).toString());++ suggestions = suggest(new InputStatus("select table"), "stat");+ assertEquals(2, suggestions.size());+ assertEquals("select tableA.:14", suggestions.get(0).toString());+ assertEquals("select tableB.:14", suggestions.get(1).toString());+ }++}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 63d23ecf14..61e98b42a9 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@@ -99,13 +99,12 @@ class AssistPanel extends Panel {if (label == null)label = suggestion.getReplaceContent();if (matchRange != null) {- String content = suggestion.getReplaceContent();- String prefix = StringEscapeUtils.escapeHtml4(content.substring(0, matchRange.getFrom()));- String suffix = StringEscapeUtils.escapeHtml4(content.substring(matchRange.getTo()));- String matched = StringEscapeUtils.escapeHtml4(content.substring(matchRange.getFrom(), matchRange.getTo()));+ String prefix = StringEscapeUtils.escapeHtml4(label.substring(0, matchRange.getFrom()));+ String suffix = StringEscapeUtils.escapeHtml4(label.substring(matchRange.getTo()));+ String matched = StringEscapeUtils.escapeHtml4(label.substring(matchRange.getFrom(), matchRange.getTo()));link.add(new Label("label", prefix + "<b>" + matched + "</b>" + suffix).setEscapeModelStrings(false));} else {- link.add(new Label("label", suggestion.getReplaceContent()));+ link.add(new Label("label", label));}item.add(link);if (suggestion.getDescription() != null)diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/model/Depot.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/model/Depot.javaindex dec399e369..4bf3df5114 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/model/Depot.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/model/Depot.java@@ -465,6 +465,17 @@ public class Depot extends AbstractEntity implements UserBelonging {affinals.add(this);affinals.addAll(findForkDescendants());}+ Collections.sort(affinals, new Comparator<Depot>() {++ @Override+ public int compare(Depot repo1, Depot repo2) {+ if (repo1.getUser().equals(repo2.getUser()))+ return repo1.getName().compareTo(repo2.getName());+ else+ return repo1.getUser().getName().compareTo(repo2.getUser().getName());+ }++ });return affinals;}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 5720bf1a88..756bac1f8c 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@@ -7,16 +7,14 @@ criteria: includeMatch | excludeMatch;includeMatch: INCLUDE '(' fullBranchMatch ')';excludeMatch: EXCLUDE '(' fullBranchMatch ')';-fullBranchMatch: accountMatch ':' depotMatch ':' branchMatch | depotMatch ':' branchMatch | branchMatch;+fullBranchMatch: depotMatch ':' branchMatch | branchMatch;-accountMatch: ACCOUNT Value;-depotMatch: REPOSITORY Value;+depotMatch: DEPOT depotFQN=Value;branchMatch: BRANCH Value;INCLUDE: 'include';EXCLUDE: 'exclude';-ACCOUNT: 'account';-REPOSITORY: 'repository';+DEPOT: 'repository';BRANCH: 'branch';Value: '(' (ESCAPE|~[()\\])+? ')';diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/util/fullbranchmatch/FullBranchMatchUtils.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/util/fullbranchmatch/FullBranchMatchUtils.javaindex fd822405d1..24a3bd9812 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/util/fullbranchmatch/FullBranchMatchUtils.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/util/fullbranchmatch/FullBranchMatchUtils.java@@ -7,6 +7,7 @@ import org.antlr.v4.runtime.ANTLRInputStream;import org.antlr.v4.runtime.BailErrorStrategy;import org.antlr.v4.runtime.CommonTokenStream;import org.antlr.v4.runtime.tree.TerminalNode;+import org.apache.commons.lang3.StringUtils;import com.pmease.commons.util.match.IncludeExclude;import com.pmease.commons.util.match.RuleMatcher;@@ -51,19 +52,20 @@ public class FullBranchMatchUtils {@Overridepublic boolean matches(FullBranchMatchContext rule, DepotAndBranch value) {- if (rule.accountMatch() != null) {- String accountPattern = getValue(rule.accountMatch().Value());- String depotPattern = getValue(rule.depotMatch().Value());+ if (rule.depotMatch() != null) {+ String fullDepotPattern = getValue(rule.depotMatch().Value());String branchPattern = getValue(rule.branchMatch().Value());- return WildcardUtils.matchString(accountPattern, value.getDepot().getUser().getName())- && WildcardUtils.matchString(depotPattern, value.getDepot().getName())- && WildcardUtils.matchString(branchPattern, value.getBranch());- } else if (rule.depotMatch() != null) {- String depotPattern = getValue(rule.depotMatch().Value());- String branchPattern = getValue(rule.branchMatch().Value());- return value.getDepot().getUser().equals(currentDepot.getUser())- && WildcardUtils.matchString(depotPattern, value.getDepot().getName())- && WildcardUtils.matchString(branchPattern, value.getBranch());+ if (fullDepotPattern.indexOf("/") != -1) {+ String accountPattern = StringUtils.substringBefore(fullDepotPattern, "/");+ String depotPattern = StringUtils.substringAfter(fullDepotPattern, "/");+ return WildcardUtils.matchString(accountPattern, value.getDepot().getUser().getName())+ && WildcardUtils.matchString(depotPattern, value.getDepot().getName())+ && WildcardUtils.matchString(branchPattern, value.getBranch());+ } else {+ return value.getDepot().getUser().equals(currentDepot.getUser())+ && WildcardUtils.matchString(fullDepotPattern, value.getDepot().getName())+ && WildcardUtils.matchString(branchPattern, value.getBranch());+ }} else {String branchPattern = getValue(rule.branchMatch().Value());return value.getDepot().equals(currentDepot)diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/branchpicker/AffinalBranchPicker.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/branchpicker/AffinalBranchPicker.javaindex e0c3b75fcb..99f6cee751 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/branchpicker/AffinalBranchPicker.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/branchpicker/AffinalBranchPicker.java@@ -13,7 +13,7 @@ import com.pmease.commons.hibernate.dao.Dao;import com.pmease.gitplex.core.GitPlex;import com.pmease.gitplex.core.model.Depot;import com.pmease.gitplex.web.component.repopicker.RepositoryPicker;-import com.pmease.gitplex.web.model.AffinalRepositoriesModel;+import com.pmease.gitplex.web.model.AffinalDepotsModel;@SuppressWarnings("serial")public abstract class AffinalBranchPicker extends Panel {@@ -61,7 +61,7 @@ public abstract class AffinalBranchPicker extends Panel {protected void onInitialize() {super.onInitialize();- add(new RepositoryPicker("repositoryPicker", new AffinalRepositoriesModel(depotId), depotId) {+ add(new RepositoryPicker("repositoryPicker", new AffinalDepotsModel(depotId), depotId) {@Overrideprotected void onSelect(AjaxRequestTarget target, Depot depot) {diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/fullbranchmatch/FullBranchMatchBehavior.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/fullbranchmatch/FullBranchMatchBehavior.javaindex d2917ece74..dd2e2fb28e 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/fullbranchmatch/FullBranchMatchBehavior.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/fullbranchmatch/FullBranchMatchBehavior.java@@ -11,9 +11,13 @@ import com.pmease.commons.antlr.codeassist.InputSuggestion;import com.pmease.commons.antlr.codeassist.ParentedElement;import com.pmease.commons.antlr.grammar.ElementSpec;import com.pmease.commons.antlr.grammar.LexerRuleRefElementSpec;+import com.pmease.commons.antlr.parser.Element;import com.pmease.commons.wicket.behavior.inputassist.ANTLRAssistBehavior;+import com.pmease.gitplex.core.GitPlex;+import com.pmease.gitplex.core.manager.DepotManager;import com.pmease.gitplex.core.model.Depot;import com.pmease.gitplex.core.util.fullbranchmatch.FullBranchMatchParser;+import com.pmease.gitplex.web.page.depot.DepotPage;import com.pmease.gitplex.web.util.SuggestionUtils;@SuppressWarnings("serial")@@ -45,7 +49,28 @@ public class FullBranchMatchBehavior extends ANTLRAssistBehavior {@Overrideprotected List<InputSuggestion> match(String unfencedMatchWith) {- return SuggestionUtils.suggestBranch(depotModel.getObject(), unfencedMatchWith, count);+ int tokenType = expectedElement.getRoot().getLastMatchedToken().getType();+ DepotPage page = (DepotPage) getComponent().getPage();+ Depot depot = page.getDepot();+ if (tokenType == FullBranchMatchParser.DEPOT) {+ return SuggestionUtils.suggestAffinals(depot, unfencedMatchWith, count);+ } else {+ ParentedElement criteriaElement = expectedElement.findParentByRule("criteria");+ List<Element> depotFQNElements = criteriaElement.findChildrenByLabel("depotFQN", true);+ if (!depotFQNElements.isEmpty()) {+ Element depotFQNElement = depotFQNElements.get(0);+ String branchDepotFQN = depotFQNElement.getMatchedText().trim().substring(1);+ branchDepotFQN = branchDepotFQN.substring(0, branchDepotFQN.length()-1);+ Depot branchDepot = GitPlex.getInstance(DepotManager.class).findBy(branchDepotFQN);+ if (branchDepot != null) {+ return SuggestionUtils.suggestBranch(branchDepot, unfencedMatchWith, count);+ } else {+ return new ArrayList<>();+ }+ } else {+ return SuggestionUtils.suggestBranch(depot, unfencedMatchWith, count);+ }+ }}@Override@@ -59,6 +84,28 @@ public class FullBranchMatchBehavior extends ANTLRAssistBehavior {return null;}+ @Override+ protected InputSuggestion wrapAsSuggestion(ParentedElement expectedElement,+ String suggestedLiteral, boolean complete) {+ String description;+ switch (suggestedLiteral) {+ case "repository":+ description = "specify repository of source branches";+ break;+ case "branch":+ ParentedElement criteriaElement = expectedElement.findParentByRule("criteria");+ if (!criteriaElement.findChildrenByRule("depotMatch", true).isEmpty()) {+ description = "";+ } else {+ description = "";+ }+ break;+ default:+ description = null;+ }+ return new InputSuggestion(suggestedLiteral, description, null);+ }+@Overrideprotected List<String> getHints(ParentedElement expectedElement, String matchWith) {List<String> hints = new ArrayList<>();diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repochoice/AffinalDepotChoiceProvider.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repochoice/AffinalDepotChoiceProvider.javaindex 5f3253be9a..3a5a5cda1c 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repochoice/AffinalDepotChoiceProvider.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repochoice/AffinalDepotChoiceProvider.java@@ -15,7 +15,7 @@ import com.pmease.commons.wicket.component.select2.ListChoiceProvider;import com.pmease.gitplex.core.GitPlex;import com.pmease.gitplex.core.model.Depot;import com.pmease.gitplex.web.Constants;-import com.pmease.gitplex.web.model.AffinalRepositoriesModel;+import com.pmease.gitplex.web.model.AffinalDepotsModel;@SuppressWarnings("serial")public class AffinalDepotChoiceProvider extends ListChoiceProvider<Depot> {@@ -28,7 +28,7 @@ public class AffinalDepotChoiceProvider extends ListChoiceProvider<Depot> {super(Constants.DEFAULT_PAGE_SIZE);this.depotId = repoId;- affinalDepotsModel = new AffinalRepositoriesModel(repoId);+ affinalDepotsModel = new AffinalDepotsModel(repoId);}@Override@@ -61,7 +61,7 @@ public class AffinalDepotChoiceProvider extends ListChoiceProvider<Depot> {return GitPlex.getInstance(Dao.class).load(Depot.class, depotId);}- private List<Depot> getAffinalRepositories() {+ private List<Depot> getAffinalDepots() {return affinalDepotsModel.getObject();}@@ -76,7 +76,7 @@ public class AffinalDepotChoiceProvider extends ListChoiceProvider<Depot> {protected List<Depot> filterList(String term) {term = term.toLowerCase();List<Depot> depots = new ArrayList<>();- for (Depot depot: getAffinalRepositories()) {+ for (Depot depot: getAffinalDepots()) {if (depot.getOwner().getName().toLowerCase().startsWith(term))depots.add(depot);}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/revisionpicker/AffinalRevisionPicker.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/revisionpicker/AffinalRevisionPicker.javaindex 719504dbda..3281435546 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/revisionpicker/AffinalRevisionPicker.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/revisionpicker/AffinalRevisionPicker.java@@ -13,7 +13,7 @@ import com.pmease.commons.hibernate.dao.Dao;import com.pmease.gitplex.core.GitPlex;import com.pmease.gitplex.core.model.Depot;import com.pmease.gitplex.web.component.repopicker.RepositoryPicker;-import com.pmease.gitplex.web.model.AffinalRepositoriesModel;+import com.pmease.gitplex.web.model.AffinalDepotsModel;@SuppressWarnings("serial")public abstract class AffinalRevisionPicker extends Panel {@@ -61,7 +61,7 @@ public abstract class AffinalRevisionPicker extends Panel {protected void onInitialize() {super.onInitialize();- add(new RepositoryPicker("repositoryPicker", new AffinalRepositoriesModel(depotId), depotId) {+ add(new RepositoryPicker("repositoryPicker", new AffinalDepotsModel(depotId), depotId) {@Overrideprotected void onSelect(AjaxRequestTarget target, Depot depot) {diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/model/AffinalRepositoriesModel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/model/AffinalDepotsModel.javasimilarity index 91%rename from gitplex.web/src/main/java/com/pmease/gitplex/web/model/AffinalRepositoriesModel.javarename to gitplex.web/src/main/java/com/pmease/gitplex/web/model/AffinalDepotsModel.javaindex a1b3e1f55e..85c2052a4a 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/model/AffinalRepositoriesModel.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/model/AffinalDepotsModel.java@@ -14,11 +14,11 @@ import com.pmease.gitplex.core.model.Depot;import com.pmease.gitplex.core.permission.ObjectPermission;@SuppressWarnings("serial")-public class AffinalRepositoriesModel extends LoadableDetachableModel<List<Depot>> {+public class AffinalDepotsModel extends LoadableDetachableModel<List<Depot>> {private final Long repoId;- public AffinalRepositoriesModel(Long repoId) {+ public AffinalDepotsModel(Long repoId) {this.repoId = repoId;}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/util/SuggestionUtils.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/util/SuggestionUtils.javaindex 2a783d03d4..7332f680fd 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/util/SuggestionUtils.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/util/SuggestionUtils.java@@ -35,6 +35,21 @@ public class SuggestionUtils {return suggestions;}+ public static List<InputSuggestion> suggestAffinals(Depot depot, String matchWith, int count) {+ String lowerCaseMatchWith = matchWith.toLowerCase();+ int numSuggestions = 0;+ List<InputSuggestion> suggestions = new ArrayList<>();+ for (Depot affinal: depot.findAffinals()) {+ String FQN = affinal.getFQN();+ int index = FQN.toLowerCase().indexOf(lowerCaseMatchWith);+ if (index != -1 && numSuggestions++<count) {+ Range matchRange = new Range(index, index+lowerCaseMatchWith.length());+ suggestions.add(new InputSuggestion(FQN, matchRange));+ }+ }+ return suggestions;+ }+public static List<InputSuggestion> suggestTag(Depot depot, String matchWith, int count) {String lowerCaseMatchWith = matchWith.toLowerCase();int numSuggestions = 0;