|
13 | 13 | using Rubberduck.Parsing.Symbols;
|
14 | 14 | using System;
|
15 | 15 | using Rubberduck.Inspections.Inspections.Extensions;
|
16 |
| -using Rubberduck.JunkDrawer.Extensions; |
17 | 16 | using Rubberduck.Parsing.VBA.DeclarationCaching;
|
18 | 17 | using Rubberduck.Parsing.VBA.Parsing;
|
19 | 18 |
|
@@ -145,38 +144,40 @@ protected override IEnumerable<IInspectionResult> DoGetInspectionResults()
|
145 | 144 | {
|
146 | 145 | var finder = DeclarationFinderProvider.DeclarationFinder;
|
147 | 146 | var parseTreeValueVisitor = CreateParseTreeValueVisitor(GetIdentifierReferenceForContextFunction(finder));
|
| 147 | + var selectCaseInspector = _unreachableCaseInspectorFactory.Create(GetVariableTypeNameFunction(finder)); |
148 | 148 |
|
149 | 149 | return finder.UserDeclarations(DeclarationType.Module)
|
150 | 150 | .Where(module => module != null)
|
151 |
| - .SelectMany(module => DoGetInspectionResults(module.QualifiedModuleName, finder, parseTreeValueVisitor)) |
| 151 | + .SelectMany(module => DoGetInspectionResults(module.QualifiedModuleName, finder, parseTreeValueVisitor, selectCaseInspector)) |
152 | 152 | .ToList();
|
153 | 153 | }
|
154 | 154 |
|
155 | 155 | protected override IEnumerable<IInspectionResult> DoGetInspectionResults(QualifiedModuleName module)
|
156 | 156 | {
|
157 | 157 | var finder = DeclarationFinderProvider.DeclarationFinder;
|
158 | 158 | var parseTreeValueVisitor = CreateParseTreeValueVisitor(GetIdentifierReferenceForContextFunction(finder));
|
159 |
| - return DoGetInspectionResults(module, finder, parseTreeValueVisitor); |
| 159 | + var selectCaseInspector = _unreachableCaseInspectorFactory.Create(GetVariableTypeNameFunction(finder)); |
| 160 | + return DoGetInspectionResults(module, finder, parseTreeValueVisitor, selectCaseInspector); |
160 | 161 | }
|
161 | 162 |
|
162 |
| - private IEnumerable<IInspectionResult> DoGetInspectionResults(QualifiedModuleName module, DeclarationFinder finder, IParseTreeValueVisitor parseTreeValueVisitor) |
| 163 | + private IEnumerable<IInspectionResult> DoGetInspectionResults(QualifiedModuleName module, DeclarationFinder finder, IParseTreeValueVisitor parseTreeValueVisitor, IUnreachableCaseInspector selectCaseInspector) |
163 | 164 | {
|
164 | 165 | var qualifiedSelectCaseStmts = Listener.Contexts(module)
|
165 | 166 | // ignore filtering here to make the search space smaller
|
166 | 167 | .Where(result => !result.IsIgnoringInspectionResultFor(finder, AnnotationName));
|
167 | 168 |
|
168 | 169 | return qualifiedSelectCaseStmts
|
169 |
| - .SelectMany(context => ResultsForContext(context, finder, parseTreeValueVisitor)) |
| 170 | + .SelectMany(context => ResultsForContext(context, parseTreeValueVisitor, selectCaseInspector)) |
170 | 171 | .ToList();
|
171 | 172 | }
|
172 | 173 |
|
173 |
| - private IEnumerable<IInspectionResult> ResultsForContext(QualifiedContext<ParserRuleContext> qualifiedSelectCaseStmt, DeclarationFinder finder, IParseTreeValueVisitor parseTreeValueVisitor) |
| 174 | + private IEnumerable<IInspectionResult> ResultsForContext(QualifiedContext<ParserRuleContext> qualifiedSelectCaseStmt, IParseTreeValueVisitor parseTreeValueVisitor, IUnreachableCaseInspector selectCaseInspector) |
174 | 175 | {
|
175 | 176 | var module = qualifiedSelectCaseStmt.ModuleName;
|
176 |
| - var contextValues = parseTreeValueVisitor.VisitChildren(module, qualifiedSelectCaseStmt.Context); |
177 |
| - var selectCaseInspector = _unreachableCaseInspectorFactory.Create(module, (VBAParser.SelectCaseStmtContext)qualifiedSelectCaseStmt.Context, contextValues, GetVariableTypeNameFunction(finder)); |
| 177 | + var selectStmt = (VBAParser.SelectCaseStmtContext)qualifiedSelectCaseStmt.Context; |
| 178 | + var contextValues = parseTreeValueVisitor.VisitChildren(module, selectStmt); |
178 | 179 |
|
179 |
| - var results = selectCaseInspector.InspectForUnreachableCases(); |
| 180 | + var results = selectCaseInspector.InspectForUnreachableCases(module, selectStmt, contextValues); |
180 | 181 |
|
181 | 182 | return results
|
182 | 183 | .Select(resultTpl => CreateInspectionResult(qualifiedSelectCaseStmt, resultTpl.context, resultTpl.resultType))
|
|
0 commit comments