public override void Fix(IInspectionResult result) { IModuleRewriter rewriter = _state.GetRewriter(result.QualifiedSelection.QualifiedName); ForNextStmtContext context = result.Context as ForNextStmtContext; int toExpressionEnd = this.GetToExpressionEnd(context); rewriter.InsertAfter(toExpressionEnd, " Step 1"); }
public override void EnterForNextStmt([NotNull] ForNextStmtContext context) { StepStmtContext stepStatement = context.stepStmt(); if (stepStatement == null) { _contexts.Add(new QualifiedContext <ParserRuleContext>(CurrentModuleName, context)); } }
private static int GetToExpressionEnd(ForNextStmtContext context) { var toNodeIndex = context.TO().Symbol.TokenIndex; foreach (var expressionChild in context.expression()) { if (expressionChild.Stop.TokenIndex > toNodeIndex) { return(expressionChild.Stop.TokenIndex); } } throw new InvalidOperationException(); }
public override void EnterForNextStmt([NotNull] ForNextStmtContext context) { StepStmtContext stepStatement = context.stepStmt(); if (stepStatement == null) { return; } string stepText = stepStatement.expression().GetText(); if (stepText == "1") { _contexts.Add(new QualifiedContext <ParserRuleContext>(CurrentModuleName, stepStatement)); } }
public ForNextStmtContext forNextStmt() { ForNextStmtContext _localctx = new ForNextStmtContext(Context, State); EnterRule(_localctx, 72, RULE_forNextStmt); int _la; try { EnterOuterAlt(_localctx, 1); { State = 890; Match(FOR); State = 891; Match(WS); State = 892; ambiguousIdentifier(); State = 894; _la = TokenStream.La(1); if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__3) | (1L << T__5) | (1L << T__6) | (1L << T__7) | (1L << T__8))) != 0) || _la==AMPERSAND) { { State = 893; typeHint(); } } State = 898; switch ( Interpreter.AdaptivePredict(TokenStream,97,Context) ) { case 1: { State = 896; Match(WS); State = 897; asTypeClause(); } break; } State = 901; _la = TokenStream.La(1); if (_la==WS) { { State = 900; Match(WS); } } State = 903; Match(EQ); State = 905; _la = TokenStream.La(1); if (_la==WS) { { State = 904; Match(WS); } } State = 907; valueStmt(0); State = 908; Match(WS); State = 909; Match(TO); State = 910; Match(WS); State = 911; valueStmt(0); State = 916; _la = TokenStream.La(1); if (_la==WS) { { State = 912; Match(WS); State = 913; Match(STEP); State = 914; Match(WS); State = 915; valueStmt(0); } } State = 919; ErrorHandler.Sync(this); _la = TokenStream.La(1); do { { { State = 918; Match(NEWLINE); } } State = 921; ErrorHandler.Sync(this); _la = TokenStream.La(1); } while ( _la==NEWLINE ); State = 929; switch ( Interpreter.AdaptivePredict(TokenStream,103,Context) ) { case 1: { State = 923; block(); State = 925; ErrorHandler.Sync(this); _la = TokenStream.La(1); do { { { State = 924; Match(NEWLINE); } } State = 927; ErrorHandler.Sync(this); _la = TokenStream.La(1); } while ( _la==NEWLINE ); } break; } State = 931; Match(NEXT); State = 934; switch ( Interpreter.AdaptivePredict(TokenStream,104,Context) ) { case 1: { State = 932; Match(WS); State = 933; ambiguousIdentifier(); } break; } } } catch (RecognitionException re) { _localctx.exception = re; ErrorHandler.ReportError(this, re); ErrorHandler.Recover(this, re); } finally { ExitRule(); } return _localctx; }