Skip to content

Commit 8263002

Browse files
committed
Add predeclared indicator to name with signature and custom icon. Closes #3703
1 parent 98b9f4a commit 8263002

File tree

4 files changed

+41
-7
lines changed

4 files changed

+41
-7
lines changed

Rubberduck.Core/Navigation/CodeExplorer/CodeExplorerComponentViewModel.cs

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,7 @@ public CodeExplorerComponentViewModel(CodeExplorerItemViewModel parent, Declarat
3737
: base(declaration)
3838
{
3939
Parent = parent;
40-
41-
_icon = Icons.ContainsKey(DeclarationType)
42-
? Icons[DeclarationType]
43-
: GetImageSource(CodeExplorerUI.status_offline);
40+
SetIcon();
4441

4542
Items = declarations.GroupBy(item => item.Scope).SelectMany(grouping =>
4643
grouping.Where(item => item.ParentDeclaration != null
@@ -166,8 +163,13 @@ public bool IsTestModule
166163

167164
private readonly string _name;
168165
public override string Name => _name;
169-
170-
public override string NameWithSignature => _name;
166+
167+
public override string NameWithSignature =>
168+
$"{_name}{(IsPredeclared ? " (Predeclared)" : string.Empty)}";
169+
170+
private bool IsPredeclared => Declaration != null &&
171+
Declaration.Attributes.HasPredeclaredIdAttribute(out _) &&
172+
Declaration.IsUserDefined;
171173

172174
public override QualifiedSelection? QualifiedSelection => Declaration.QualifiedSelection;
173175

@@ -206,6 +208,9 @@ private DeclarationType DeclarationType
206208
}
207209
}
208210

211+
private static readonly BitmapImage PredeclaredIcon = GetImageSource(CodeExplorerUI.ObjectClassPredeclared);
212+
private static readonly BitmapImage OopsIcon = GetImageSource(CodeExplorerUI.status_offline);
213+
209214
private static readonly IDictionary<DeclarationType,BitmapImage> Icons = new Dictionary<DeclarationType, BitmapImage>
210215
{
211216
{ DeclarationType.ClassModule, GetImageSource(CodeExplorerUI.ObjectClass) },
@@ -222,6 +227,22 @@ private DeclarationType DeclarationType
222227
{ DeclarationType.RelatedDocument, GetImageSource(CodeExplorerUI.document_import)}
223228
};
224229

230+
private void SetIcon()
231+
{
232+
if (IsPredeclared)
233+
{
234+
_icon = PredeclaredIcon;
235+
return;
236+
}
237+
238+
if (Icons.ContainsKey(DeclarationType))
239+
{
240+
_icon = Icons[DeclarationType];
241+
}
242+
243+
_icon = OopsIcon;
244+
}
245+
225246
private BitmapImage _icon;
226247
public override BitmapImage CollapsedIcon => _icon;
227248
public override BitmapImage ExpandedIcon => _icon;

Rubberduck.Resources/CodeExplorer/CodeExplorerUI.Designer.cs

Lines changed: 11 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Rubberduck.Resources/CodeExplorer/CodeExplorerUI.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,4 +412,7 @@
412412
<data name="CodeExplorer_LibraryReferences" xml:space="preserve">
413413
<value>Library References</value>
414414
</data>
415+
<data name="ObjectClassPredeclared" type="System.Resources.ResXFileRef, System.Windows.Forms">
416+
<value>..\Icons\Custom\PNG\ObjectClassPredeclared.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
417+
</data>
415418
</root>
Loading

0 commit comments

Comments
 (0)