1
- using System ;
2
- using System . Collections . Generic ;
1
+ using System . Collections . Generic ;
3
2
using System . Linq ;
4
- using System . Text ;
5
3
using System . Threading ;
6
- using System . Threading . Tasks ;
7
4
using Rubberduck . Parsing . VBA ;
8
5
using Antlr4 . Runtime . Tree ;
9
- using Antlr4 . Runtime ;
10
6
using Rubberduck . Parsing . Grammar ;
11
7
using Rubberduck . VBEditor ;
12
8
using Antlr4 . Runtime . Misc ;
@@ -109,9 +105,7 @@ public override void EnterSubStmt([NotNull] VBAParser.SubStmtContext context)
109
105
public override void ExitSubStmt ( [ NotNull ] VBAParser . SubStmtContext context )
110
106
{
111
107
// well, we're done here
112
- memberResults . Add ( new MemberMetricsResult ( currentMember , results ) ) ;
113
- results = new List < CodeMetricsResult > ( ) ; // reinitialize to drop results
114
- currentMember = null ;
108
+ ExitMeasurableMember ( ) ;
115
109
}
116
110
117
111
public override void EnterFunctionStmt ( [ NotNull ] VBAParser . FunctionStmtContext context )
@@ -126,9 +120,46 @@ public override void EnterFunctionStmt([NotNull] VBAParser.FunctionStmtContext c
126
120
public override void ExitFunctionStmt ( [ NotNull ] VBAParser . FunctionStmtContext context )
127
121
{
128
122
// well, we're done here
129
- memberResults . Add ( new MemberMetricsResult ( currentMember , results ) ) ;
130
- results = new List < CodeMetricsResult > ( ) ; // reinitialize to drop results
131
- currentMember = null ;
123
+ ExitMeasurableMember ( ) ;
124
+ }
125
+
126
+ public override void EnterPropertyGetStmt ( [ NotNull ] VBAParser . PropertyGetStmtContext context )
127
+ {
128
+ results . Add ( new CodeMetricsResult ( 0 , 1 , 0 ) ) ;
129
+
130
+ currentMember = _finder . DeclarationsWithType ( DeclarationType . PropertyGet ) . Where ( d => d . Context == context ) . First ( ) ;
131
+ }
132
+
133
+ public override void ExitPropertyGetStmt ( [ NotNull ] VBAParser . PropertyGetStmtContext context )
134
+ {
135
+ // well, we're done here
136
+ ExitMeasurableMember ( ) ;
137
+ }
138
+
139
+ public override void EnterPropertyLetStmt ( [ NotNull ] VBAParser . PropertyLetStmtContext context )
140
+ {
141
+ results . Add ( new CodeMetricsResult ( 0 , 1 , 0 ) ) ;
142
+
143
+ currentMember = _finder . DeclarationsWithType ( DeclarationType . PropertyLet ) . Where ( d => d . Context == context ) . First ( ) ;
144
+ }
145
+
146
+ public override void ExitPropertyLetStmt ( [ NotNull ] VBAParser . PropertyLetStmtContext context )
147
+ {
148
+ // well, we're done here
149
+ ExitMeasurableMember ( ) ;
150
+ }
151
+
152
+ public override void EnterPropertySetStmt ( [ NotNull ] VBAParser . PropertySetStmtContext context )
153
+ {
154
+ results . Add ( new CodeMetricsResult ( 0 , 1 , 0 ) ) ;
155
+
156
+ currentMember = _finder . DeclarationsWithType ( DeclarationType . PropertySet ) . Where ( d => d . Context == context ) . First ( ) ;
157
+ }
158
+
159
+ public override void ExitPropertySetStmt ( [ NotNull ] VBAParser . PropertySetStmtContext context )
160
+ {
161
+ // well, we're done here
162
+ ExitMeasurableMember ( ) ;
132
163
}
133
164
134
165
public override void EnterBlockStmt ( [ NotNull ] VBAParser . BlockStmtContext context )
@@ -138,9 +169,15 @@ public override void EnterBlockStmt([NotNull] VBAParser.BlockStmtContext context
138
169
// FIXME LINE_CONTINUATION might interfere here
139
170
//results.Add(new CodeMetricsResult(0, 0, ws.ChildCount / 4));
140
171
}
141
-
142
172
// FIXME also check if we need to do something about `mandatoryLineContinuation`?
143
173
174
+ private void ExitMeasurableMember ( )
175
+ {
176
+ memberResults . Add ( new MemberMetricsResult ( currentMember , results ) ) ;
177
+ results = new List < CodeMetricsResult > ( ) ; // reinitialize to drop results
178
+ currentMember = null ;
179
+ }
180
+
144
181
internal ModuleMetricsResult GetMetricsResult ( QualifiedModuleName qmn )
145
182
{
146
183
return new ModuleMetricsResult ( qmn , memberResults , moduleResults ) ;
0 commit comments