77using Rubberduck . UI . Command . MenuItems . ParentMenus ;
88using Rubberduck . VBEditor ;
99using ParserState = Rubberduck . Parsing . VBA . ParserState ;
10- using NLog ;
1110
1211namespace Rubberduck . UI . Command . MenuItems
1312{
@@ -21,7 +20,6 @@ public class RubberduckCommandBar : IDisposable
2120 private CommandBarButton _statusButton ;
2221 private CommandBarButton _selectionButton ;
2322 private CommandBar _commandbar ;
24- private static readonly Logger _logger = LogManager . GetCurrentClassLogger ( ) ;
2523
2624 public RubberduckCommandBar ( RubberduckParserState state , VBE vbe , IShowParserErrorsCommand command )
2725 {
@@ -32,7 +30,7 @@ public RubberduckCommandBar(RubberduckParserState state, VBE vbe, IShowParserErr
3230 Initialize ( ) ;
3331 }
3432
35- private void _statusButton_Click ( CommandBarButton Ctrl , ref bool CancelDefault )
33+ private void _statusButton_Click ( CommandBarButton ctrl , ref bool cancelDefault )
3634 {
3735 if ( _state . Status == ParserState . Error )
3836 {
@@ -43,7 +41,6 @@ private void _statusButton_Click(CommandBarButton Ctrl, ref bool CancelDefault)
4341 public void SetStatusText ( string value = null )
4442 {
4543 var text = value ?? RubberduckUI . ResourceManager . GetString ( "ParserState_" + _state . Status ) ;
46- _logger . Debug ( "RubberduckCommandBar status text changes to '{0}'." , text ) ;
4744 UiDispatcher . Invoke ( ( ) => _statusButton . Caption = text ) ;
4845 }
4946
@@ -55,31 +52,21 @@ public void SetSelectionText(Declaration declaration)
5552 if ( selection . HasValue ) { SetSelectionText ( selection . Value ) ; }
5653 _selectionButton . TooltipText = _selectionButton . Caption ;
5754 }
58- else if ( declaration != null && ! declaration . IsBuiltIn && declaration . DeclarationType != DeclarationType . ClassModule && declaration . DeclarationType != DeclarationType . ProceduralModule )
55+ else if ( declaration != null )
5956 {
57+ var typeName = declaration . HasTypeHint
58+ ? Declaration . TypeHintToTypeName [ declaration . TypeHint ]
59+ : declaration . AsTypeName ;
60+
6061 _selectionButton . Caption = string . Format ( "{0}|{1}: {2} ({3}{4})" ,
6162 declaration . QualifiedSelection . Selection ,
6263 declaration . QualifiedName . QualifiedModuleName ,
6364 declaration . IdentifierName ,
6465 RubberduckUI . ResourceManager . GetString ( "DeclarationType_" + declaration . DeclarationType ) ,
65- string . IsNullOrEmpty ( declaration . AsTypeName ) ? string . Empty : ": " + declaration . AsTypeName ) ;
66- _selectionButton . TooltipText = string . IsNullOrEmpty ( declaration . DescriptionString )
67- ? _selectionButton . Caption
68- : declaration . DescriptionString ;
69- }
70- else if ( declaration != null )
71- {
72- // todo: confirm this is what we want, and then refator
73- var selection = _vbe . ActiveCodePane . GetQualifiedSelection ( ) ;
74- if ( selection . HasValue )
75- {
76- _selectionButton . Caption = string . Format ( "{0}|{1}: {2} ({3}{4})" ,
77- selection . Value . Selection ,
78- declaration . QualifiedName . QualifiedModuleName ,
79- declaration . IdentifierName ,
80- RubberduckUI . ResourceManager . GetString ( "DeclarationType_" + declaration . DeclarationType ) ,
81- string . IsNullOrEmpty ( declaration . AsTypeName ) ? string . Empty : ": " + declaration . AsTypeName ) ;
82- }
66+ string . IsNullOrEmpty ( declaration . AsTypeName )
67+ ? string . Empty
68+ : ": " + typeName ) ;
69+
8370 _selectionButton . TooltipText = string . IsNullOrEmpty ( declaration . DescriptionString )
8471 ? _selectionButton . Caption
8572 : declaration . DescriptionString ;
@@ -93,8 +80,6 @@ private void SetSelectionText(QualifiedSelection selection)
9380
9481 private void State_StateChanged ( object sender , EventArgs e )
9582 {
96- _logger . Debug ( "RubberduckCommandBar handles StateChanged..." ) ;
97-
9883 if ( _state . Status != ParserState . ResolvedDeclarations )
9984 {
10085 SetStatusText ( RubberduckUI . ResourceManager . GetString ( "ParserState_" + _state . Status ) ) ;
@@ -112,15 +97,15 @@ private void OnRefresh()
11297 }
11398 }
11499
115- public void Initialize ( )
100+ private void Initialize ( )
116101 {
117102 _commandbar = _vbe . CommandBars . Add ( "Rubberduck" , MsoBarPosition . msoBarTop , false , true ) ;
118103
119104 _refreshButton = ( CommandBarButton ) _commandbar . Controls . Add ( MsoControlType . msoControlButton ) ;
120105 ParentMenuItemBase . SetButtonImage ( _refreshButton , Resources . arrow_circle_double , Resources . arrow_circle_double_mask ) ;
121106 _refreshButton . Style = MsoButtonStyle . msoButtonIcon ;
122107 _refreshButton . Tag = "Refresh" ;
123- _refreshButton . TooltipText = RubberduckUI . RubberduckCommandbarRefreshButtonTooltip ;
108+ _refreshButton . TooltipText = RubberduckUI . RubberduckCommandbarRefreshButtonTooltip ;
124109 _refreshButton . Click += refreshButton_Click ;
125110
126111 _statusButton = ( CommandBarButton ) _commandbar . Controls . Add ( MsoControlType . msoControlButton ) ;
@@ -136,7 +121,7 @@ public void Initialize()
136121 _commandbar . Visible = true ;
137122 }
138123
139- private void refreshButton_Click ( CommandBarButton Ctrl , ref bool CancelDefault )
124+ private void refreshButton_Click ( CommandBarButton ctrl , ref bool cancelDefault )
140125 {
141126 OnRefresh ( ) ;
142127 }
0 commit comments