Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the CodeWalker class.
        /// </summary>
        /// <param name="queryClause">The query clause to walk through.</param>
        /// <param name="statementCallback">Callback executed when a statement is visited.</param>
        /// <param name="expressionCallback">Callback executed when an expression is visited.</param>
        /// <param name="queryClauseCallback">Callback executed when a query clause is visited.</param>
        /// <param name="context">The optional visitor context data.</param>
        private CodeWalker(
            QueryClause queryClause,
            CodeWalkerStatementVisitor <T> statementCallback,
            CodeWalkerExpressionVisitor <T> expressionCallback,
            CodeWalkerQueryClauseVisitor <T> queryClauseCallback,
            T context)
        {
            Param.AssertNotNull(queryClause, "queryClause");
            Param.Ignore(statementCallback);
            Param.Ignore(expressionCallback);
            Param.Ignore(queryClauseCallback);
            Param.Ignore(context);

            this.statementCallback   = statementCallback;
            this.expressionCallback  = expressionCallback;
            this.queryClauseCallback = queryClauseCallback;

            this.WalkQueryClause(
                queryClause,
                queryClause.ParentQueryClause,
                queryClause.FindParentExpression(),
                queryClause.FindParentStatement(),
                queryClause.FindParentElement(),
                context);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Walks through the code units in the statement.
 /// </summary>
 /// <param name="statementCallback">
 /// Callback executed when a statement is visited.
 /// </param>
 /// <param name="expressionCallback">
 /// Callback executed when an expression is visited.
 /// </param>
 /// <param name="queryClauseCallback">
 /// Callback executed when a query clause is visited.
 /// </param>
 public void WalkStatement(
     CodeWalkerStatementVisitor <object> statementCallback,
     CodeWalkerExpressionVisitor <object> expressionCallback,
     CodeWalkerQueryClauseVisitor <object> queryClauseCallback)
 {
     Param.Ignore(statementCallback, expressionCallback, queryClauseCallback);
     CodeWalker <object> .Start(this, statementCallback, expressionCallback, queryClauseCallback, null);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Walks through the code units in the statement.
 /// </summary>
 /// <param name="statementCallback">
 /// Callback executed when a statement is visited.
 /// </param>
 /// <param name="expressionCallback">
 /// Callback executed when an expression is visited.
 /// </param>
 /// <param name="queryClauseCallback">
 /// Callback executed when a query clause is visited.
 /// </param>
 /// <param name="context">
 /// The optional visitor context data.
 /// </param>
 /// <typeparam name="T">
 /// The type of the context item.
 /// </typeparam>
 public void WalkStatement <T>(
     CodeWalkerStatementVisitor <T> statementCallback,
     CodeWalkerExpressionVisitor <T> expressionCallback,
     CodeWalkerQueryClauseVisitor <T> queryClauseCallback,
     T context)
 {
     Param.Ignore(statementCallback, expressionCallback, queryClauseCallback, context);
     CodeWalker <T> .Start(this, statementCallback, expressionCallback, queryClauseCallback, context);
 }
Ejemplo n.º 4
0
        public override void AnalyzeDocument(CodeDocument document)
        {
            var codeDocument = (CsDocument)document;

            if (codeDocument.RootElement != null && !codeDocument.RootElement.Generated)
            {
                var statementCallback = new CodeWalkerStatementVisitor <object>(VisitStatement);

                codeDocument.WalkDocument(null, statementCallback, null);
            }
        }
Ejemplo n.º 5
0
        public static void Start(
            QueryClause queryClause,
            CodeWalkerStatementVisitor <T> statementCallback,
            CodeWalkerExpressionVisitor <T> expressionCallback,
            CodeWalkerQueryClauseVisitor <T> queryClauseCallback,
            T context)
        {
            Param.AssertNotNull(queryClause, "queryClause");
            Param.Ignore(statementCallback);
            Param.Ignore(expressionCallback);
            Param.Ignore(queryClauseCallback);
            Param.Ignore(context);

            new CodeWalker <T>(queryClause, statementCallback, expressionCallback, queryClauseCallback, context);
        }
Ejemplo n.º 6
0
        public static void Start(
            CsDocument document,
            CodeWalkerElementVisitor <T> elementCallback,
            CodeWalkerStatementVisitor <T> statementCallback,
            CodeWalkerExpressionVisitor <T> expressionCallback,
            CodeWalkerQueryClauseVisitor <T> queryClauseCallback,
            T context)
        {
            Param.AssertNotNull(document, "document");
            Param.Ignore(elementCallback);
            Param.Ignore(statementCallback);
            Param.Ignore(expressionCallback);
            Param.Ignore(queryClauseCallback);
            Param.Ignore(context);

            new CodeWalker <T>(document, elementCallback, statementCallback, expressionCallback, queryClauseCallback, context);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Initializes a new instance of the CodeWalker class.
        /// </summary>
        /// <param name="element">The element to walk through.</param>
        /// <param name="elementCallback">Callback executed when an element is visited.</param>
        /// <param name="statementCallback">Callback executed when a statement is visited.</param>
        /// <param name="expressionCallback">Callback executed when an expression is visited.</param>
        /// <param name="queryClauseCallback">Callback executed when a query clause is visited.</param>
        /// <param name="context">The optional visitor context data.</param>
        private CodeWalker(
            CsElement element,
            CodeWalkerElementVisitor <T> elementCallback,
            CodeWalkerStatementVisitor <T> statementCallback,
            CodeWalkerExpressionVisitor <T> expressionCallback,
            CodeWalkerQueryClauseVisitor <T> queryClauseCallback,
            T context)
        {
            Param.AssertNotNull(element, "element");
            Param.Ignore(elementCallback);
            Param.Ignore(statementCallback);
            Param.Ignore(expressionCallback);
            Param.Ignore(queryClauseCallback);
            Param.Ignore(context);

            this.elementCallback     = elementCallback;
            this.statementCallback   = statementCallback;
            this.expressionCallback  = expressionCallback;
            this.queryClauseCallback = queryClauseCallback;

            this.WalkElement(element, element.FindParentElement(), context);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Initializes a new instance of the CodeWalker class.
        /// </summary>
        /// <param name="document">The document to walk through.</param>
        /// <param name="elementCallback">Callback executed when an element is visited.</param>
        /// <param name="statementCallback">Callback executed when a statement is visited.</param>
        /// <param name="expressionCallback">Callback executed when an expression is visited.</param>
        /// <param name="queryClauseCallback">Callback executed when a query clause is visited.</param>
        /// <param name="context">The optional visitor context data.</param>
        private CodeWalker(
            CsDocument document,
            CodeWalkerElementVisitor <T> elementCallback,
            CodeWalkerStatementVisitor <T> statementCallback,
            CodeWalkerExpressionVisitor <T> expressionCallback,
            CodeWalkerQueryClauseVisitor <T> queryClauseCallback,
            T context)
        {
            Param.AssertNotNull(document, "document");
            Param.Ignore(elementCallback);
            Param.Ignore(statementCallback);
            Param.Ignore(expressionCallback);
            Param.Ignore(queryClauseCallback);
            Param.Ignore(context);

            this.elementCallback     = elementCallback;
            this.statementCallback   = statementCallback;
            this.expressionCallback  = expressionCallback;
            this.queryClauseCallback = queryClauseCallback;

            this.WalkElement(document.RootElement, null, context);
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Walks through the code units in the element.
 /// </summary>
 /// <param name="elementCallback">
 /// Callback executed when an element is visited.
 /// </param>
 /// <param name="statementCallback">
 /// Callback executed when a statement is visited.
 /// </param>
 public void WalkElement(CodeWalkerElementVisitor <object> elementCallback, CodeWalkerStatementVisitor <object> statementCallback)
 {
     Param.Ignore(elementCallback, statementCallback);
     this.WalkElement(elementCallback, statementCallback, null, null, null);
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Walks through the code units in the element.
 /// </summary>
 /// <param name="elementCallback">
 /// Callback executed when an element is visited.
 /// </param>
 /// <param name="statementCallback">
 /// Callback executed when a statement is visited.
 /// </param>
 /// <param name="context">
 /// The optional visitor context data.
 /// </param>
 /// <typeparam name="T">
 /// The type of the context item.
 /// </typeparam>
 public void WalkElement <T>(CodeWalkerElementVisitor <T> elementCallback, CodeWalkerStatementVisitor <T> statementCallback, T context)
 {
     Param.Ignore(elementCallback, statementCallback, context);
     this.WalkElement(elementCallback, statementCallback, null, null, context);
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Walks through the code units in the statement.
 /// </summary>
 /// <param name="statementCallback">
 /// Callback executed when a statement is visited.
 /// </param>
 /// <param name="expressionCallback">
 /// Callback executed when an expression is visited.
 /// </param>
 public void WalkStatement(CodeWalkerStatementVisitor <object> statementCallback, CodeWalkerExpressionVisitor <object> expressionCallback)
 {
     Param.Ignore(statementCallback, expressionCallback);
     this.WalkStatement(statementCallback, expressionCallback, null, null);
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Walks through the code units in the statement.
 /// </summary>
 /// <param name="statementCallback">
 /// Callback executed when a statement is visited.
 /// </param>
 /// <param name="expressionCallback">
 /// Callback executed when an expression is visited.
 /// </param>
 /// <param name="context">
 /// The optional visitor context data.
 /// </param>
 /// <typeparam name="T">
 /// The type of the context item.
 /// </typeparam>
 public void WalkStatement <T>(CodeWalkerStatementVisitor <T> statementCallback, CodeWalkerExpressionVisitor <T> expressionCallback, T context)
 {
     Param.Ignore(statementCallback, expressionCallback, context);
     this.WalkStatement(statementCallback, expressionCallback, null, context);
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Walks through the code units in the expression.
 /// </summary>
 /// <param name="statementCallback">
 /// Callback executed when a statement is visited.
 /// </param>
 /// <param name="context">
 /// The optional visitor context data.
 /// </param>
 /// <typeparam name="T">
 /// The type of the context item.
 /// </typeparam>
 public void WalkExpression <T>(CodeWalkerStatementVisitor <T> statementCallback, T context)
 {
     Param.Ignore(statementCallback, context);
     this.WalkExpression(statementCallback, null, null, context);
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Walks through the code units in the query clause.
 /// </summary>
 /// <param name="statementCallback">
 /// Callback executed when a statement is visited.
 /// </param>
 public void WalkQueryClause(CodeWalkerStatementVisitor <object> statementCallback)
 {
     Param.Ignore(statementCallback);
     this.WalkQueryClause(statementCallback, null, null, null);
 }
Ejemplo n.º 15
0
 /// <summary>
 /// Walks through the code units in the query clause.
 /// </summary>
 /// <param name="statementCallback">
 /// Callback executed when a statement is visited.
 /// </param>
 /// <param name="context">
 /// The optional visitor context data.
 /// </param>
 /// <typeparam name="T">
 /// The type of the context item.
 /// </typeparam>
 public void WalkQueryClause <T>(CodeWalkerStatementVisitor <T> statementCallback, T context)
 {
     Param.Ignore(statementCallback, context);
     this.WalkQueryClause(statementCallback, null, null, context);
 }