Skip to content

Commit c7ac2da

Browse files
committed
Remove ProjectDisplayName from ProjectDeclaration
This also removes the IVbProject ctor parameter.
1 parent 156e1b7 commit c7ac2da

File tree

8 files changed

+12
-52
lines changed

8 files changed

+12
-52
lines changed

Rubberduck.Core/Formatters/InspectionResultFormatter.cs

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ namespace Rubberduck.Formatters
88
public class InspectionResultFormatter : IExportable
99
{
1010
private readonly IInspectionResult _inspectionResult;
11+
private readonly string _documentName;
1112

12-
public InspectionResultFormatter(IInspectionResult inspectionResult)
13+
public InspectionResultFormatter(IInspectionResult inspectionResult, string documentName)
1314
{
1415
_inspectionResult = inspectionResult;
16+
_documentName = documentName;
1517
}
1618

1719
public object[] ToArray()
@@ -28,30 +30,10 @@ public object[] ToArray()
2830
};
2931
}
3032

31-
/// <summary>
32-
/// WARNING: This property can have side effects. It can change the ActiveVBProject if the result has a null Declaration,
33-
/// which causes a flicker in the VBE. This should only be called if it is *absolutely* necessary.
34-
/// </summary>
3533
public string ToClipboardString()
3634
{
3735
var module = _inspectionResult.QualifiedSelection.QualifiedName;
38-
var documentName = _inspectionResult.Target != null
39-
? _inspectionResult.Target.ProjectDisplayName
40-
: string.Empty;
41-
42-
//todo: Find a sane way to reimplement this.
43-
//if (string.IsNullOrEmpty(documentName))
44-
//{
45-
// var component = module.Component;
46-
// documentName = component != null
47-
// ? component.ParentProject.ProjectDisplayName
48-
// : string.Empty;
49-
//}
50-
51-
if (string.IsNullOrEmpty(documentName))
52-
{
53-
documentName = Path.GetFileName(module.ProjectPath);
54-
}
36+
var documentName = _documentName;
5537

5638
return string.Format(
5739
InspectionsUI.QualifiedSelectionInspection,

Rubberduck.Parsing/Symbols/ProjectDeclaration.cs

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,17 @@
33
using Rubberduck.VBEditor;
44
using System.Collections.Generic;
55
using System.Linq;
6-
using Rubberduck.VBEditor.SafeComWrappers.Abstract;
76

87
namespace Rubberduck.Parsing.Symbols
98
{
109
public sealed class ProjectDeclaration : Declaration, IDisposable
1110
{
1211
private readonly List<ProjectReference> _projectReferences;
13-
private readonly IVBProject _project;
1412

1513
public ProjectDeclaration(
1614
QualifiedMemberName qualifiedName,
1715
string name,
18-
bool isUserDefined,
19-
IVBProject project)
16+
bool isUserDefined)
2017
: base(
2118
qualifiedName,
2219
null,
@@ -34,12 +31,11 @@ public ProjectDeclaration(
3431
null,
3532
isUserDefined)
3633
{
37-
_project = project;
3834
_projectReferences = new List<ProjectReference>();
3935
}
4036

4137
public ProjectDeclaration(ComProject project, QualifiedModuleName module)
42-
: this(module.QualifyMemberName(project.Name), project.Name, false, null)
38+
: this(module.QualifyMemberName(project.Name), project.Name, false)
4339
{
4440
Guid = project.Guid;
4541
MajorVersion = project.MajorVersion;
@@ -72,24 +68,6 @@ public void ClearProjectReferences()
7268
_projectReferences.Clear();
7369
}
7470

75-
private string _displayName;
76-
/// <summary>
77-
/// WARNING: This property has side effects. It changes the ActiveVBProject, which causes a flicker in the VBE.
78-
/// This should only be called if it is *absolutely* necessary.
79-
/// </summary>
80-
public override string ProjectDisplayName
81-
{
82-
get
83-
{
84-
if (_displayName != null)
85-
{
86-
return _displayName;
87-
}
88-
_displayName = !IsDisposed && _project != null ? _project.ProjectDisplayName : string.Empty;
89-
return _displayName;
90-
}
91-
}
92-
9371
public bool IsDisposed { get; private set; }
9472

9573
public void Dispose()

Rubberduck.Parsing/VBA/DeclarationResolving/DeclarationResolveRunnerBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ private Declaration CreateProjectDeclaration(string projectId)
8080

8181
var qualifiedModuleName = new QualifiedModuleName(project);
8282
var qualifiedName = qualifiedModuleName.QualifyMemberName(project.Name);
83-
var projectDeclaration = new ProjectDeclaration(qualifiedName, qualifiedName.MemberName, true, project);
83+
var projectDeclaration = new ProjectDeclaration(qualifiedName, qualifiedName.MemberName, true);
8484

8585
return projectDeclaration;
8686
}

RubberduckTests/Symbols/AccessibilityCheckTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public void ProjectsAreAlwaysAccessible()
2323
private static ProjectDeclaration GetTestProject(string name)
2424
{
2525
var qualifiedProjectName = new QualifiedMemberName(StubQualifiedModuleName(), name);
26-
return new ProjectDeclaration(qualifiedProjectName, name, true, null);
26+
return new ProjectDeclaration(qualifiedProjectName, name, true);
2727
}
2828

2929
private static QualifiedModuleName StubQualifiedModuleName()

RubberduckTests/Symbols/ClassModuleDeclarationTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public void ClassModulesHaveDeclarationTypeClassModule()
2222
private static ProjectDeclaration GetTestProject(string name)
2323
{
2424
var qualifiedProjectName = new QualifiedMemberName(StubQualifiedModuleName(), name);
25-
return new ProjectDeclaration(qualifiedProjectName, name, true, null);
25+
return new ProjectDeclaration(qualifiedProjectName, name, true);
2626
}
2727

2828
private static QualifiedModuleName StubQualifiedModuleName()

RubberduckTests/Symbols/DeclarationFinderTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1583,7 +1583,7 @@ private static ClassModuleDeclaration GetTestClassModule(Declaration projectDecl
15831583
private static ProjectDeclaration GetTestProject(string name)
15841584
{
15851585
var qualifiedProjectName = new QualifiedMemberName(StubQualifiedModuleName("proj"), name);
1586-
return new ProjectDeclaration(qualifiedProjectName, name, true, null);
1586+
return new ProjectDeclaration(qualifiedProjectName, name, true);
15871587
}
15881588

15891589
private static QualifiedModuleName StubQualifiedModuleName(string name)

RubberduckTests/Symbols/ProceduralModuleDeclarationTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public void ProceduralModulesHaveDeclarationTypeProceduralModule()
2121
private static ProjectDeclaration GetTestProject(string name)
2222
{
2323
var qualifiedProjectName = new QualifiedMemberName(StubQualifiedModuleName(), name);
24-
return new ProjectDeclaration(qualifiedProjectName, name, true, null);
24+
return new ProjectDeclaration(qualifiedProjectName, name, true);
2525
}
2626

2727
private static QualifiedModuleName StubQualifiedModuleName()

RubberduckTests/Symbols/ProjectDeclarationTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public void ProjectsHaveDeclarationTypeProject()
2020
private static ProjectDeclaration GetTestProject(string name)
2121
{
2222
var qualifiedProjectName = new QualifiedMemberName(StubQualifiedModuleName(), name);
23-
return new ProjectDeclaration(qualifiedProjectName, name, true, null);
23+
return new ProjectDeclaration(qualifiedProjectName, name, true);
2424
}
2525

2626
private static QualifiedModuleName StubQualifiedModuleName()

0 commit comments

Comments
 (0)