Kaynağa Gözat

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 yıl önce
ebeveyn
işleme
6f02afbcb2

+ 0
- 6
src/com/dmdirc/ClientModule.java Dosyayı Görüntüle

25
 import com.dmdirc.actions.ActionFactory;
25
 import com.dmdirc.actions.ActionFactory;
26
 import com.dmdirc.actions.ActionGroup;
26
 import com.dmdirc.actions.ActionGroup;
27
 import com.dmdirc.actions.ActionManager;
27
 import com.dmdirc.actions.ActionManager;
28
-import com.dmdirc.actions.wrappers.AliasWrapper;
29
 import com.dmdirc.actions.wrappers.PerformWrapper;
28
 import com.dmdirc.actions.wrappers.PerformWrapper;
30
 import com.dmdirc.commandline.CommandLineOptionsModule;
29
 import com.dmdirc.commandline.CommandLineOptionsModule;
31
 import com.dmdirc.commandline.CommandLineOptionsModule.Directory;
30
 import com.dmdirc.commandline.CommandLineOptionsModule.Directory;
271
         return manager;
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
     @Provides(type = Provides.Type.SET)
273
     @Provides(type = Provides.Type.SET)
280
     @Singleton
274
     @Singleton
281
     public ActionGroup getPerformWrapper(final PerformWrapper wrapper) {
275
     public ActionGroup getPerformWrapper(final PerformWrapper wrapper) {

+ 3
- 0
src/com/dmdirc/actions/wrappers/Alias.java Dosyayı Görüntüle

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

+ 4
- 0
src/com/dmdirc/actions/wrappers/AliasWrapper.java Dosyayı Görüntüle

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

+ 0
- 5
src/com/dmdirc/plugins/PluginInjectorInitialiser.java Dosyayı Görüntüle

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

+ 1
- 11
src/com/dmdirc/ui/input/TabCompleterFactory.java Dosyayı Görüntüle

22
 
22
 
23
 package com.dmdirc.ui.input;
23
 package com.dmdirc.ui.input;
24
 
24
 
25
-import com.dmdirc.actions.wrappers.AliasWrapper;
26
 import com.dmdirc.commandparser.CommandType;
25
 import com.dmdirc.commandparser.CommandType;
27
 import com.dmdirc.interfaces.CommandController;
26
 import com.dmdirc.interfaces.CommandController;
28
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
27
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
40
 
39
 
41
     /** The command controller to use to find commands. */
40
     /** The command controller to use to find commands. */
42
     private final Provider<CommandController> commandController;
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
      * Creates a new instance of {@link TabCompleterFactory}.
44
      * Creates a new instance of {@link TabCompleterFactory}.
51
      *
45
      *
52
      * @param commandController The command controller to use to find commands.
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
     @Inject
48
     @Inject
56
     public TabCompleterFactory(
49
     public TabCompleterFactory(
57
-            final Provider<CommandController> commandController,
58
-            final Provider<AliasWrapper> aliasWrapper) {
50
+            final Provider<CommandController> commandController) {
59
         this.commandController = commandController;
51
         this.commandController = commandController;
60
-        this.aliasWrapper = aliasWrapper;
61
     }
52
     }
62
 
53
 
63
     /**
54
     /**
77
             final CommandType... commandTypes) {
68
             final CommandType... commandTypes) {
78
         final TabCompleter tabCompleter = new TabCompleter(commandController.get(), configProvider);
69
         final TabCompleter tabCompleter = new TabCompleter(commandController.get(), configProvider);
79
         addCommands(tabCompleter, commandTypes);
70
         addCommands(tabCompleter, commandTypes);
80
-        tabCompleter.addEntries(TabCompletionType.COMMAND, aliasWrapper.get().getAliases());
81
         return tabCompleter;
71
         return tabCompleter;
82
     }
72
     }
83
 
73
 

+ 0
- 46
test/com/dmdirc/actions/wrappers/AliasTest.java Dosyayı Görüntüle

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 Dosyayı Görüntüle

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…
İptal
Kaydet