Browse Source

Deprecate old aliases and remove core refs.

Change-Id: I5de5f97b47cc856b8e751d6b168e27acca6bb3a6
Reviewed-on: http://gerrit.dmdirc.com/3548
Automatic-Compile: DMDirc Build Manager
Reviewed-by: Greg Holmes <greg@dmdirc.com>
pull/1/head
Chris Smith 10 years ago
parent
commit
6f02afbcb2

+ 0
- 6
src/com/dmdirc/ClientModule.java View File

@@ -25,7 +25,6 @@ package com.dmdirc;
25 25
 import com.dmdirc.actions.ActionFactory;
26 26
 import com.dmdirc.actions.ActionGroup;
27 27
 import com.dmdirc.actions.ActionManager;
28
-import com.dmdirc.actions.wrappers.AliasWrapper;
29 28
 import com.dmdirc.actions.wrappers.PerformWrapper;
30 29
 import com.dmdirc.commandline.CommandLineOptionsModule;
31 30
 import com.dmdirc.commandline.CommandLineOptionsModule.Directory;
@@ -271,11 +270,6 @@ public class ClientModule {
271 270
         return manager;
272 271
     }
273 272
 
274
-    @Provides(type = Provides.Type.SET)
275
-    public ActionGroup getAliasWrapper(final AliasWrapper aliasWrapper) {
276
-        return aliasWrapper;
277
-    }
278
-
279 273
     @Provides(type = Provides.Type.SET)
280 274
     @Singleton
281 275
     public ActionGroup getPerformWrapper(final PerformWrapper wrapper) {

+ 3
- 0
src/com/dmdirc/actions/wrappers/Alias.java View File

@@ -38,7 +38,10 @@ import java.util.List;
38 38
 
39 39
 /**
40 40
  * Actions alias wrapper.
41
+ *
42
+ * @deprecated Replaced by {@link com.dmdirc.commandparser.aliases.Alias}.
41 43
  */
44
+@Deprecated
42 45
 public class Alias implements Serializable {
43 46
 
44 47
     /** A version number for this class. */

+ 4
- 0
src/com/dmdirc/actions/wrappers/AliasWrapper.java View File

@@ -27,6 +27,7 @@ import com.dmdirc.actions.Action;
27 27
 import com.dmdirc.actions.ActionCondition;
28 28
 import com.dmdirc.actions.ActionGroup;
29 29
 import com.dmdirc.actions.CoreActionType;
30
+import com.dmdirc.commandparser.aliases.AliasManager;
30 31
 import com.dmdirc.interfaces.CommandController;
31 32
 import com.dmdirc.logger.ErrorLevel;
32 33
 import com.dmdirc.logger.Logger;
@@ -41,8 +42,11 @@ import javax.inject.Singleton;
41 42
 
42 43
 /**
43 44
  * Encapsulates alias actions.
45
+ *
46
+ * @deprecated Replaced by {@link AliasManager}.
44 47
  */
45 48
 @Singleton
49
+@Deprecated
46 50
 public class AliasWrapper extends ActionGroup {
47 51
 
48 52
     /** The name of the actions group we wrap. */

+ 0
- 5
src/com/dmdirc/plugins/PluginInjectorInitialiser.java View File

@@ -28,7 +28,6 @@ import com.dmdirc.ServerManager;
28 28
 import com.dmdirc.actions.ActionFactory;
29 29
 import com.dmdirc.actions.ActionManager;
30 30
 import com.dmdirc.actions.ActionSubstitutorFactory;
31
-import com.dmdirc.actions.wrappers.AliasWrapper;
32 31
 import com.dmdirc.actions.wrappers.PerformWrapper;
33 32
 import com.dmdirc.commandparser.CommandManager;
34 33
 import com.dmdirc.config.prefs.PreferencesManager;
@@ -56,7 +55,6 @@ public class PluginInjectorInitialiser {
56 55
 
57 56
     private final ActionManager actionManager;
58 57
     private final ActionFactory actionFactory;
59
-    private final AliasWrapper aliasWrapper;
60 58
     private final PluginManager pluginManager;
61 59
     private final IdentityController identityController;
62 60
     private final ServerManager serverManager;
@@ -78,7 +76,6 @@ public class PluginInjectorInitialiser {
78 76
     @Inject
79 77
     public PluginInjectorInitialiser(final ActionManager actionManager,
80 78
             final ActionFactory actionFactory,
81
-            final AliasWrapper aliasWrapper,
82 79
             final PluginManager pluginManager,
83 80
             final IdentityController identityController,
84 81
             final ServerManager serverManager,
@@ -98,7 +95,6 @@ public class PluginInjectorInitialiser {
98 95
             @GlobalConfig final IconManager iconManager) {
99 96
         this.actionManager = actionManager;
100 97
         this.actionFactory = actionFactory;
101
-        this.aliasWrapper = aliasWrapper;
102 98
         this.pluginManager = pluginManager;
103 99
         this.identityController = identityController;
104 100
         this.serverManager = serverManager;
@@ -134,7 +130,6 @@ public class PluginInjectorInitialiser {
134 130
         injector.addParameter(statusBarManager);
135 131
         injector.addParameter(PreferencesManager.class, preferencesManager);
136 132
         injector.addParameter(PerformWrapper.class, performWrapper);
137
-        injector.addParameter(AliasWrapper.class, aliasWrapper);
138 133
         injector.addParameter(LifecycleController.class, lifecycleController);
139 134
         injector.addParameter(corePluginExtractor);
140 135
         injector.addParameter(actionFactory);

+ 1
- 11
src/com/dmdirc/ui/input/TabCompleterFactory.java View File

@@ -22,7 +22,6 @@
22 22
 
23 23
 package com.dmdirc.ui.input;
24 24
 
25
-import com.dmdirc.actions.wrappers.AliasWrapper;
26 25
 import com.dmdirc.commandparser.CommandType;
27 26
 import com.dmdirc.interfaces.CommandController;
28 27
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
@@ -40,24 +39,16 @@ public class TabCompleterFactory {
40 39
 
41 40
     /** The command controller to use to find commands. */
42 41
     private final Provider<CommandController> commandController;
43
-    /** The alias wrapper to use for alias tab completion. */
44
-    // TODO: There should be an easy way to inject completion providers here, instead of
45
-    //       calling out the AliasWrapper in particular. Specifically, plugins should be able to
46
-    //       add things trivially.
47
-    private final Provider<AliasWrapper> aliasWrapper;
48 42
 
49 43
     /**
50 44
      * Creates a new instance of {@link TabCompleterFactory}.
51 45
      *
52 46
      * @param commandController The command controller to use to find commands.
53
-     * @param aliasWrapper      The alias wrapper to use for alias tab completion.
54 47
      */
55 48
     @Inject
56 49
     public TabCompleterFactory(
57
-            final Provider<CommandController> commandController,
58
-            final Provider<AliasWrapper> aliasWrapper) {
50
+            final Provider<CommandController> commandController) {
59 51
         this.commandController = commandController;
60
-        this.aliasWrapper = aliasWrapper;
61 52
     }
62 53
 
63 54
     /**
@@ -77,7 +68,6 @@ public class TabCompleterFactory {
77 68
             final CommandType... commandTypes) {
78 69
         final TabCompleter tabCompleter = new TabCompleter(commandController.get(), configProvider);
79 70
         addCommands(tabCompleter, commandTypes);
80
-        tabCompleter.addEntries(TabCompletionType.COMMAND, aliasWrapper.get().getAliases());
81 71
         return tabCompleter;
82 72
     }
83 73
 

+ 0
- 46
test/com/dmdirc/actions/wrappers/AliasTest.java View File

@@ -1,46 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2014 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.actions.wrappers;
24
-
25
-import com.dmdirc.actions.ActionFactory;
26
-
27
-import java.util.Arrays;
28
-
29
-import org.junit.Test;
30
-
31
-import static org.junit.Assert.*;
32
-import static org.mockito.Mockito.*;
33
-
34
-public class AliasTest {
35
-
36
-    @Test
37
-    public void testBasics() {
38
-        final Alias alias = new Alias(mock(ActionFactory.class), "testing");
39
-
40
-        assertEquals("testing", alias.getCommand());
41
-        assertEquals("testing-Any", alias.getName());
42
-        assertTrue(Arrays.equals(new String[]{""}, alias.getResponse()));
43
-        assertTrue(alias.matches(alias));
44
-    }
45
-
46
-}

+ 0
- 124
test/com/dmdirc/actions/wrappers/AliasWrapperTest.java View File

@@ -1,124 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2014 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.actions.wrappers;
24
-
25
-import com.dmdirc.actions.Action;
26
-import com.dmdirc.actions.ActionCondition;
27
-import com.dmdirc.actions.CoreActionComparison;
28
-import com.dmdirc.actions.CoreActionComponent;
29
-import com.dmdirc.actions.CoreActionType;
30
-import com.dmdirc.interfaces.CommandController;
31
-import com.dmdirc.interfaces.actions.ActionType;
32
-import com.dmdirc.logger.ErrorManager;
33
-import com.dmdirc.logger.Logger;
34
-import com.dmdirc.ui.WindowManager;
35
-
36
-import java.util.ArrayList;
37
-import java.util.List;
38
-
39
-import org.junit.Before;
40
-import org.junit.BeforeClass;
41
-import org.junit.Test;
42
-import org.junit.runner.RunWith;
43
-import org.mockito.Mock;
44
-import org.mockito.runners.MockitoJUnitRunner;
45
-
46
-import static org.junit.Assert.*;
47
-import static org.mockito.Mockito.*;
48
-
49
-@RunWith(MockitoJUnitRunner.class)
50
-public class AliasWrapperTest {
51
-
52
-    @Mock private Action action;
53
-    @Mock private ActionCondition condition;
54
-    @Mock private WindowManager windowManager;
55
-    @Mock private CommandController commandController;
56
-    private List<ActionCondition> conditions;
57
-
58
-    private AliasWrapper aliasWrapper;
59
-
60
-    @BeforeClass
61
-    public static void overrideLogger() {
62
-        // We expect errors to be generated, so mock out the error manager.
63
-        Logger.setErrorManager(mock(ErrorManager.class));
64
-    }
65
-
66
-    @Before
67
-    public void setup() {
68
-        when(commandController.getCommandChar()).thenReturn('!');
69
-
70
-        conditions = new ArrayList<>();
71
-        aliasWrapper = new AliasWrapper(commandController, windowManager);
72
-
73
-        when(condition.getArg()).thenReturn(1);
74
-        when(condition.getComparison()).thenReturn(CoreActionComparison.STRING_EQUALS);
75
-        when(condition.getComponent()).thenReturn(CoreActionComponent.STRING_STRING);
76
-        when(condition.getTarget()).thenReturn("name");
77
-        when(action.getConditions()).thenReturn(conditions);
78
-        when(action.getTriggers()).thenReturn(new ActionType[] { CoreActionType.UNKNOWN_COMMAND });
79
-    }
80
-
81
-    @Test
82
-    public void testAddsAlias() {
83
-        conditions.add(condition);
84
-
85
-        aliasWrapper.add(action);
86
-        assertFalse(aliasWrapper.getAliases().isEmpty());
87
-    }
88
-
89
-    @Test
90
-    public void testDoesNotAddActionWithNoConditions() {
91
-        aliasWrapper.add(action);
92
-        assertTrue(aliasWrapper.getAliases().isEmpty());
93
-    }
94
-
95
-    @Test
96
-    public void testDoesNotAddActionWithWrongTrigger() {
97
-        when(action.getTriggers()).thenReturn(new ActionType[] { CoreActionType.ACTION_CREATED });
98
-
99
-        aliasWrapper.add(action);
100
-        assertTrue(aliasWrapper.getAliases().isEmpty());
101
-    }
102
-
103
-    @Test
104
-    public void testGetsCommandName() {
105
-        conditions.add(condition);
106
-        assertEquals("!name", aliasWrapper.getCommandName(action));
107
-    }
108
-
109
-    @Test
110
-    public void testGetsCommandNameWithMultipleConditions() {
111
-        final ActionCondition otherCondition = mock(ActionCondition.class);
112
-        when(otherCondition.getArg()).thenReturn(7);
113
-
114
-        conditions.add(otherCondition);
115
-        conditions.add(condition);
116
-        assertEquals("!name", aliasWrapper.getCommandName(action));
117
-    }
118
-
119
-    @Test
120
-    public void testGetCommandNameReturnsNullIfUnknown() {
121
-        assertNull(aliasWrapper.getCommandName(action));
122
-    }
123
-
124
-}

Loading…
Cancel
Save