Skip to content

Commit 1a23b2e

Browse files
committed
cached ProjectName
1 parent 0ecf7d0 commit 1a23b2e

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

Rubberduck.Parsing/Symbols/Declaration.cs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,15 @@ public Declaration(
156156
_attributes = attributes ?? new Attributes();
157157

158158
_projectId = _qualifiedName.QualifiedModuleName.ProjectId;
159+
var projectDeclaration = Declaration.GetProjectParent(parentDeclaration);
160+
if (projectDeclaration != null)
161+
{
162+
_projectName = projectDeclaration.IdentifierName;
163+
}
164+
else if (_declarationType == DeclarationType.Project)
165+
{
166+
_projectName = _identifierName;
167+
}
159168

160169
_customFolder = FolderFromAnnotations();
161170
_isArray = isArray;
@@ -392,17 +401,10 @@ public void AddMemberCall(IdentifierReference reference)
392401
/// </summary>
393402
public string ProjectId { get { return _projectId; } }
394403

404+
private readonly string _projectName;
395405
public string ProjectName
396406
{
397-
get
398-
{
399-
if (Project != null)
400-
{
401-
return Project.Name;
402-
}
403-
// Referenced projects have their identifier name set as their project name.
404-
return IdentifierName;
405-
}
407+
get { return _projectName; }
406408
}
407409

408410
public object[] ToArray()

0 commit comments

Comments
 (0)