Skip to content

Commit bc53551

Browse files
committed
Renaming and other cleanup
1 parent c9d4b03 commit bc53551

File tree

2 files changed

+15
-20
lines changed

2 files changed

+15
-20
lines changed

RetailCoder.VBE/Inspections/QuickFixes/AssignedByValParameterMakeLocalCopyQuickFix.cs

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -116,33 +116,32 @@ private string BuildLocalCopyAssignment()
116116

117117
private IEnumerable<string> GetIdentifierNamesAccessibleToProcedureContext()
118118
{
119-
var allIdentifiers = new HashSet<string>();
120-
121-
var allParametersAndLocalVariables = _parserState.AllUserDeclarations
119+
var allSameProcedureDeclarations = _parserState.AllUserDeclarations
122120
.Where(item => item.ParentScope == _target.ParentScope)
123121
.ToList();
124122

125-
allIdentifiers.UnionWith(allParametersAndLocalVariables.Select(d => d.IdentifierName));
126-
127123
var sameModuleDeclarations = _parserState.AllUserDeclarations
128124
.Where(item => item.ComponentName == _target.ComponentName
129-
&& !IsProceduralContext(item.ParentDeclaration.Context))
125+
&& !IsDeclaredInMethodOrProperty(item.ParentDeclaration.Context))
130126
.ToList();
131127

132-
allIdentifiers.UnionWith(sameModuleDeclarations.Select(d => d.IdentifierName));
133-
134-
var allPublicDeclarations = _parserState.AllUserDeclarations
135-
.Where(item => (item.Accessibility == Accessibility.Public
136-
|| ((item.Accessibility == Accessibility.Implicit)
137-
&& item.ParentScopeDeclaration is ProceduralModuleDeclaration))
138-
&& !(item.ParentScopeDeclaration is ClassModuleDeclaration))
128+
var allGloballyAccessibleDeclarations = _parserState.AllUserDeclarations
129+
.Where(item => item.ProjectName == _target.ProjectName
130+
&& !(item.ParentScopeDeclaration is ClassModuleDeclaration)
131+
&& (item.Accessibility == Accessibility.Public
132+
|| ((item.Accessibility == Accessibility.Implicit)
133+
&& item.ParentScopeDeclaration is ProceduralModuleDeclaration)))
139134
.ToList();
140135

141-
allIdentifiers.UnionWith(allPublicDeclarations.Select(d => d.IdentifierName));
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));
142140

143-
return allIdentifiers.ToList();
141+
return accessibleIdentifierNames.ToList();
144142
}
145-
private bool IsProceduralContext(RuleContext context)
143+
144+
private bool IsDeclaredInMethodOrProperty(RuleContext context)
146145
{
147146
if (context is VBAParser.SubStmtContext)
148147
{

RetailCoder.VBE/Inspections/QuickFixes/PassParameterByReferenceQuickFix.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
using Antlr4.Runtime;
2-
using Antlr4.Runtime.Tree;
31
using Rubberduck.Common;
42
using Rubberduck.Inspections.Abstract;
53
using Rubberduck.Inspections.Resources;
64
using Rubberduck.Parsing.Grammar;
75
using Rubberduck.Parsing.Symbols;
86
using Rubberduck.VBEditor;
9-
using Rubberduck.VBEditor.SafeComWrappers.Abstract;
10-
using System.Linq;
117

128
namespace Rubberduck.Inspections.QuickFixes
139
{

0 commit comments

Comments
 (0)