Skip to content

Commit f39f248

Browse files
committed
Resolve review comments
1 parent 1af9ed6 commit f39f248

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

Rubberduck.Parsing/VBA/DeclarationCaching/DeclarationFinder.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1302,7 +1302,7 @@ public IEnumerable<Declaration> FindNewDeclarationNameConflicts(string newName,
13021302
return Enumerable.Empty<Declaration>();
13031303
}
13041304

1305-
var identifierMatches = MatchName(newName).Where(match => match.Project == renameTarget.Project);
1305+
var identifierMatches = MatchName(newName).Where(match => match.ProjectId == renameTarget.ProjectId);
13061306

13071307
if (!identifierMatches.Any())
13081308
{
@@ -1327,7 +1327,8 @@ public IEnumerable<Declaration> FindNewDeclarationNameConflicts(string newName,
13271327
&& !UsesScopeResolution(renameTargetRef.Context.Parent)))
13281328
|| idm.DeclarationType.HasFlag(DeclarationType.Variable)
13291329
&& idm.ParentDeclaration.DeclarationType.HasFlag(DeclarationType.Module)
1330-
&& renameTarget.References.Any(renameTargetRef => renameTargetRef.QualifiedModuleName == idm.ParentDeclaration.QualifiedModuleName));
1330+
&& renameTarget.References.Any(renameTargetRef => renameTargetRef.QualifiedModuleName == idm.ParentDeclaration.QualifiedModuleName))
1331+
.ToList();
13311332

13321333
if (referenceConflicts.Any())
13331334
{
@@ -1342,7 +1343,8 @@ public IEnumerable<Declaration> FindNewDeclarationNameConflicts(string newName,
13421343
renameTargetModule,
13431344
renameTarget.ParentDeclaration,
13441345
idm)
1345-
&& IsConflictingMember(renameTarget, renameTargetModule, idm));
1346+
&& IsConflictingMember(renameTarget, renameTargetModule, idm))
1347+
.ToList();
13461348

13471349
return declarationConflicts;
13481350
}

RubberduckTests/Symbols/DeclarationFinderTests.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -450,10 +450,10 @@ End Sub
450450
//https://github.com/rubberduck-vba/Rubberduck/issues/4969
451451
private const string projectOneModuleName = "projectOneModule";
452452
private const string projectTwoModuleName = "projectTwoModule";
453-
[TestCase(projectOneModuleName, ExpectedResult = 0)] //Duplicate module name found in a separate project
454-
[TestCase(projectTwoModuleName, ExpectedResult = 1)] //Duplicate module name found in the same project
453+
[TestCase(projectOneModuleName, 0)] //Duplicate module name found in a separate project
454+
[TestCase(projectTwoModuleName, 1)] //Duplicate module name found in the same project
455455
[Category("Resolver")]
456-
public int DeclarationFinder_NameConflictDetectionRespectsProjectScope(string proposedTestModuleName)
456+
public void DeclarationFinder_NameConflictDetectionRespectsProjectScope(string proposedTestModuleName, int expectedCount)
457457
{
458458

459459
string renameTargetModuleName = "TargetModule";
@@ -476,11 +476,12 @@ public int DeclarationFinder_NameConflictDetectionRespectsProjectScope(string pr
476476

477477
using(var parser = MockParser.CreateAndParse(vbe))
478478
{
479-
var target = parser.DeclarationFinder.AllDeclarations
479+
var target = parser.DeclarationFinder.UserDeclarations(DeclarationType.ProceduralModule)
480480
.FirstOrDefault(item => item.IdentifierName.Equals(renameTargetModuleName));
481481

482482
var results = parser.DeclarationFinder.FindNewDeclarationNameConflicts(proposedTestModuleName, target);
483-
return results.Count();
483+
484+
Assert.AreEqual(expectedCount, results.Count());
484485
}
485486
}
486487

0 commit comments

Comments
 (0)