Skip to content

Commit 2196a09

Browse files
committed
Removed use of HashSet and minor edits to PassByRefQuickFix
1 parent bc53551 commit 2196a09

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

RetailCoder.VBE/Inspections/QuickFixes/AssignedByValParameterMakeLocalCopyQuickFix.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,12 @@ private IEnumerable<string> GetIdentifierNamesAccessibleToProcedureContext()
133133
&& item.ParentScopeDeclaration is ProceduralModuleDeclaration)))
134134
.ToList();
135135

136-
var accessibleIdentifierNames = new HashSet<string>();
137-
accessibleIdentifierNames.UnionWith(allSameProcedureDeclarations.Select(d => d.IdentifierName));
138-
accessibleIdentifierNames.UnionWith(sameModuleDeclarations.Select(d => d.IdentifierName));
139-
accessibleIdentifierNames.UnionWith(allGloballyAccessibleDeclarations.Select(d => d.IdentifierName));
136+
var accessibleIdentifierNames = new List<string>();
137+
accessibleIdentifierNames.AddRange(allSameProcedureDeclarations.Select(d => d.IdentifierName));
138+
accessibleIdentifierNames.AddRange(sameModuleDeclarations.Select(d => d.IdentifierName));
139+
accessibleIdentifierNames.AddRange(allGloballyAccessibleDeclarations.Select(d => d.IdentifierName));
140140

141-
return accessibleIdentifierNames.ToList();
141+
return accessibleIdentifierNames.Distinct();
142142
}
143143

144144
private bool IsDeclaredInMethodOrProperty(RuleContext context)

RetailCoder.VBE/Inspections/QuickFixes/PassParameterByReferenceQuickFix.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using Rubberduck.Parsing.Grammar;
55
using Rubberduck.Parsing.Symbols;
66
using Rubberduck.VBEditor;
7+
using Rubberduck.VBEditor.SafeComWrappers.Abstract;
78

89
namespace Rubberduck.Inspections.QuickFixes
910
{
@@ -12,18 +13,19 @@ namespace Rubberduck.Inspections.QuickFixes
1213
/// </summary>
1314
public class PassParameterByReferenceQuickFix : QuickFixBase
1415
{
15-
private Declaration _target;
16+
private readonly ICodeModule _codeModule;
17+
private VBAParser.ArgContext _argContext;
1618

1719
public PassParameterByReferenceQuickFix(Declaration target, QualifiedSelection selection)
1820
: base(target.Context, selection, InspectionsUI.PassParameterByReferenceQuickFix)
1921
{
20-
_target = target;
22+
_argContext = target.Context as VBAParser.ArgContext;
23+
_codeModule = Selection.QualifiedName.Component.CodeModule;
2124
}
2225

2326
public override void Fix()
2427
{
25-
var module = Selection.QualifiedName.Component.CodeModule;
26-
module.ReplaceToken(((VBAParser.ArgContext)Context).BYVAL().Symbol, Tokens.ByRef);
28+
_codeModule.ReplaceToken(_argContext.BYVAL().Symbol, Tokens.ByRef);
2729
}
2830
}
2931
}

0 commit comments

Comments
 (0)