浏览代码

Merge pull request #731 from csmith/master

Kill TabCompletionMatches.
pull/732/head
Greg Holmes 7 年前
父节点
当前提交
4dc25ba7f6

+ 8
- 6
src/main/java/com/dmdirc/ui/input/TabCompleter.java 查看文件

@@ -23,11 +23,12 @@
23 23
 package com.dmdirc.ui.input;
24 24
 
25 25
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
26
-
27 26
 import com.google.common.collect.ArrayListMultimap;
28 27
 import com.google.common.collect.Multimap;
29 28
 
30 29
 import javax.annotation.Nullable;
30
+import java.util.ArrayList;
31
+import java.util.List;
31 32
 
32 33
 /**
33 34
  * The tab completer handles a user's request to tab complete some word.
@@ -75,9 +76,8 @@ public class TabCompleter {
75 76
      *
76 77
      * @return A TabCompleterResult containing any matches found
77 78
      */
78
-    public TabCompletionMatches complete(final String partial,
79
-            @Nullable final AdditionalTabTargets additionals) {
80
-        final TabCompletionMatches result = new TabCompletionMatches();
79
+    public List<String> complete(final String partial, @Nullable final AdditionalTabTargets additionals) {
80
+        final List<String> result = new ArrayList<>();
81 81
 
82 82
         final boolean caseSensitive = configManager.getOptionBool("tabcompletion", "casesensitive");
83 83
         final boolean allowEmpty = configManager.getOptionBool("tabcompletion", "allowempty");
@@ -103,14 +103,16 @@ public class TabCompleter {
103 103
                 // Filter out duplicates
104 104
                 .distinct()
105 105
                 // Add them all to the result
106
-                .forEach(result::addResult);
106
+                .forEach(result::add);
107 107
 
108 108
         if (parent != null) {
109 109
             if (additionals != null) {
110 110
                 additionals.clear();
111 111
             }
112 112
 
113
-            result.merge(parent.complete(partial, additionals));
113
+            parent.complete(partial, additionals).stream()
114
+                    .filter(match -> !result.contains(match))
115
+                    .forEach(result::add);
114 116
         }
115 117
 
116 118
         return result;

+ 0
- 100
src/main/java/com/dmdirc/ui/input/TabCompletionMatches.java 查看文件

@@ -1,100 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2015 DMDirc Developers
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-
23
-package com.dmdirc.ui.input;
24
-
25
-import java.util.ArrayList;
26
-import java.util.Collections;
27
-import java.util.List;
28
-
29
-/**
30
- * Describes a set of matches from a tab completion attempt.
31
- *
32
- * @deprecated This class is dumb. Just use a List.
33
- */
34
-@Deprecated
35
-public class TabCompletionMatches extends ArrayList<String> {
36
-
37
-    /**
38
-     * Adds a result to this result set.
39
-     *
40
-     * @param result The result to be added
41
-     */
42
-    public void addResult(final String result) {
43
-        add(result);
44
-    }
45
-
46
-    /**
47
-     * Determines if this result set contains the specified result.
48
-     *
49
-     * @param result The result to be tested
50
-     *
51
-     * @return True if this set contains the specified result, false otherwise
52
-     */
53
-    public boolean hasResult(final String result) {
54
-        return contains(result);
55
-    }
56
-
57
-    /**
58
-     * Merges the specified additional results with this result set.
59
-     *
60
-     * @param additional The results to merge
61
-     */
62
-    public void merge(final TabCompletionMatches additional) {
63
-        additional.getResults().stream().filter(result -> !hasResult(result))
64
-                .forEach(this::addResult);
65
-    }
66
-
67
-    /**
68
-     * Gets the total size of this result set.
69
-     *
70
-     * @return the size of this result set
71
-     */
72
-    public int getResultCount() {
73
-        return size();
74
-    }
75
-
76
-    /**
77
-     * Retrieves the list of results that this set contains.
78
-     *
79
-     * @return An unmodifiable list containing the results
80
-     */
81
-    public List<String> getResults() {
82
-        return Collections.unmodifiableList(this);
83
-    }
84
-
85
-    @Override
86
-    public String toString() {
87
-        final StringBuilder buff = new StringBuilder();
88
-
89
-        for (String entry : this) {
90
-            if (buff.length() > 0) {
91
-                buff.append(", ");
92
-            }
93
-
94
-            buff.append(entry);
95
-        }
96
-
97
-        return buff.toString();
98
-    }
99
-
100
-}

正在加载...
取消
保存