Exemplo n.º 1
0
        private void ConvertFunction(IInspectionResult result, VBAParser.FunctionStmtContext functionContext)
        {
            var rewriter = _state.GetRewriter(result.Target);

            var asTypeContext = ParserRuleContextHelper.GetChild <VBAParser.AsTypeClauseContext>(functionContext);

            if (asTypeContext != null)
            {
                rewriter.Remove(asTypeContext);
                rewriter.Remove(functionContext.children.ElementAt(functionContext.children.IndexOf(asTypeContext) - 1) as ParserRuleContext);
            }

            if (result.Target.TypeHint != null)
            {
                rewriter.Remove(ParserRuleContextHelper.GetDescendent <VBAParser.TypeHintContext>(functionContext));
            }

            rewriter.Replace(functionContext.FUNCTION(), Tokens.Sub);
            rewriter.Replace(functionContext.END_FUNCTION(), "End Sub");

            foreach (var returnStatement in GetReturnStatements(result.Target))
            {
                rewriter.Remove(returnStatement);
            }
        }
Exemplo n.º 2
0
 private static void ConvertFunctionDeclaration(VBAParser.FunctionStmtContext functionContext, IModuleRewriter rewriter)
 {
     rewriter.Replace(functionContext.FUNCTION(), Tokens.Sub);
     rewriter.Replace(functionContext.END_FUNCTION(), "End Sub");
 }
Exemplo n.º 3
0
 public override void EnterFunctionStmt(VBAParser.FunctionStmtContext context)
 {
     CheckContext(context, context.END_FUNCTION());
     base.EnterFunctionStmt(context);
 }