Skip to content

Commit 8dfc3d4

Browse files
committed
renamed ProjectName to ProjectId, implemented changes to store original hashcode in Project.HelpFile
1 parent 2774a37 commit 8dfc3d4

23 files changed

+98
-127
lines changed

RetailCoder.VBE/App.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,8 +335,8 @@ async void sink_ProjectRenamed(object sender, DispatcherRenamedEventArgs<VBProje
335335
return;
336336
}
337337

338-
Debug.WriteLine("Project '{0}' was renamed to '{1}'.", e.OldName, e.Item.Name);
339-
_parser.State.RemoveProject(e.OldName);
338+
Debug.WriteLine("Project '{0}' (ID {1}) was renamed to '{2}'.", e.OldName, e.Item.HelpFile, e.Item.Name);
339+
_parser.State.RemoveProject(e.Item.HelpFile);
340340
_parser.State.OnParseRequested(sender);
341341
}
342342

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.ProjectName == withEventsDeclaration.ProjectName
357+
&& item.ProjectId == withEventsDeclaration.ProjectId
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.ProjectName == type.ProjectName && item.ParentScope == type.Scope);
366+
return declarations.Where(item => item.Project != null && item.ProjectId == type.ProjectId && 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.ProjectName == implementation.ProjectName)
397+
? matches.SingleOrDefault(m => m.ProjectId == implementation.ProjectId)
398398
: matches.First();
399399
}
400400

RetailCoder.VBE/Inspections/InspectionResultBase.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public override string ToString()
103103
InspectionsUI.QualifiedSelectionInspection,
104104
Inspection.Severity,
105105
Description,
106-
module.ProjectName,
106+
module.ProjectId,
107107
module.ComponentName,
108108
QualifiedSelection.Selection.StartLine);
109109
}
@@ -121,7 +121,7 @@ public int CompareTo(object obj)
121121
public object[] ToArray()
122122
{
123123
var module = QualifiedSelection.QualifiedName;
124-
return new object[] {Inspection.Severity.ToString(), Description, module.ProjectName, module.ComponentName, QualifiedSelection.Selection.StartLine };
124+
return new object[] {Inspection.Severity.ToString(), Description, module.ProjectId, module.ComponentName, QualifiedSelection.Selection.StartLine };
125125
}
126126

127127
public string ToCsvString()
@@ -131,7 +131,7 @@ public string ToCsvString()
131131
"\"{0}\",\"{1}\",\"{2}\",\"{3}\",{4}",
132132
Inspection.Severity,
133133
Description,
134-
module.ProjectName,
134+
module.ProjectId,
135135
module.ComponentName,
136136
QualifiedSelection.Selection.StartLine);
137137
}

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.ProjectName == procedure.ProjectName)
86+
var parent = modules.Where(item => item.ProjectId == procedure.ProjectId)
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.ProjectName == procedure.ProjectName)
105+
var parent = classes.Where(item => item.ProjectId == procedure.ProjectId)
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.ProjectName == procedure.ProjectName)
121+
var parent = enumerable.Where(item => item.ProjectId == procedure.ProjectId)
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.ProjectName == _targetDeclaration.ProjectName
52+
&& item.ProjectId == _targetDeclaration.ProjectId
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.ProjectName == _targetInterface.ProjectName
209+
.Where(item => item.ProjectId == _targetInterface.ProjectId
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.ProjectName == interfaceImplementation.ProjectName
151+
.Where(item => item.ProjectId == interfaceImplementation.ProjectId
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.ProjectName == TargetDeclaration.ProjectName
70+
&& d.ProjectId == TargetDeclaration.ProjectId
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.ProjectName == _model.TargetDeclaration.ProjectName &&
276+
.Where(item => item.ProjectId == _model.TargetDeclaration.ProjectId &&
277277
item.IdentifierName == _model.TargetDeclaration.ComponentName + "_" + _model.TargetDeclaration.IdentifierName);
278278
foreach (var interfaceImplentation in interfaceImplementations)
279279
{

RetailCoder.VBE/Refactorings/Rename/RenameRefactoring.cs

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

1716
namespace Rubberduck.Refactorings.Rename
1817
{
@@ -78,7 +77,7 @@ private Declaration FindDeclarationForIdentifier()
7877
{
7978
var targetReference = reference;
8079
var potentialDeclarations = _model.Declarations.Where(item => !item.IsBuiltIn
81-
&& item.ProjectName == targetReference.Declaration.ProjectName
80+
&& item.ProjectId == targetReference.Declaration.ProjectId
8281
&& ((item.Context != null
8382
&& item.Context.Start.Line <= targetReference.Selection.StartLine
8483
&& item.Context.Stop.Line >= targetReference.Selection.EndLine)
@@ -149,7 +148,7 @@ private void Rename()
149148
{
150149
// properties can have more than 1 member.
151150
var members = _model.Declarations.Named(_model.Target.IdentifierName)
152-
.Where(item => item.ProjectName == _model.Target.ProjectName
151+
.Where(item => item.ProjectId == _model.Target.ProjectId
153152
&& item.ComponentName == _model.Target.ComponentName
154153
&& item.DeclarationType.HasFlag(DeclarationType.Property));
155154
foreach (var member in members)
@@ -212,7 +211,7 @@ private void RenameProject()
212211
{
213212
try
214213
{
215-
var project = _state.Projects.SingleOrDefault(p => p.ProjectName() == _model.Target.ProjectName);
214+
var project = _state.Projects.SingleOrDefault(p => p.HelpFile == _model.Target.ProjectId);
216215
if (project != null)
217216
{
218217
project.Name = _model.NewName;
@@ -251,7 +250,7 @@ private void RenameDeclaration(Declaration target, string newName)
251250
else
252251
{
253252
var members = _model.Declarations.Named(target.IdentifierName)
254-
.Where(item => item.ProjectName == target.ProjectName
253+
.Where(item => item.ProjectId == target.ProjectId
255254
&& item.ComponentName == target.ComponentName
256255
&& item.DeclarationType.HasFlag(DeclarationType.Property));
257256

0 commit comments

Comments
 (0)