private ParameterDeclaration VisitArrayPatternElement(IArrayPatternElement arrayPatternElement)
        {
            ParameterDeclaration paramDecl;

            if (arrayPatternElement is Identifier identifier)
            {
                var name = VisitIdentifier(identifier);
                paramDecl = new ParameterDeclaration(null, null, name, name.TextSpan);
            }
            else if (arrayPatternElement is AssignmentPattern assignmentPattern)
            {
                var assignExpr = VisitAssignmentPattern(assignmentPattern);
                UstTokens.IdToken name;

                if (assignExpr.Left is UstTokens.IdToken idToken)
                {
                    name = idToken;
                }
                else
                {
                    Logger?.LogDebug($"Not {nameof(UstTokens.IdToken)} nodes are not support as parameter names"); // TODO
                    name = null;
                }

                paramDecl = new ParameterDeclaration(null, null, name, assignExpr.TextSpan)
                {
                    Initializer = assignExpr.Right
                };
            }
            else if (arrayPatternElement == null)
            {
                paramDecl = null;
            }
            else
            {
                // TODO: other types
                paramDecl = null;
            }

            return(paramDecl);
        }
 public VariableDeclarator(IArrayPatternElement id, Expression init) :
     base(Nodes.VariableDeclarator)
 {
     Id   = id;
     Init = init;
 }
Esempio n. 3
0
 public CatchClause(IArrayPatternElement param, BlockStatement body) :
     base(Nodes.CatchClause)
 {
     Param = param;
     Body  = body;
 }