Skip to content

Commit 2e2b072

Browse files
committed
Fixed scoping bug with unassigned locals
1 parent fbab6d6 commit 2e2b072

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

RetailCoder.VBE/Inspections/VariableNotAssignedInspection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public IEnumerable<CodeInspectionResultBase> GetInspectionResults(IEnumerable<VB
8787

8888
// identify unassigned procedure-scoped declarations:
8989
unassignedDeclarations.AddRange(
90-
locals.Where(local => assignments.All(a => a.Name != local.Name))
90+
locals.Where(local => assignments.All(a => (a.Scope.MemberName + a.Name) != (local.Scope.MemberName + local.Name)))
9191
.Select(identifier => new VariableNotAssignedInspetionResult(Name, Severity, identifier.Context.ambiguousIdentifier(), result.QualifiedName)));
9292

9393
// identify globals assigned in this module:

RetailCoder.VBE/Inspections/VariableNotAssignedInspetionResult.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public override IDictionary<string, Action<VBE>> GetQuickFixes()
2020
return
2121
new Dictionary<string, Action<VBE>>
2222
{
23-
{"Remove unused variable", RemoveVariableDeclaration}
23+
{"Remove unassigned variable (and usages)", RemoveVariableDeclaration}
2424
};
2525
}
2626

@@ -46,5 +46,10 @@ private void RemoveVariableDeclaration(VBE vbe)
4646
module.InsertLines(selection.StartLine, newCodeLines);
4747
}
4848
}
49+
50+
private void RemoveVariableUsages(VBE vbe)
51+
{
52+
53+
}
4954
}
5055
}

0 commit comments

Comments
 (0)