Quellcode durchsuchen

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 vor 9 Jahren
Ursprung
Commit
663ef2c19c

+ 6
- 1
src/com/dmdirc/commandparser/commands/flags/CommandFlagHandler.java Datei anzeigen

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

+ 2
- 1
src/com/dmdirc/commandparser/commands/global/Echo.java Datei anzeigen

46
 import java.util.List;
46
 import java.util.List;
47
 
47
 
48
 import javax.annotation.Nonnull;
48
 import javax.annotation.Nonnull;
49
+import javax.annotation.Nullable;
49
 import javax.inject.Inject;
50
 import javax.inject.Inject;
50
 
51
 
51
 /**
52
 /**
84
     @Override
85
     @Override
85
     public void execute(@Nonnull final FrameContainer origin,
86
     public void execute(@Nonnull final FrameContainer origin,
86
             final CommandArguments args, final CommandContext context) {
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
         if (results == null) {
90
         if (results == null) {
90
             return;
91
             return;

+ 2
- 1
src/com/dmdirc/commandparser/commands/global/SetCommand.java Datei anzeigen

46
 import java.util.List;
46
 import java.util.List;
47
 
47
 
48
 import javax.annotation.Nonnull;
48
 import javax.annotation.Nonnull;
49
+import javax.annotation.Nullable;
49
 import javax.inject.Inject;
50
 import javax.inject.Inject;
50
 
51
 
51
 /**
52
 /**
103
     @Override
104
     @Override
104
     public void execute(@Nonnull final FrameContainer origin,
105
     public void execute(@Nonnull final FrameContainer origin,
105
             final CommandArguments args, final CommandContext context) {
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
         if (res == null) {
109
         if (res == null) {
109
             return;
110
             return;

+ 4
- 1
src/com/dmdirc/plugins/GlobalClassLoader.java Datei anzeigen

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

+ 2
- 2
src/com/dmdirc/ui/input/InputHandler.java Datei anzeigen

540
     private void doCommandTabCompletion(final String text, final int start,
540
     private void doCommandTabCompletion(final String text, final int start,
541
             final int end, final boolean shiftPressed) {
541
             final int end, final boolean shiftPressed) {
542
         doNormalTabCompletion(text, start, end, shiftPressed,
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 Datei anzeigen

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

Laden…
Abbrechen
Speichern