Esempio n. 1
0
 public virtual object VisitTryStatement(TryStatementAst tryStatementAst)
 {
     VisitElement(tryStatementAst.Body);
     VisitElements(tryStatementAst.CatchClauses);
     VisitElement(tryStatementAst.Finally);
     return(tryStatementAst);
 }
Esempio n. 2
0
 public static StatementBlockAst GetFinally(this TryStatementAst _ast)
 {
     if (_ast.Finally != null)
     {
         return(_ast.Finally);
     }
     return(null);
 }
Esempio n. 3
0
        public object VisitTryStatement(TryStatementAst tryStatementAst)
        {
            var body         = VisitAst(tryStatementAst.Body);
            var catchClauses = VisitAst(tryStatementAst.CatchClauses);
            var @finally     = VisitAst(tryStatementAst.Finally);

            return(new TryStatementAst(tryStatementAst.Extent, body, catchClauses, @finally));
        }
 public virtual StatementAst VisitTryStatement(TryStatementAst tryStatementAst)
 {
     return(new TryStatementAst(
                tryStatementAst.Extent,
                tryStatementAst.Body?.Rewrite(this, SyntaxKind.StatementBlock),
                tryStatementAst.CatchClauses?.RewriteAll(this, SyntaxKind.Catch),
                tryStatementAst.Finally?.Rewrite(this, SyntaxKind.StatementBlock)));
 }
        public object VisitTryStatement(TryStatementAst tryStatementAst)
        {
            var newBody         = VisitElement(tryStatementAst.Body);
            var newCatchClauses = VisitElements(tryStatementAst.CatchClauses);
            var newFinally      = VisitElement(tryStatementAst.Finally);

            return(new TryStatementAst(tryStatementAst.Extent, newBody, newCatchClauses, newFinally));
        }
 public static TryStatementAst Update(
     this TryStatementAst ast,
     StatementBlockAst body = null,
     IEnumerable <CatchClauseAst> catchClauses = null,
     StatementBlockAst @finally = null)
 {
     return(new TryStatementAst(
                ast.Extent,
                body?.Clone() ?? ast.Body?.Clone(),
                catchClauses?.CloneAll() ?? ast.CatchClauses?.CloneAll(),
                @finally?.Clone() ?? ast.Finally?.Clone()));
 }
Esempio n. 7
0
        public override AstVisitAction VisitTryStatement(TryStatementAst tryStatementAst)
        {
            explanations.Add(new Explanation()
            {
                CommandName     = "Try statement",
                HelpResult      = HelpTableQuery("about_try_catch_finally"),
                Description     = "If an exception is thrown in a Try block, it can be handled in a Catch block, and/or a cleanup can be done in a Finally block.",
                TextToHighlight = "try"
            }.AddDefaults(tryStatementAst, explanations));

            return(AstVisitAction.Continue);
        }
Esempio n. 8
0
 public override object VisitTryStatement(TryStatementAst tryStatementAst)
 {
     script_.Write("try{");
     VisitElement(tryStatementAst.Body);
     script_.Write("}");
     VisitElements(tryStatementAst.CatchClauses);
     if (tryStatementAst.Finally != null)
     {
         script_.Write("finally{");
     }
     VisitElement(tryStatementAst.Finally);
     if (tryStatementAst.Finally != null)
     {
         script_.Write("}");
     }
     return(tryStatementAst);
 }
        public override AstVisitAction VisitTryStatement(TryStatementAst tryStatementAst)
        {
            var tryBody = VisitSyntaxNode(tryStatementAst.Body);
            var body    = tryBody as Block;

            if (body == null)
            {
                body = new Block(tryBody);
            }

            var catches = new List <Catch>();

            foreach (var catchClause in  tryStatementAst.CatchClauses)
            {
                var catchNode = VisitSyntaxNode(catchClause) as Catch;
                catches.Add(catchNode);
            }

            if (tryStatementAst.Finally != null)
            {
                var fin     = VisitSyntaxNode(tryStatementAst.Finally);
                var finBody = fin as Block;
                if (finBody == null)
                {
                    finBody = new Block(fin);
                }

                var fina = new Finally(finBody);

                _currentNode = new Try(body, catches, fina);
            }
            else
            {
                _currentNode = new Try(body, catches);
            }



            return(AstVisitAction.SkipChildren);
        }
Esempio n. 10
0
 public object VisitTryStatement(TryStatementAst tryStatementAst)
 {
     Console.WriteLine("Visited an TryStatementAst.");
     return(tryStatementAst);
 }
 object ICustomAstVisitor.VisitTryStatement(TryStatementAst tryStatementAst)
 => ProcessRewriter(VisitTryStatement, tryStatementAst);
 public object VisitTryStatement(TryStatementAst tryStatementAst) => null;
Esempio n. 13
0
 /// <summary/>
 public virtual AstVisitAction VisitTryStatement(TryStatementAst tryStatementAst) => DefaultVisit(tryStatementAst);
 public object VisitTryStatement(TryStatementAst tryStatementAst)
 {
     throw PSTraceSource.NewArgumentException("ast");
 }
Esempio n. 15
0
 public override AstVisitAction VisitTryStatement(TryStatementAst tryStatementAst)
 {
     throw new NotImplementedException(); //VisitTryStatement(tryStatementAst);
 }
 public override AstVisitAction VisitTryStatement(TryStatementAst tryStatementAst)
 {
     return(Visit(tryStatementAst));
 }
Esempio n. 17
0
 public static IEnumerable <Ast> GetCatch(this TryStatementAst _ast)
 {
     return(_ast.FindAll(Args => Args is CatchClauseAst && Args.Parent == _ast, false));
 }
 public virtual TResult VisitTryStatement(TryStatementAst tryStatementAst) => default(TResult);
Esempio n. 19
0
 public override AstVisitAction VisitTryStatement(TryStatementAst tryStatementAst)
 {
     Console.WriteLine("Visited an TryStatementAst.");
     Console.WriteLine("    " + tryStatementAst.ToString().Replace(Environment.NewLine, Environment.NewLine + "    "));
     return(AstVisitAction.Continue);
 }
Esempio n. 20
0
 public override AstVisitAction VisitTryStatement(TryStatementAst ast)
 {
     return(AstVisitAction.Continue);
 }
Esempio n. 21
0
 public object VisitTryStatement(TryStatementAst tryStatementAst)
 {
     throw new NotImplementedException();
 }
Esempio n. 22
0
 public object VisitTryStatement(TryStatementAst tryStatementAst)
 {
     throw new UnexpectedElementException();
 }
Esempio n. 23
0
 // TryStatementAst Extension Methods
 // New Methods Available:
 // - CreateNodeFromAST(NodeDepth, NodePosition) => Creates a Node
 // - CreateChildNodes ($item in $collection) {} => Creates Child Nodes
 public static TryNode CreateNodeFromAst(this TryStatementAst _ast, int _depth, int _position, Node _parent, Tree _tree)
 {
     return(new TryNode(_ast, _depth, _position, _parent, _tree));
 }
 object ICustomAstVisitor.VisitTryStatement(TryStatementAst tryStatementAst) => VisitTryStatement(tryStatementAst);
Esempio n. 25
0
 public object VisitTryStatement(TryStatementAst tryStatementAst)
 {
     return(false);
 }
Esempio n. 26
0
 public override AstVisitAction VisitTryStatement(TryStatementAst ast)
 {
     return(Check(ast));
 }
Esempio n. 27
0
 public static IEnumerable <Ast> GetChildAst(this TryStatementAst _ast)
 {
     return(_ast.Body.FindAll(Args => Args is Ast && Args.Parent == _ast.Body, false));
 }
Esempio n. 28
0
 public override AstVisitAction VisitTryStatement(TryStatementAst ast)
 {
     return(DoNextAction(ast));
 }
Esempio n. 29
0
 public override StatementAst VisitTryStatement(TryStatementAst tryStatementAst)
 => VisitStatement(base.VisitTryStatement(tryStatementAst));
Esempio n. 30
0
 public override AstVisitAction VisitTryStatement(TryStatementAst tryStatementAst) => VisitAst(tryStatementAst);