7
7
using Rubberduck . UI . Command . MenuItems . ParentMenus ;
8
8
using Rubberduck . VBEditor ;
9
9
using ParserState = Rubberduck . Parsing . VBA . ParserState ;
10
- using NLog ;
11
10
12
11
namespace Rubberduck . UI . Command . MenuItems
13
12
{
@@ -21,7 +20,6 @@ public class RubberduckCommandBar : IDisposable
21
20
private CommandBarButton _statusButton ;
22
21
private CommandBarButton _selectionButton ;
23
22
private CommandBar _commandbar ;
24
- private static readonly Logger _logger = LogManager . GetCurrentClassLogger ( ) ;
25
23
26
24
public RubberduckCommandBar ( RubberduckParserState state , VBE vbe , IShowParserErrorsCommand command )
27
25
{
@@ -32,7 +30,7 @@ public RubberduckCommandBar(RubberduckParserState state, VBE vbe, IShowParserErr
32
30
Initialize ( ) ;
33
31
}
34
32
35
- private void _statusButton_Click ( CommandBarButton Ctrl , ref bool CancelDefault )
33
+ private void _statusButton_Click ( CommandBarButton ctrl , ref bool cancelDefault )
36
34
{
37
35
if ( _state . Status == ParserState . Error )
38
36
{
@@ -43,7 +41,6 @@ private void _statusButton_Click(CommandBarButton Ctrl, ref bool CancelDefault)
43
41
public void SetStatusText ( string value = null )
44
42
{
45
43
var text = value ?? RubberduckUI . ResourceManager . GetString ( "ParserState_" + _state . Status ) ;
46
- _logger . Debug ( "RubberduckCommandBar status text changes to '{0}'." , text ) ;
47
44
UiDispatcher . Invoke ( ( ) => _statusButton . Caption = text ) ;
48
45
}
49
46
@@ -55,31 +52,21 @@ public void SetSelectionText(Declaration declaration)
55
52
if ( selection . HasValue ) { SetSelectionText ( selection . Value ) ; }
56
53
_selectionButton . TooltipText = _selectionButton . Caption ;
57
54
}
58
- else if ( declaration != null && ! declaration . IsBuiltIn && declaration . DeclarationType != DeclarationType . ClassModule && declaration . DeclarationType != DeclarationType . ProceduralModule )
55
+ else if ( declaration != null )
59
56
{
57
+ var typeName = declaration . HasTypeHint
58
+ ? Declaration . TypeHintToTypeName [ declaration . TypeHint ]
59
+ : declaration . AsTypeName ;
60
+
60
61
_selectionButton . Caption = string . Format ( "{0}|{1}: {2} ({3}{4})" ,
61
62
declaration . QualifiedSelection . Selection ,
62
63
declaration . QualifiedName . QualifiedModuleName ,
63
64
declaration . IdentifierName ,
64
65
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
+
83
70
_selectionButton . TooltipText = string . IsNullOrEmpty ( declaration . DescriptionString )
84
71
? _selectionButton . Caption
85
72
: declaration . DescriptionString ;
@@ -93,8 +80,6 @@ private void SetSelectionText(QualifiedSelection selection)
93
80
94
81
private void State_StateChanged ( object sender , EventArgs e )
95
82
{
96
- _logger . Debug ( "RubberduckCommandBar handles StateChanged..." ) ;
97
-
98
83
if ( _state . Status != ParserState . ResolvedDeclarations )
99
84
{
100
85
SetStatusText ( RubberduckUI . ResourceManager . GetString ( "ParserState_" + _state . Status ) ) ;
@@ -112,15 +97,15 @@ private void OnRefresh()
112
97
}
113
98
}
114
99
115
- public void Initialize ( )
100
+ private void Initialize ( )
116
101
{
117
102
_commandbar = _vbe . CommandBars . Add ( "Rubberduck" , MsoBarPosition . msoBarTop , false , true ) ;
118
103
119
104
_refreshButton = ( CommandBarButton ) _commandbar . Controls . Add ( MsoControlType . msoControlButton ) ;
120
105
ParentMenuItemBase . SetButtonImage ( _refreshButton , Resources . arrow_circle_double , Resources . arrow_circle_double_mask ) ;
121
106
_refreshButton . Style = MsoButtonStyle . msoButtonIcon ;
122
107
_refreshButton . Tag = "Refresh" ;
123
- _refreshButton . TooltipText = RubberduckUI . RubberduckCommandbarRefreshButtonTooltip ;
108
+ _refreshButton . TooltipText = RubberduckUI . RubberduckCommandbarRefreshButtonTooltip ;
124
109
_refreshButton . Click += refreshButton_Click ;
125
110
126
111
_statusButton = ( CommandBarButton ) _commandbar . Controls . Add ( MsoControlType . msoControlButton ) ;
@@ -136,7 +121,7 @@ public void Initialize()
136
121
_commandbar . Visible = true ;
137
122
}
138
123
139
- private void refreshButton_Click ( CommandBarButton Ctrl , ref bool CancelDefault )
124
+ private void refreshButton_Click ( CommandBarButton ctrl , ref bool cancelDefault )
140
125
{
141
126
OnRefresh ( ) ;
142
127
}
0 commit comments