@@ -55,7 +55,7 @@ public static bool RequiresSetAssignment(IdentifierReference reference, Rubberdu
55
55
return false ;
56
56
}
57
57
58
- var isObjectVariable = declaration . IsObject ( ) ;
58
+ var isObjectVariable = declaration . IsObject ;
59
59
var isVariant = declaration . IsUndeclared || declaration . AsTypeName == Tokens . Variant ;
60
60
if ( ! isObjectVariable && ! isVariant )
61
61
{
@@ -180,76 +180,5 @@ private static bool IsVariableOrParameter(Declaration item)
180
180
return item . DeclarationType == DeclarationType . Variable
181
181
|| item . DeclarationType == DeclarationType . Parameter ;
182
182
}
183
-
184
- private static bool ObjectOrVariantRequiresSetAssignment ( IdentifierReference objectOrVariantRef , IEnumerable < Declaration > variantAndObjectDeclarations )
185
- {
186
- //Not an assignment...nothing to evaluate
187
- if ( ! objectOrVariantRef . IsAssignment )
188
- {
189
- return false ;
190
- }
191
-
192
- if ( objectOrVariantRef . Declaration . AsTypeName != Tokens . Variant )
193
- {
194
- return true ;
195
- }
196
-
197
- //Variants can be assigned with or without 'Set' depending...
198
- var letStmtContext = objectOrVariantRef . Context . GetAncestor < VBAParser . LetStmtContext > ( ) ;
199
-
200
- //A potential error is only possible for let statements: rset, lset and other type specific assignments are always let assignments;
201
- //assignemts in for each loop statements are do not require the set keyword.
202
- if ( letStmtContext == null )
203
- {
204
- return false ;
205
- }
206
-
207
- //You can only new up objects.
208
- if ( RHSUsesNew ( letStmtContext ) )
209
- {
210
- return true ;
211
- }
212
-
213
- if ( RHSIsLiteral ( letStmtContext ) )
214
- {
215
- if ( RHSIsObjectLiteral ( letStmtContext ) )
216
- {
217
- return true ;
218
- }
219
- //All literals but the object literal potentially do not need a set assignment.
220
- //We cannot get more information from the RHS and do not want false positives.
221
- return false ;
222
- }
223
-
224
- //If the RHS is the identifierName of one of the 'interesting' declarations, we need to use 'Set'
225
- //unless the 'interesting' declaration is also a Variant
226
- var rhsIdentifier = GetRHSIdentifierExpressionText ( letStmtContext ) ;
227
- return variantAndObjectDeclarations . Any ( dec => dec . IdentifierName == rhsIdentifier
228
- && dec . AsTypeName != Tokens . Variant
229
- && dec . Attributes . HasDefaultMemberAttribute ( dec . IdentifierName , out _ ) ) ;
230
- }
231
-
232
- private static string GetRHSIdentifierExpressionText ( VBAParser . LetStmtContext letStmtContext )
233
- {
234
- var expression = letStmtContext . expression ( ) ;
235
- return expression is VBAParser . LExprContext ? expression . GetText ( ) : string . Empty ;
236
- }
237
-
238
- private static bool RHSUsesNew ( VBAParser . LetStmtContext letStmtContext )
239
- {
240
- var expression = letStmtContext . expression ( ) ;
241
- return ( expression is VBAParser . NewExprContext ) ;
242
- }
243
-
244
- private static bool RHSIsLiteral ( VBAParser . LetStmtContext letStmtContext )
245
- {
246
- return letStmtContext . expression ( ) is VBAParser . LiteralExprContext ;
247
- }
248
-
249
- private static bool RHSIsObjectLiteral ( VBAParser . LetStmtContext letStmtContext )
250
- {
251
- var rhsAsLiteralExpr = letStmtContext . expression ( ) as VBAParser . LiteralExprContext ;
252
- return rhsAsLiteralExpr ? . literalExpression ( ) ? . literalIdentifier ( ) ? . objectLiteralIdentifier ( ) != null ;
253
- }
254
183
}
255
184
}
0 commit comments