Browse Source

Sprinkle some @Nullables around.

Other minor tidying.

Change-Id: I1e41c7e348b58a0fdea3aaae5a647051f9274409
Reviewed-on: http://gerrit.dmdirc.com/4079
Reviewed-by: Greg Holmes <greg@dmdirc.com>
Automatic-Compile: DMDirc Build Manager
pull/1/head
Chris Smith 9 years ago
parent
commit
663ef2c19c

+ 6
- 1
src/com/dmdirc/commandparser/commands/flags/CommandFlagHandler.java View File

@@ -26,11 +26,14 @@ import com.dmdirc.FrameContainer;
26 26
 import com.dmdirc.commandparser.CommandArguments;
27 27
 
28 28
 import java.util.ArrayList;
29
+import java.util.Collection;
29 30
 import java.util.HashMap;
30 31
 import java.util.LinkedList;
31 32
 import java.util.List;
32 33
 import java.util.Map;
33 34
 
35
+import javax.annotation.Nullable;
36
+
34 37
 /**
35 38
  * Utility class for commands which allow the user to specify shell-like flags (
36 39
  * <code>--foo</code>).
@@ -70,6 +73,7 @@ public class CommandFlagHandler {
70 73
      * @return A corresponding {@link CommandFlagResult} object, or null if some problem was
71 74
      *         encountered.
72 75
      */
76
+    @Nullable
73 77
     public CommandFlagResult process(final FrameContainer origin,
74 78
             final CommandArguments arguments) {
75 79
         final Map<CommandFlag, Integer> results = parse(origin, arguments);
@@ -87,6 +91,7 @@ public class CommandFlagHandler {
87 91
      * @return A map of discovered command flags to the offset of the flag's first argument within
88 92
      *         the <code>arguments</code> object. If an error occurs, null is returned.
89 93
      */
94
+    @Nullable
90 95
     protected Map<CommandFlag, Integer> parse(final FrameContainer origin,
91 96
             final CommandArguments arguments) {
92 97
         enabledFlags.clear();
@@ -98,7 +103,7 @@ public class CommandFlagHandler {
98 103
         }
99 104
 
100 105
         final Map<CommandFlag, Integer> results = new HashMap<>();
101
-        final List<CommandFlag> delayedFlags = new ArrayList<>(flags.size());
106
+        final Collection<CommandFlag> delayedFlags = new ArrayList<>(flags.size());
102 107
 
103 108
         int offset;
104 109
         for (offset = 0; offset < arguments.getArguments().length; offset++) {

+ 2
- 1
src/com/dmdirc/commandparser/commands/global/Echo.java View File

@@ -46,6 +46,7 @@ import java.util.Date;
46 46
 import java.util.List;
47 47
 
48 48
 import javax.annotation.Nonnull;
49
+import javax.annotation.Nullable;
49 50
 import javax.inject.Inject;
50 51
 
51 52
 /**
@@ -84,7 +85,7 @@ public class Echo extends Command implements IntelligentCommand {
84 85
     @Override
85 86
     public void execute(@Nonnull final FrameContainer origin,
86 87
             final CommandArguments args, final CommandContext context) {
87
-        final CommandFlagResult results = handler.process(origin, args);
88
+        @Nullable final CommandFlagResult results = handler.process(origin, args);
88 89
 
89 90
         if (results == null) {
90 91
             return;

+ 2
- 1
src/com/dmdirc/commandparser/commands/global/SetCommand.java View File

@@ -46,6 +46,7 @@ import com.dmdirc.ui.input.AdditionalTabTargets;
46 46
 import java.util.List;
47 47
 
48 48
 import javax.annotation.Nonnull;
49
+import javax.annotation.Nullable;
49 50
 import javax.inject.Inject;
50 51
 
51 52
 /**
@@ -103,7 +104,7 @@ public class SetCommand extends Command implements IntelligentCommand {
103 104
     @Override
104 105
     public void execute(@Nonnull final FrameContainer origin,
105 106
             final CommandArguments args, final CommandContext context) {
106
-        final CommandFlagResult res = handler.process(origin, args);
107
+        @Nullable final CommandFlagResult res = handler.process(origin, args);
107 108
 
108 109
         if (res == null) {
109 110
             return;

+ 4
- 1
src/com/dmdirc/plugins/GlobalClassLoader.java View File

@@ -29,6 +29,8 @@ import java.util.HashMap;
29 29
 import java.util.List;
30 30
 import java.util.Map;
31 31
 
32
+import javax.annotation.Nullable;
33
+
32 34
 /**
33 35
  * This classloader knows about plugins and is used to store persistent classes.
34 36
  */
@@ -108,7 +110,7 @@ public final class GlobalClassLoader extends ClassLoader {
108 110
      *
109 111
      * @return The resulting {@link Class} object
110 112
      */
111
-    public Class<?> defineClass(final String classname, final byte[] data) {
113
+    public Class<?> defineClass(final String classname, final byte... data) {
112 114
         return defineClass(classname, data, 0, data.length);
113 115
     }
114 116
 
@@ -117,6 +119,7 @@ public final class GlobalClassLoader extends ClassLoader {
117 119
      *
118 120
      * @param classname Class to look for.
119 121
      */
122
+    @Nullable
120 123
     private byte[] getClassData(final String classname) {
121 124
         try {
122 125
             final String jarname = resourcesList.get(classname);

+ 2
- 2
src/com/dmdirc/ui/input/InputHandler.java View File

@@ -540,8 +540,8 @@ public abstract class InputHandler implements ConfigChangeListener {
540 540
     private void doCommandTabCompletion(final String text, final int start,
541 541
             final int end, final boolean shiftPressed) {
542 542
         doNormalTabCompletion(text, start, end, shiftPressed,
543
-                TabCompleterUtils.getIntelligentResults(parentWindow, text.substring(0, start),
544
-                        text.substring(start, end)));
543
+                TabCompleterUtils.getIntelligentResults(parentWindow, commandController,
544
+                        text.substring(0, start), text.substring(start, end)));
545 545
     }
546 546
 
547 547
     /**

+ 9
- 3
src/com/dmdirc/ui/input/TabCompleterUtils.java View File

@@ -28,10 +28,13 @@ import com.dmdirc.commandparser.CommandInfo;
28 28
 import com.dmdirc.commandparser.CommandType;
29 29
 import com.dmdirc.commandparser.commands.Command;
30 30
 import com.dmdirc.commandparser.commands.IntelligentCommand;
31
+import com.dmdirc.interfaces.CommandController;
31 32
 
32 33
 import java.util.Arrays;
33 34
 import java.util.Map;
34 35
 
36
+import javax.annotation.Nullable;
37
+
35 38
 /**
36 39
  * Utilities relating to {@link TabCompleter}s.
37 40
  */
@@ -49,6 +52,7 @@ public final class TabCompleterUtils {
49 52
      *
50 53
      * @return Additional tab targets for the text, or null if none are available
51 54
      */
55
+    @Nullable
52 56
     public static AdditionalTabTargets getIntelligentResults(final int arg,
53 57
             final IntelligentCommand.IntelligentCommandContext context, final int offset) {
54 58
         if (arg == offset) {
@@ -74,6 +78,7 @@ public final class TabCompleterUtils {
74 78
      *
75 79
      * @since 0.6.4
76 80
      */
81
+    @Nullable
77 82
     private static AdditionalTabTargets getIntelligentResults(
78 83
             final FrameContainer window,
79 84
             final CommandArguments args, final String partial) {
@@ -117,10 +122,11 @@ public final class TabCompleterUtils {
117 122
      *
118 123
      * @since 0.6.4
119 124
      */
125
+    @Nullable
120 126
     public static AdditionalTabTargets getIntelligentResults(
121
-            final FrameContainer window, final String text,
122
-            final String partial) {
127
+            final FrameContainer window, final CommandController commandController,
128
+            final String text, final String partial) {
123 129
         return getIntelligentResults(window,
124
-                new CommandArguments(window.getCommandParser().getCommandManager(), text), partial);
130
+                new CommandArguments(commandController, text), partial);
125 131
     }
126 132
 }

Loading…
Cancel
Save