1
1
using System ;
2
2
using System . Collections . Generic ;
3
3
using System . Linq ;
4
+ using System . Windows . Forms ;
4
5
using Rubberduck . Common ;
5
6
using Rubberduck . Parsing . Symbols ;
6
7
using Rubberduck . Parsing . VBA ;
@@ -31,8 +32,8 @@ public void Refactor()
31
32
}
32
33
else
33
34
{
34
- _messageBox . Show ( "Invalid Selection." , "Rubberduck - Move Closer To Usage" , System . Windows . Forms . MessageBoxButtons . OK ,
35
- System . Windows . Forms . MessageBoxIcon . Exclamation ) ;
35
+ _messageBox . Show ( RubberduckUI . MoveCloserToUsage_InvalidSelection , RubberduckUI . MoveCloserToUsage_Caption , MessageBoxButtons . OK ,
36
+ MessageBoxIcon . Exclamation ) ;
36
37
}
37
38
}
38
39
@@ -45,24 +46,25 @@ public void Refactor(Declaration target)
45
46
{
46
47
if ( target . DeclarationType != DeclarationType . Variable )
47
48
{
48
- throw new ArgumentException ( @"Invalid Argument" , "target" ) ;
49
+ // ReSharper disable once LocalizableElement
50
+ throw new ArgumentException ( "Invalid Argument. DeclarationType must be 'Variable'" , "target" ) ;
49
51
}
50
52
51
53
if ( ! target . References . Any ( ) )
52
54
{
53
55
var message = string . Format ( RubberduckUI . MoveCloserToUsage_TargetHasNoReferences , target . IdentifierName ) ;
54
56
55
- _messageBox . Show ( message , RubberduckUI . MoveCloserToUsage_Caption , System . Windows . Forms . MessageBoxButtons . OK ,
56
- System . Windows . Forms . MessageBoxIcon . Exclamation ) ;
57
+ _messageBox . Show ( message , RubberduckUI . MoveCloserToUsage_Caption , MessageBoxButtons . OK ,
58
+ MessageBoxIcon . Exclamation ) ;
57
59
58
60
return ;
59
61
}
60
62
61
63
if ( TargetIsReferencedFromMultipleMethods ( target ) )
62
64
{
63
65
var message = string . Format ( RubberduckUI . MoveCloserToUsage_TargetIsUsedInMultipleMethods , target . IdentifierName ) ;
64
- _messageBox . Show ( message , RubberduckUI . MoveCloserToUsage_Caption , System . Windows . Forms . MessageBoxButtons . OK ,
65
- System . Windows . Forms . MessageBoxIcon . Exclamation ) ;
66
+ _messageBox . Show ( message , RubberduckUI . MoveCloserToUsage_Caption , MessageBoxButtons . OK ,
67
+ MessageBoxIcon . Exclamation ) ;
66
68
67
69
return ;
68
70
}
@@ -140,35 +142,36 @@ private void RemoveVariable(Declaration target)
140
142
141
143
private string RemoveExtraComma ( string str , int numParams , int indexRemoved )
142
144
{
143
- // Example use cases for this method (fields and variables):
144
- // Dim fizz as Boolean, dizz as Double
145
- // Private fizz as Boolean, dizz as Double
146
- // Public fizz as Boolean, _
147
- // dizz as Double
148
- // Private fizz as Boolean _
149
- // , dizz as Double _
150
- // , iizz as Integer
151
-
152
- // Before this method is called, the parameter to be removed has
153
- // already been removed. This means 'str' will look like:
154
- // Dim fizz as Boolean,
155
- // Private , dizz as Double
156
- // Public fizz as Boolean, _
157
- //
158
- // Private _
159
- // , dizz as Double _
160
- // , iizz as Integer
161
-
162
- // This method is responsible for removing the redundant comma
163
- // and returning a string similar to:
164
- // Dim fizz as Boolean
165
- // Private dizz as Double
166
- // Public fizz as Boolean _
167
- //
168
- // Private _
169
- // dizz as Double _
170
- // , iizz as Integer
171
-
145
+ /* Example use cases for this method (fields and variables):
146
+ * Dim fizz as Boolean, dizz as Double
147
+ * Private fizz as Boolean, dizz as Double
148
+ * Public fizz as Boolean, _
149
+ * dizz as Double
150
+ * Private fizz as Boolean _
151
+ * , dizz as Double _
152
+ * , iizz as Integer
153
+
154
+ * Before this method is called, the parameter to be removed has
155
+ * already been removed. This means 'str' will look like:
156
+ * Dim fizz as Boolean,
157
+ * Private , dizz as Double
158
+ * Public fizz as Boolean, _
159
+ *
160
+ * Private _
161
+ * , dizz as Double _
162
+ * , iizz as Integer
163
+
164
+ * This method is responsible for removing the redundant comma
165
+ * and returning a string similar to:
166
+ * Dim fizz as Boolean
167
+ * Private dizz as Double
168
+ * Public fizz as Boolean _
169
+ *
170
+ * Private _
171
+ * dizz as Double _
172
+ * , iizz as Integer
173
+ */
174
+
172
175
var commaToRemove = numParams == indexRemoved ? indexRemoved - 1 : indexRemoved ;
173
176
174
177
return str . Remove ( str . NthIndexOf ( ',' , commaToRemove ) , 1 ) ;
0 commit comments