Skip to content

Commit c0377a0

Browse files
committed
style: Add monikers for regions, base classes, implemented interfaces
1 parent 75ea1e5 commit c0377a0

5 files changed

Lines changed: 16 additions & 6 deletions

File tree

src/CodeNav.OutOfProc/Languages/CSharp/Mappers/ClassMapper.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ private static void MapMembersFromBaseClass(ClassDeclarationSyntax member,
104104
Id = baseType.Name,
105105
Tooltip = baseType.Name,
106106
Kind = CodeItemKindEnum.BaseClass,
107+
Moniker = IconMapper.MapMoniker(CodeItemKindEnum.BaseClass, CodeItemAccessEnum.Unknown),
107108
};
108109

109110
regions.Add(baseRegion);

src/CodeNav.OutOfProc/Languages/CSharp/Mappers/InterfaceMapper.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ private static CodeImplementedInterfaceItem MapImplementedInterface(string name,
9393
Id = name,
9494
Tooltip = name,
9595
Kind = CodeItemKindEnum.ImplementedInterface,
96-
IsExpanded = true
96+
IsExpanded = true,
97+
Moniker = IconMapper.MapMoniker(CodeItemKindEnum.ImplementedInterface, CodeItemAccessEnum.Unknown),
9798
};
9899

99100
foreach (var member in members)

src/CodeNav.OutOfProc/Languages/CSharp/Mappers/RegionMapper.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using CodeNav.OutOfProc.Constants;
22
using CodeNav.OutOfProc.Helpers;
33
using CodeNav.OutOfProc.Interfaces;
4+
using CodeNav.OutOfProc.Mappers;
45
using CodeNav.OutOfProc.ViewModels;
56
using Microsoft.CodeAnalysis;
67
using Microsoft.CodeAnalysis.CSharp;
@@ -110,7 +111,8 @@ private static CodeRegionItem MapRegion(SyntaxTrivia regionStart)
110111
Id = name,
111112
Tooltip = name,
112113
Kind = CodeItemKindEnum.Region,
113-
Span = new(regionStart.Span.Start, 0)
114+
Span = new(regionStart.Span.Start, 0),
115+
Moniker = IconMapper.MapMoniker(CodeItemKindEnum.Region, CodeItemAccessEnum.Unknown),
114116
};
115117
}
116118

src/CodeNav.OutOfProc/Mappers/IconMapper.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,23 @@ public static ImageMoniker MapMoniker(CodeItemKindEnum kind, CodeItemAccessEnum
1212

1313
string monikerString = kind switch
1414
{
15-
CodeItemKindEnum.Namespace => $"Namespace{accessString}",
15+
CodeItemKindEnum.BaseClass => "ClassShortcut",
1616
CodeItemKindEnum.Class => $"Class{accessString}",
1717
CodeItemKindEnum.Constant => $"Constant{accessString}",
18+
CodeItemKindEnum.Constructor or CodeItemKindEnum.Method => $"Method{accessString}",
1819
CodeItemKindEnum.Delegate => $"Delegate{accessString}",
1920
CodeItemKindEnum.Enum => $"Enumeration{accessString}",
2021
CodeItemKindEnum.EnumMember => $"EnumerationItem{accessString}",
2122
CodeItemKindEnum.Event => $"Event{accessString}",
23+
CodeItemKindEnum.ImplementedInterface => "ImplementInterface",
2224
CodeItemKindEnum.Interface => $"Interface{accessString}",
23-
CodeItemKindEnum.Constructor or CodeItemKindEnum.Method => $"Method{accessString}",
25+
CodeItemKindEnum.Namespace => $"Namespace{accessString}",
2426
CodeItemKindEnum.Property or CodeItemKindEnum.Indexer => $"Property{accessString}",
27+
CodeItemKindEnum.Region => $"ExpandRight",
2528
CodeItemKindEnum.Struct or CodeItemKindEnum.Record => $"Structure{accessString}",
26-
CodeItemKindEnum.Variable => $"Field{accessString}",
2729
CodeItemKindEnum.Switch => "FlowSwitch",
2830
CodeItemKindEnum.SwitchSection => "FlowDecision",
31+
CodeItemKindEnum.Variable => $"Field{accessString}",
2932
_ => $"Property{accessString}",
3033
};
3134

src/CodeNav.OutOfProc/ToolWindows/Templates/CodeItemStyles.xaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,10 +213,13 @@
213213
Opacity="{Binding Opacity}"
214214
HorizontalAlignment="Stretch">
215215
<Expander.Header>
216-
<TextBlock
216+
<StackPanel Orientation="Horizontal">
217+
<vs:Image Source="{Binding Moniker}" Width="16" Height="16" Margin="0,0,3,0" />
218+
<TextBlock
217219
Text="{Binding Name}"
218220
FontWeight="SemiBold"
219221
Style="{StaticResource {x:Static styles:VsResourceKeys.TextBlockEnvironment90PercentFontSizeStyleKey}}" />
222+
</StackPanel>
220223
</Expander.Header>
221224
<ItemsControl
222225
ItemsSource="{Binding Members}"

0 commit comments

Comments
 (0)