Esempio n. 1
0
        public static SelectQueryInfo VisitSelectStatement(SelectStatementContext context)
        {
            switch (context)
            {
            case SimpleSelectContext simpleSelectContext:
                return(VisitSimpleSelectContext(simpleSelectContext));

            case ParenthesisSelectContext parenthesisSelectContext:
                return(VisitQueryExpression(parenthesisSelectContext.queryExpression()));
            }

            return(VisitorHelper.ThrowNotSupportedContext <SelectQueryInfo>(context));
        }
Esempio n. 2
0
        public static ITableSource VisitTableSource(TableSourceContext context)
        {
            switch (context)
            {
            case TableSourceBaseContext tableSourceBaseContext:
                return(VisitTableSourceBase(tableSourceBaseContext.tableSourceItem()));

            case TableSourceNestedContext tableSourceNestedContext:
                return(VisitTableSourceBase(tableSourceNestedContext.tableSourceItem()));
            }

            return(VisitorHelper.ThrowNotSupportedContext <ITableSource>(context));
        }
Esempio n. 3
0
        private IEnumerable <SourceSnippet> GetSnippets(MethodDeclarationSyntax method)
        {
            // Note: this won't get using directives in namespace declarations, but hey...
            var usings      = method.SyntaxTree.GetCompilationUnitRoot().Usings.Select(uds => uds.ToString());
            var invocations = method.DescendantNodes().OfType <InvocationExpressionSyntax>();

            foreach (var snippetFor in invocations.Where(IsSnippetMethod("For")))
            {
                var arg          = snippetFor.ArgumentList.Arguments[0].Expression;
                var targetSymbol = model.GetSymbolInfo(arg).Symbol;
                if (targetSymbol == null)
                {
                    throw new Exception($"Couldn't get a symbol for Snippet.For argument: {snippetFor.ToString()}");
                }
                var uid   = VisitorHelper.GetId(targetSymbol);
                var block = snippetFor.Ancestors().OfType <BlockSyntax>().First();
                yield return(new SourceSnippet(uid, block.GetLines(), usings));
            }
        }
        public IEnumerable <MemberExpression> GetMemberExpressions(Expression expression)
        {
            List <MemberExpression> members = new List <MemberExpression>();

            VisitorHelper.VisitMembers(
                expression,
                (expr, recur) =>
            {
                // Ensure we only process members of the parameter
                if (expr is MemberExpression)
                {
                    members.Add((MemberExpression)expr);
                }

                return(recur(expr));
            });

            return(members);
        }
Esempio n. 5
0
        public static IQueryPlanner VisitDmlStatementContext(DmlStatementContext context)
        {
            if (context.children.Count == 0)
            {
                return(null);
            }

            switch (context.children[0])
            {
            case SelectStatementContext selectStatementContext:
                return(new SelectPlanner(VisitSelectStatement(selectStatementContext)));

            case InsertStatementContext insertStatementContext:
                return(new InsertPlanner(VisitInsertStatement(insertStatementContext)));

            case UpdateStatementContext updateStatementContext:
                return(new UpdatePlanner(VisitUpdateStatement(updateStatementContext)));

            case DeleteStatementContext deleteStatementContext:
                return(new DeletePlanner(VisitDeleteStatement(deleteStatementContext)));
            }

            return(VisitorHelper.ThrowNotSupportedContext <IQueryPlanner>((ParserRuleContext)context.children[0]));
        }
Esempio n. 6
0
 public VisitorController()
 {
     _visitorHelper = new VisitorHelper();
     _visitorCheckInCheckOutHelper = new VisitorCheckInCheckOutHelper();
     _userService = new UserService();
 }