Skip to content

Commit 694f35f

Browse files
committed
Revert "fixes rubberduck-vba#6200"
This reverts commit 52322bf.
1 parent 52322bf commit 694f35f

File tree

5 files changed

+35
-87
lines changed

5 files changed

+35
-87
lines changed

Diff for: Rubberduck.CodeAnalysis/Inspections/Concrete/ObjectVariableNotSetInspection.cs

+2-3
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ protected override IEnumerable<IdentifierReference> ReferencesInModule(Qualified
6060
private static IEnumerable<IdentifierReference> FailedLetResolutionAssignments(QualifiedModuleName module, DeclarationFinder finder)
6161
{
6262
return finder.FailedLetCoercions(module)
63-
.Where(reference => reference.IsAssignment && !reference.Declaration.IsArray);
63+
.Where(reference => reference.IsAssignment);
6464
}
6565

6666
private static IEnumerable<IdentifierReference> PossiblyObjectLhsLetAssignmentsWithNonValueOnRhs(QualifiedModuleName module, DeclarationFinder finder)
@@ -89,12 +89,11 @@ private static IEnumerable<IdentifierReference> PossiblyObjectNonSetAssignments(
8989
{
9090
var assignments = finder.IdentifierReferences(module)
9191
.Where(reference => reference.IsAssignment
92-
&& !reference.Declaration.IsArray
9392
&& !reference.IsSetAssignment
9493
&& (reference.IsNonIndexedDefaultMemberAccess
9594
|| Tokens.Variant.Equals(reference.Declaration.AsTypeName, StringComparison.InvariantCultureIgnoreCase)));
9695
var unboundAssignments = finder.UnboundDefaultMemberAccesses(module)
97-
.Where(reference => reference.IsAssignment && !reference.Declaration.IsArray);
96+
.Where(reference => reference.IsAssignment);
9897

9998
return assignments.Concat(unboundAssignments);
10099
}

Diff for: Rubberduck.Parsing/Symbols/Declaration.cs

+13-17
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using Antlr4.Runtime;
22
using Rubberduck.Parsing.Annotations;
3-
using Rubberduck.Parsing.Annotations.Concrete;
43
using Rubberduck.Parsing.ComReflection;
54
using Rubberduck.Parsing.Grammar;
65
using Rubberduck.VBEditor;
@@ -9,6 +8,7 @@
98
using System.Collections.Generic;
109
using System.Diagnostics;
1110
using System.Linq;
11+
using Rubberduck.Parsing.Annotations.Concrete;
1212

1313
namespace Rubberduck.Parsing.Symbols
1414
{
@@ -117,7 +117,7 @@ public Declaration(
117117
IEnumerable<IParseTreeAnnotation> annotations = null,
118118
Attributes attributes = null)
119119
{
120-
QualifiedName = qualifiedName;
120+
QualifiedName = qualifiedName;
121121
ParentDeclaration = parentDeclaration;
122122
ParentScopeDeclaration = ParentDeclaration;
123123
ParentScope = parentScope ?? string.Empty;
@@ -145,7 +145,7 @@ public Declaration(
145145
ProjectName = IdentifierName;
146146
}
147147

148-
IsArray = isArray || AsTypeName != null && (AsTypeNameWithoutArrayDesignator.Length == AsTypeName.Length - "()".Length);
148+
IsArray = isArray;
149149
AsTypeContext = asTypeContext;
150150
TypeHint = typeHint;
151151
}
@@ -168,8 +168,7 @@ public Declaration(ComEnumeration enumeration, Declaration parent, QualifiedModu
168168
null,
169169
false,
170170
null,
171-
new Attributes())
172-
{ }
171+
new Attributes()) { }
173172

174173
public Declaration(ComStruct structure, Declaration parent, QualifiedModuleName module)
175174
: this(
@@ -189,8 +188,7 @@ public Declaration(ComStruct structure, Declaration parent, QualifiedModuleName
189188
null,
190189
false,
191190
null,
192-
new Attributes())
193-
{ }
191+
new Attributes()) { }
194192

195193
public Declaration(ComEnumerationMember member, Declaration parent, QualifiedModuleName module) : this(
196194
module.QualifyMemberName(member.Name),
@@ -209,8 +207,7 @@ public Declaration(ComEnumerationMember member, Declaration parent, QualifiedMod
209207
null,
210208
false,
211209
null,
212-
new Attributes())
213-
{ }
210+
new Attributes()) { }
214211

215212
public Declaration(ComField field, Declaration parent, QualifiedModuleName module)
216213
: this(
@@ -230,8 +227,7 @@ public Declaration(ComField field, Declaration parent, QualifiedModuleName modul
230227
null,
231228
false,
232229
null,
233-
new Attributes())
234-
{ }
230+
new Attributes()) { }
235231

236232
public static Declaration GetModuleParent(Declaration declaration)
237233
{
@@ -293,8 +289,8 @@ public string DescriptionString
293289
{
294290
string literalDescription;
295291

296-
var memberAttribute = Attributes.SingleOrDefault(a =>
297-
a.Name == Attributes.MemberAttributeName("VB_Description", IdentifierName) ||
292+
var memberAttribute = Attributes.SingleOrDefault(a =>
293+
a.Name == Attributes.MemberAttributeName("VB_Description", IdentifierName) ||
298294
a.Name == Attributes.MemberAttributeName("VB_VarDescription", IdentifierName));
299295

300296
if (memberAttribute != null)
@@ -327,10 +323,10 @@ public string DescriptionString
327323

328324
private static string CorrectlyFormatedDescription(string literalDescription)
329325
{
330-
if (string.IsNullOrEmpty(literalDescription)
331-
|| literalDescription.Length < 2
326+
if (string.IsNullOrEmpty(literalDescription)
327+
|| literalDescription.Length < 2
332328
|| literalDescription[0] != '"'
333-
|| literalDescription[literalDescription.Length - 1] != '"')
329+
|| literalDescription[literalDescription.Length -1] != '"')
334330
{
335331
return literalDescription;
336332
}
@@ -354,7 +350,7 @@ private bool IsObjectOrObjectArray
354350
{
355351
get
356352
{
357-
if (AsTypeName == Tokens.Object
353+
if (AsTypeName == Tokens.Object
358354
|| (AsTypeDeclaration?.DeclarationType.HasFlag(DeclarationType.ClassModule) ?? false))
359355
{
360356
return true;

Diff for: Rubberduck.Parsing/Symbols/ParameterDeclaration.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1+
using System.Collections.Concurrent;
2+
using System.Collections.Generic;
3+
using System.Linq;
14
using Antlr4.Runtime;
25
using Rubberduck.Parsing.Annotations;
36
using Rubberduck.Parsing.Binding;
47
using Rubberduck.Parsing.ComReflection;
58
using Rubberduck.Parsing.Grammar;
69
using Rubberduck.Parsing.VBA.Extensions;
710
using Rubberduck.VBEditor;
8-
using System.Collections.Concurrent;
9-
using System.Collections.Generic;
10-
using System.Linq;
1111

1212
namespace Rubberduck.Parsing.Symbols
1313
{
@@ -39,7 +39,7 @@ public ParameterDeclaration(QualifiedMemberName qualifiedName,
3939
null,
4040
null,
4141
Selection.Home,
42-
isArray || isParamArray,
42+
isArray,
4343
asTypeContext,
4444
false)
4545
{
@@ -78,7 +78,7 @@ public ParameterDeclaration(QualifiedMemberName qualifiedName,
7878
context,
7979
null,
8080
selection,
81-
isArray || isParamArray,
81+
isArray,
8282
asTypeContext,
8383
isUserDefined)
8484
{

Diff for: RubberduckTests/Grammar/ResolverTests.cs

+14-30
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading;
15
using NUnit.Framework;
26
using Rubberduck.InternalApi.Extensions;
3-
using Rubberduck.Parsing.Annotations.Concrete;
47
using Rubberduck.Parsing.Symbols;
58
using Rubberduck.Parsing.VBA;
9+
using RubberduckTests.Mocks;
10+
using Rubberduck.Parsing.Annotations;
11+
using Rubberduck.Parsing.Annotations.Concrete;
612
using Rubberduck.VBEditor;
713
using Rubberduck.VBEditor.SafeComWrappers;
814
using Rubberduck.VBEditor.SafeComWrappers.Abstract;
9-
using RubberduckTests.Mocks;
10-
using System;
11-
using System.Collections.Generic;
12-
using System.Linq;
13-
using System.Threading;
1415

1516
namespace RubberduckTests.Grammar
1617
{
@@ -119,23 +120,6 @@ End Sub
119120
}
120121
}
121122

122-
[Category("Resolver")]
123-
[Test]
124-
public void ParamArrayParameter_IsArray()
125-
{
126-
var code = @"Option Explicit
127-
128-
Public Sub Test(ParamArray Values)
129-
End Sub
130-
";
131-
using (var state = Resolve(code))
132-
{
133-
var declaration = state.AllUserDeclarations.Single(item => item.DeclarationType == DeclarationType.Parameter && item.IdentifierName == "Values") as ParameterDeclaration;
134-
Assert.IsTrue(declaration.IsParamArray);
135-
Assert.IsTrue(declaration.IsArray);
136-
}
137-
}
138-
139123
[Category("Resolver")]
140124
[Test]
141125
public void OptionalParameterDefaultConstValue_IsReferenceToDeclaredConst()
@@ -1033,7 +1017,7 @@ End Sub
10331017
item.DeclarationType == DeclarationType.Variable
10341018
&& item.IdentifierName == "foo");
10351019

1036-
Assert.AreEqual(1, declaration.References.Count(item =>
1020+
Assert.AreEqual(1,declaration.References.Count(item =>
10371021
item.ParentScoping.DeclarationType == DeclarationType.Procedure
10381022
&& item.ParentScoping.IdentifierName == "DoSomething"
10391023
&& item.IsAssignment));
@@ -2294,7 +2278,7 @@ End Sub
22942278
var printReference = printDeclaration.References.Single();
22952279

22962280
var module = state.DeclarationFinder.AllModules.Single(qmn => qmn.ComponentType == ComponentType.ClassModule);
2297-
var expectedPrintSelection = new QualifiedSelection(module, new Selection(4, 5, 4, 10));
2281+
var expectedPrintSelection = new QualifiedSelection(module, new Selection(4, 5,4, 10));
22982282
var actualPrintSelection = new QualifiedSelection(printReference.QualifiedModuleName, printReference.Selection);
22992283

23002284
Assert.AreEqual(4, referencedDeclaration.References.Count());
@@ -3648,7 +3632,7 @@ End Function
36483632

36493633
Assert.AreEqual(expectedReferencedDeclarationName, actualReferencedDeclarationName);
36503634
Assert.IsTrue(reference.IsIndexedDefaultMemberAccess);
3651-
Assert.AreEqual(2, reference.DefaultMemberRecursionDepth);
3635+
Assert.AreEqual(2,reference.DefaultMemberRecursionDepth);
36523636
}
36533637
}
36543638

@@ -3848,7 +3832,7 @@ End Function
38483832
{
38493833
var module = state.DeclarationFinder.AllModules.First(qmn => qmn.ComponentName == "Module1");
38503834
var defaultMemberAccess = state.DeclarationFinder.UnboundDefaultMemberAccesses(module).First();
3851-
3835+
38523836
var expectedReferencedSelection = new QualifiedSelection(module, selection);
38533837
var actualReferencedSelection = new QualifiedSelection(defaultMemberAccess.QualifiedModuleName, defaultMemberAccess.Selection);
38543838

@@ -5719,7 +5703,7 @@ End Function
57195703
.Single(param => param.IdentifierName.Equals("furtherArgs"));
57205704
var argumentReferences = parameter.ArgumentReferences;
57215705

5722-
var expectedExpressionTexts = new HashSet<string> { "4", "5", "6" };
5706+
var expectedExpressionTexts = new HashSet<string>{"4", "5", "6"};
57235707
var actualExpressionTexts = argumentReferences.Select(reference => reference.Context.GetText()).ToList();
57245708

57255709
var expectedCount = expectedExpressionTexts.Count;
@@ -7350,7 +7334,7 @@ End Sub
73507334
var undeclared = finder.Members(module.QualifiedModuleName)
73517335
.Where(declaration => declaration.IsUndeclared)
73527336
.ToList();
7353-
7337+
73547338
Assert.AreEqual(4, undeclared.Count);
73557339
}
73567340
}
@@ -7418,7 +7402,7 @@ End Sub
74187402
using (var state = Resolve(vbe.Object))
74197403
{
74207404
var finder = state.DeclarationFinder;
7421-
7405+
74227406
var classModule = finder.UserDeclarations(DeclarationType.ClassModule).Single();
74237407
var barDeclaration = finder.Members(classModule.QualifiedModuleName, DeclarationType.Function).Single();
74247408
var barReference = barDeclaration.References.Single();

Diff for: RubberduckTests/Inspections/ObjectVariableNotSetInspectionTests.cs

+1-32
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
using System.Linq;
12
using NUnit.Framework;
23
using Rubberduck.CodeAnalysis.Inspections;
34
using Rubberduck.CodeAnalysis.Inspections.Concrete;
45
using Rubberduck.Parsing.VBA;
56
using Rubberduck.VBEditor;
67
using Rubberduck.VBEditor.SafeComWrappers;
78
using RubberduckTests.Mocks;
8-
using System.Linq;
99

1010
namespace RubberduckTests.Inspections
1111
{
@@ -210,37 +210,6 @@ Dim target As Variant
210210
AssertInputCodeYieldsExpectedInspectionResultCount(input, expectResultCount);
211211
}
212212

213-
[Test]
214-
[Category("Inspections")]
215-
public void ObjectVariableNotSet_GivenObjectArray_ReturnsNoResult()
216-
{
217-
var expectResultCount = 0;
218-
var input =
219-
@"
220-
Private myObjectArray() As Object
221-
222-
Public Property Get ObjectArray() As Object()
223-
ObjectArray = myObjectArray
224-
End Property
225-
226-
227-
Public Sub Test()
228-
229-
Dim oArr1(0) As Object
230-
Set oArr1(0) = New Something
231-
232-
myObjectArray = oArr1
233-
234-
Dim oArr2() As Object
235-
oArr2 = ObjectArray
236-
237-
Debug.Print oArr2(0).Name
238-
239-
End Sub
240-
";
241-
AssertInputCodeYieldsExpectedInspectionResultCount(input, expectResultCount);
242-
}
243-
244213
[Test]
245214
[Category("Inspections")]
246215
public void ObjectVariableNotSet_GivenObjectVariableNotSet_Ignored_DoesNotReturnResult()

0 commit comments

Comments
 (0)