public SelectCaseStmtContextWrapper(VBAParser.SelectCaseStmtContext selectCaseContext, IParseTreeVisitorResults inspValues, IUnreachableCaseInspectionFactoryProvider factoryFactory) : base(selectCaseContext, inspValues, factoryFactory) { _selectCaseContext = selectCaseContext; _unreachableResults = new List <ParserRuleContext>(); _mismatchResults = new List <ParserRuleContext>(); _caseElseResults = new List <ParserRuleContext>(); _inspectionRangeFactory = factoryFactory.CreateIRangeClauseContextWrapperFactory(); SetEvaluationTypeName(Context, ParseTreeValueResults, FilterFactory); }
public UnreachableCaseInspector(VBAParser.SelectCaseStmtContext selectCaseContext, IParseTreeVisitorResults inspValues, IParseTreeValueFactory valueFactory, Func <string, ParserRuleContext, string> GetVariableTypeName = null) { _valueFactory = valueFactory; _caseClauses = selectCaseContext.caseClause(); _caseElseContext = selectCaseContext.caseElseClause(); GetVariableDeclarationTypeName = GetVariableTypeName; ParseTreeValueResults = inspValues; SetSelectExpressionTypeName(selectCaseContext as ParserRuleContext, inspValues); }
public void Resolve(VBAParser.SelectCaseStmtContext context) { ResolveDefault(context.selectExpression().expression()); if (context.caseClause() == null) { return; } foreach (var caseClause in context.caseClause()) { foreach (var rangeClause in caseClause.rangeClause()) { if (rangeClause.expression() != null) { ResolveDefault(rangeClause.expression()); } else { ResolveDefault(rangeClause.selectStartValue().expression()); ResolveDefault(rangeClause.selectEndValue().expression()); } } } }
public override void EnterSelectCaseStmt(VBAParser.SelectCaseStmtContext context) { _resolver.Resolve(context); }
public IUnreachableCaseInspector Create(VBAParser.SelectCaseStmtContext selectStmt, IParseTreeVisitorResults results, IParseTreeValueFactory valueFactory, Func <string, ParserRuleContext, string> func = null) { return(new UnreachableCaseInspector(selectStmt, results, valueFactory, func)); }
public ISelectCaseStmtContextWrapper Create(VBAParser.SelectCaseStmtContext selectStmt, IParseTreeVisitorResults results) { return(new SelectCaseStmtContextWrapper(selectStmt, results, FactoryProvider)); }
public override void EnterSelectCaseStmt([NotNull] VBAParser.SelectCaseStmtContext context) { _contexts.Add(new QualifiedContext <ParserRuleContext>(CurrentModuleName, context)); }
private string DeriveTypeFromCaseClauses(IParseTreeVisitorResults inspValues, VBAParser.SelectCaseStmtContext selectStmt) { var caseClauseTypeNames = new List <string>(); foreach (var caseClause in selectStmt.caseClause()) { foreach (var range in caseClause.rangeClause()) { if (TryDetectTypeHint(range.GetText(), out string hintTypeName)) { caseClauseTypeNames.Add(hintTypeName); } else { var inspRange = _inspectionRangeFactory.Create(range, inspValues); var types = inspRange.ResultContexts.Select(rc => inspValues.GetTypeName(rc)) .Where(tp => InspectableTypes.Contains(tp)); caseClauseTypeNames.AddRange(types); } } } if (TryDetermineEvaluationTypeFromTypes(caseClauseTypeNames, out string evalTypeName)) { return(evalTypeName); } return(string.Empty); }
public override void EnterSelectCaseStmt(VBAParser.SelectCaseStmtContext context) { CheckContext(context, context.END_SELECT()); base.EnterSelectCaseStmt(context); }
private string DeriveTypeFromCaseClauses(IParseTreeVisitorResults inspValues, VBAParser.SelectCaseStmtContext selectStmt) { var caseClauseTypeNames = new List <string>(); foreach (var caseClause in selectStmt.caseClause()) { foreach (var range in caseClause.rangeClause()) { if (TryDetectTypeHint(range.GetText(), out string hintTypeName)) { caseClauseTypeNames.Add(hintTypeName); } else { var typeNames = from context in range.children where context is ParserRuleContext && IsResultContext(context) select inspValues.GetValueType(context as ParserRuleContext); caseClauseTypeNames.AddRange(typeNames); caseClauseTypeNames.RemoveAll(tp => !InspectableTypes.Contains(tp)); } } } if (TryGetSelectExpressionTypeNameFromTypes(caseClauseTypeNames, out string evalTypeName)) { return(evalTypeName); } return(string.Empty); }