Skip to content

Commit ece3a5d

Browse files
committed
Merge pull request #1298 from retailcoder/next
replaced Project.Equals with ProjectName.Equals everywhere
2 parents f411c31 + f3dad99 commit ece3a5d

File tree

15 files changed

+38
-34
lines changed

15 files changed

+38
-34
lines changed

RetailCoder.VBE/Common/DeclarationExtensions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ public static IEnumerable<Declaration> FindEventProcedures(this IEnumerable<Decl
354354
var handlerNames = events.Select(e => withEventsDeclaration.IdentifierName + '_' + e.IdentifierName);
355355

356356
return items.Where(item => item.Project != null
357-
&& item.Project.Equals(withEventsDeclaration.Project)
357+
&& item.ProjectName == withEventsDeclaration.ProjectName
358358
&& item.ParentScope == withEventsDeclaration.ParentScope
359359
&& item.DeclarationType == DeclarationType.Procedure
360360
&& handlerNames.Any(name => item.IdentifierName == name))
@@ -363,7 +363,7 @@ public static IEnumerable<Declaration> FindEventProcedures(this IEnumerable<Decl
363363

364364
private static IEnumerable<Declaration> GetTypeMembers(this IEnumerable<Declaration> declarations, Declaration type)
365365
{
366-
return declarations.Where(item => item.Project != null && item.Project.Equals(type.Project) && item.ParentScope == type.Scope);
366+
return declarations.Where(item => item.Project != null && item.ProjectName == type.ProjectName && item.ParentScope == type.Scope);
367367
}
368368

369369
/// <summary>
@@ -394,7 +394,7 @@ public static Declaration FindInterfaceMember(this IEnumerable<Declaration> decl
394394
var matches = members.Where(m => !m.IsBuiltIn && implementation.IdentifierName == m.ComponentName + '_' + m.IdentifierName).ToList();
395395

396396
return matches.Count > 1
397-
? matches.SingleOrDefault(m => m.Project == implementation.Project)
397+
? matches.SingleOrDefault(m => m.ProjectName == implementation.ProjectName)
398398
: matches.First();
399399
}
400400

RetailCoder.VBE/Inspections/ProcedureNotUsedInspection.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ private bool IsPublicModuleMember(IEnumerable<Declaration> modules, Declaration
8383
return false;
8484
}
8585

86-
var parent = modules.Where(item => item.Project == procedure.Project)
86+
var parent = modules.Where(item => item.ProjectName == procedure.ProjectName)
8787
.SingleOrDefault(item => item.IdentifierName == procedure.ComponentName);
8888

8989
return parent != null;
@@ -102,7 +102,7 @@ private bool IsClassLifeCycleHandler(IEnumerable<Declaration> classes, Declarati
102102
return false;
103103
}
104104

105-
var parent = classes.Where(item => item.Project == procedure.Project)
105+
var parent = classes.Where(item => item.ProjectName == procedure.ProjectName)
106106
.SingleOrDefault(item => item.IdentifierName == procedure.ComponentName);
107107

108108
return parent != null;
@@ -118,7 +118,7 @@ private bool IsInterfaceMember(IEnumerable<Declaration> declarations, IEnumerabl
118118
{
119119
// get the procedure's parent module
120120
var enumerable = classes as IList<Declaration> ?? classes.ToList();
121-
var parent = enumerable.Where(item => item.Project == procedure.Project)
121+
var parent = enumerable.Where(item => item.ProjectName == procedure.ProjectName)
122122
.SingleOrDefault(item => item.IdentifierName == procedure.ComponentName);
123123

124124
if (parent == null)

RetailCoder.VBE/Refactorings/ExtractInterface/ExtractInterfaceModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public ExtractInterfaceModel(RubberduckParserState state, QualifiedSelection sel
4949
InterfaceName = "I" + TargetDeclaration.IdentifierName;
5050

5151
_members = declarations.Where(item => !item.IsBuiltIn
52-
&& item.Project == _targetDeclaration.Project
52+
&& item.ProjectName == _targetDeclaration.ProjectName
5353
&& item.ComponentName == _targetDeclaration.ComponentName
5454
&& (item.Accessibility == Accessibility.Public || item.Accessibility == Accessibility.Implicit)
5555
&& MemberTypes.Contains(item.DeclarationType))

RetailCoder.VBE/Refactorings/ImplementInterface/ImplementInterfaceRefactoring.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ private IEnumerable<Declaration> GetInterfaceMembers()
206206
private IEnumerable<Declaration> GetImplementedMembers()
207207
{
208208
return _declarations.FindInterfaceImplementationMembers()
209-
.Where(item => item.Project.Equals(_targetInterface.Project)
209+
.Where(item => item.ProjectName == _targetInterface.ProjectName
210210
&& item.ComponentName == _targetClass.IdentifierName
211211
&& item.IdentifierName.StartsWith(_targetInterface.ComponentName + "_")
212212
&& !item.Equals(_targetClass))

RetailCoder.VBE/Refactorings/IntroduceParameter/IntroduceParameterRefactoring.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ private void UpdateSignature(Declaration targetVariable)
148148
UpdateSignature(interfaceImplementation, targetVariable);
149149

150150
var interfaceImplementations = _declarations.FindInterfaceImplementationMembers()
151-
.Where(item => item.Project.Equals(interfaceImplementation.Project)
151+
.Where(item => item.ProjectName == interfaceImplementation.ProjectName
152152
&& item.IdentifierName == interfaceImplementation.ComponentName + "_" + interfaceImplementation.IdentifierName
153153
&& !item.Equals(functionDeclaration));
154154

RetailCoder.VBE/Refactorings/RemoveParameters/RemoveParametersModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ private IEnumerable<Declaration> GetParameters()
6767

6868
return Declarations.Where(d => d.DeclarationType == DeclarationType.Parameter
6969
&& d.ComponentName == TargetDeclaration.ComponentName
70-
&& d.Project.Equals(TargetDeclaration.Project)
70+
&& d.ProjectName == TargetDeclaration.ProjectName
7171
&& targetSelection.Contains(d.Selection))
7272
.OrderBy(item => item.Selection.StartLine)
7373
.ThenBy(item => item.Selection.StartColumn);

RetailCoder.VBE/Refactorings/RemoveParameters/RemoveParametersRefactoring.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ private void AdjustSignatures()
273273
}
274274

275275
var interfaceImplementations = _model.Declarations.FindInterfaceImplementationMembers()
276-
.Where(item => item.Project.Equals(_model.TargetDeclaration.Project) &&
276+
.Where(item => item.ProjectName == _model.TargetDeclaration.ProjectName &&
277277
item.IdentifierName == _model.TargetDeclaration.ComponentName + "_" + _model.TargetDeclaration.IdentifierName);
278278
foreach (var interfaceImplentation in interfaceImplementations)
279279
{

RetailCoder.VBE/Refactorings/Rename/RenameRefactoring.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
using Rubberduck.Parsing.VBA;
1313
using Rubberduck.UI;
1414
using Rubberduck.VBEditor;
15+
using Rubberduck.VBEditor.Extensions;
1516

1617
namespace Rubberduck.Refactorings.Rename
1718
{
@@ -77,7 +78,7 @@ private Declaration FindDeclarationForIdentifier()
7778
{
7879
var targetReference = reference;
7980
var potentialDeclarations = _model.Declarations.Where(item => !item.IsBuiltIn
80-
&& item.Project.Equals(targetReference.Declaration.Project)
81+
&& item.ProjectName == targetReference.Declaration.ProjectName
8182
&& ((item.Context != null
8283
&& item.Context.Start.Line <= targetReference.Selection.StartLine
8384
&& item.Context.Stop.Line >= targetReference.Selection.EndLine)
@@ -148,7 +149,7 @@ private void Rename()
148149
{
149150
// properties can have more than 1 member.
150151
var members = _model.Declarations.Named(_model.Target.IdentifierName)
151-
.Where(item => item.Project == _model.Target.Project
152+
.Where(item => item.ProjectName == _model.Target.ProjectName
152153
&& item.ComponentName == _model.Target.ComponentName
153154
&& item.DeclarationType.HasFlag(DeclarationType.Property));
154155
foreach (var member in members)
@@ -211,7 +212,7 @@ private void RenameProject()
211212
{
212213
try
213214
{
214-
var project = _state.Projects.SingleOrDefault(p => p == _model.Target.Project);
215+
var project = _state.Projects.SingleOrDefault(p => p.ProjectName() == _model.Target.ProjectName);
215216
if (project != null)
216217
{
217218
project.Name = _model.NewName;
@@ -250,7 +251,7 @@ private void RenameDeclaration(Declaration target, string newName)
250251
else
251252
{
252253
var members = _model.Declarations.Named(target.IdentifierName)
253-
.Where(item => item.Project == target.Project
254+
.Where(item => item.ProjectName == target.ProjectName
254255
&& item.ComponentName == target.ComponentName
255256
&& item.DeclarationType.HasFlag(DeclarationType.Property));
256257

RetailCoder.VBE/Refactorings/ReorderParameters/ReorderParametersRefactoring.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ private void AdjustSignatures()
182182
}
183183

184184
var interfaceImplementations = _model.Declarations.FindInterfaceImplementationMembers()
185-
.Where(item => item.Project.Equals(_model.TargetDeclaration.Project) &&
185+
.Where(item => item.ProjectName == _model.TargetDeclaration.ProjectName &&
186186
item.IdentifierName == _model.TargetDeclaration.ComponentName + "_" + _model.TargetDeclaration.IdentifierName);
187187
foreach (var interfaceImplentation in interfaceImplementations)
188188
{

RetailCoder.VBE/UI/Command/Refactorings/FormDesignerRefactorRenameCommand.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using Rubberduck.Parsing.VBA;
88
using Rubberduck.Refactorings.Rename;
99
using Rubberduck.UI.Refactorings;
10+
using Rubberduck.VBEditor.Extensions;
1011

1112
namespace Rubberduck.UI.Command.Refactorings
1213
{
@@ -55,7 +56,7 @@ private Declaration GetTarget()
5556
return _state.AllUserDeclarations
5657
.FirstOrDefault(item => item.IdentifierName == control.Name &&
5758
item.ComponentName == Vbe.SelectedVBComponent.Name &&
58-
Vbe.ActiveVBProject.Equals(item.Project));
59+
Vbe.ActiveVBProject.ProjectName() == item.ProjectName);
5960
}
6061
}
6162

0 commit comments

Comments
 (0)