瀏覽代碼

Stop TabCompleter depending on CommandManager.

pull/597/head
Chris Smith 9 年之前
父節點
當前提交
0a7fb8b874

+ 14
- 5
src/com/dmdirc/commandparser/CommandManager.java 查看文件

@@ -163,11 +163,14 @@ public class CommandManager implements CommandController {
163 163
     private void registerCommandName(final CommandInfo command,
164 164
             final boolean register) {
165 165
         // Do tab completion
166
-        final String commandName = getCommandChar() + command.getName();
166
+        final String plainCommandName = getCommandChar() + command.getName();
167
+        final String silencedCommandName = getCommandChar() + getSilenceChar() + command.getName();
167 168
 
168 169
         if (command.getType() == CommandType.TYPE_GLOBAL) {
169 170
             registerCommandName(globalWindowProvider.get().getTabCompleter(),
170
-                    commandName, register);
171
+                    plainCommandName, register);
172
+            registerCommandName(globalWindowProvider.get().getTabCompleter(),
173
+                    silencedCommandName, register);
171 174
         }
172 175
 
173 176
         // TODO: This logic is probably in two places. Abstract it.
@@ -175,14 +178,18 @@ public class CommandManager implements CommandController {
175 178
             if (command.getType() == CommandType.TYPE_SERVER
176 179
                     || command.getType() == CommandType.TYPE_GLOBAL) {
177 180
                 registerCommandName(server.getWindowModel().getTabCompleter(),
178
-                        commandName, register);
181
+                        plainCommandName, register);
182
+                registerCommandName(server.getWindowModel().getTabCompleter(),
183
+                        silencedCommandName, register);
179 184
             }
180 185
 
181 186
             if (command.getType() == CommandType.TYPE_CHANNEL
182 187
                     || command.getType() == CommandType.TYPE_CHAT) {
183 188
                 for (GroupChat channel : server.getGroupChatManager().getChannels()) {
184 189
                     registerCommandName(channel.getWindowModel().getTabCompleter(),
185
-                            commandName, register);
190
+                            plainCommandName, register);
191
+                    registerCommandName(channel.getWindowModel().getTabCompleter(),
192
+                            silencedCommandName, register);
186 193
                 }
187 194
             }
188 195
 
@@ -190,7 +197,9 @@ public class CommandManager implements CommandController {
190 197
                     || command.getType() == CommandType.TYPE_CHAT) {
191 198
                 for (Query query : server.getQueries()) {
192 199
                     registerCommandName(query.getTabCompleter(),
193
-                            commandName, register);
200
+                            plainCommandName, register);
201
+                    registerCommandName(query.getTabCompleter(),
202
+                            silencedCommandName, register);
194 203
                 }
195 204
             }
196 205
         }

+ 1
- 20
src/com/dmdirc/ui/input/TabCompleter.java 查看文件

@@ -22,7 +22,6 @@
22 22
 
23 23
 package com.dmdirc.ui.input;
24 24
 
25
-import com.dmdirc.interfaces.CommandController;
26 25
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
27 26
 
28 27
 import com.google.common.collect.ArrayListMultimap;
@@ -42,38 +41,29 @@ public class TabCompleter {
42 41
     private final TabCompleter parent;
43 42
     /** The config manager to use for reading settings. */
44 43
     private final AggregateConfigProvider configManager;
45
-    /** The controller to use to retrieve command information. */
46
-    private final CommandController commandController;
47 44
     /** The entries in this completer. */
48 45
     private final Multimap<TabCompletionType, String> entries = ArrayListMultimap.create();
49 46
 
50 47
     /**
51 48
      * Creates a new instance of {@link TabCompleter}.
52 49
      *
53
-     * @param commandController The controller to use for command information.
54 50
      * @param configManager     The manager to read config settings from.
55 51
      */
56
-    public TabCompleter(
57
-            final CommandController commandController,
58
-            final AggregateConfigProvider configManager) {
52
+    public TabCompleter(final AggregateConfigProvider configManager) {
59 53
         this.parent = null;
60
-        this.commandController = commandController;
61 54
         this.configManager = configManager;
62 55
     }
63 56
 
64 57
     /**
65 58
      * Creates a new instance of {@link TabCompleter}.
66 59
      *
67
-     * @param commandController The controller to use for command information.
68 60
      * @param configManager     The manager to read config settings from.
69 61
      * @param parent            The parent tab completer to inherit completions from.
70 62
      */
71 63
     public TabCompleter(
72
-            final CommandController commandController,
73 64
             final AggregateConfigProvider configManager,
74 65
             @Nullable final TabCompleter parent) {
75 66
         this.parent = parent;
76
-        this.commandController = commandController;
77 67
         this.configManager = configManager;
78 68
     }
79 69
 
@@ -134,15 +124,6 @@ public class TabCompleter {
134 124
      */
135 125
     public void addEntry(final TabCompletionType type, final String entry) {
136 126
         entries.put(type, entry);
137
-
138
-        if (type == TabCompletionType.COMMAND && entry.length() > 1
139
-                && entry.charAt(0) == commandController.getCommandChar()
140
-                && entry.charAt(1) != commandController.getSilenceChar()) {
141
-            // If we're adding a command name that doesn't include the silence
142
-            // character, also add a version with the silence char
143
-            addEntry(type, entry.substring(0, 1) + commandController.getSilenceChar()
144
-                    + entry.substring(1));
145
-        }
146 127
     }
147 128
 
148 129
     /**

+ 2
- 3
src/com/dmdirc/ui/input/TabCompleterFactory.java 查看文件

@@ -62,7 +62,7 @@ public class TabCompleterFactory {
62 62
     public TabCompleter getTabCompleter(
63 63
             final AggregateConfigProvider configProvider,
64 64
             final CommandType... commandTypes) {
65
-        final TabCompleter tabCompleter = new TabCompleter(commandController.get(), configProvider);
65
+        final TabCompleter tabCompleter = new TabCompleter(configProvider);
66 66
         addCommands(tabCompleter, commandTypes);
67 67
         return tabCompleter;
68 68
     }
@@ -81,8 +81,7 @@ public class TabCompleterFactory {
81 81
             final TabCompleter parent,
82 82
             final AggregateConfigProvider configProvider,
83 83
             final CommandType... commandTypes) {
84
-        final TabCompleter tabCompleter = new TabCompleter(commandController.get(),
85
-                configProvider, parent);
84
+        final TabCompleter tabCompleter = new TabCompleter(configProvider, parent);
86 85
         addCommands(tabCompleter, commandTypes);
87 86
         return tabCompleter;
88 87
     }

+ 1
- 4
test/com/dmdirc/harness/TestWritableFrameContainer.java 查看文件

@@ -26,7 +26,6 @@ import com.dmdirc.DMDircMBassador;
26 26
 import com.dmdirc.FrameContainer;
27 27
 import com.dmdirc.commandparser.CommandManager;
28 28
 import com.dmdirc.commandparser.parsers.GlobalCommandParser;
29
-import com.dmdirc.interfaces.CommandController;
30 29
 import com.dmdirc.interfaces.Connection;
31 30
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
32 31
 import com.dmdirc.ui.input.TabCompleter;
@@ -36,8 +35,6 @@ import com.dmdirc.ui.messages.sink.MessageSinkManager;
36 35
 import java.util.Collections;
37 36
 import java.util.Optional;
38 37
 
39
-import static org.mockito.Mockito.mock;
40
-
41 38
 public class TestWritableFrameContainer extends FrameContainer {
42 39
 
43 40
     private final int lineLength;
@@ -48,7 +45,7 @@ public class TestWritableFrameContainer extends FrameContainer {
48 45
             final DMDircMBassador eventBus,
49 46
             final BackBufferFactory backBufferFactory) {
50 47
         super(null, "raw", "Raw", "(Raw)", cm, backBufferFactory,
51
-                new TabCompleter(mock(CommandController.class), cm),
48
+                new TabCompleter(cm),
52 49
                 messageSinkManager,
53 50
                 eventBus,
54 51
                 Collections.<String>emptySet());

Loading…
取消
儲存