示例#1
0
        private static bool CompleteAgainstSwitchFile(Ast lastAst, Token tokenBeforeCursor)
        {
            Tuple <Token, Ast> tuple;
            ErrorStatementAst  ast = lastAst as ErrorStatementAst;

            if ((((ast != null) && (ast.Flags != null)) && ((ast.Kind != null) && (tokenBeforeCursor != null))) && (ast.Kind.Kind.Equals(TokenKind.Switch) && ast.Flags.TryGetValue("file", out tuple)))
            {
                return(tuple.Item1.Extent.EndOffset == tokenBeforeCursor.Extent.EndOffset);
            }
            if (!(lastAst.Parent is CommandExpressionAst))
            {
                return(false);
            }
            PipelineAst parent = lastAst.Parent.Parent as PipelineAst;

            if (parent == null)
            {
                return(false);
            }
            ast = parent.Parent as ErrorStatementAst;
            if (((ast == null) || (ast.Kind == null)) || (ast.Flags == null))
            {
                return(false);
            }
            return((ast.Kind.Kind.Equals(TokenKind.Switch) && ast.Flags.TryGetValue("file", out tuple)) && (tuple.Item2 == parent));
        }
示例#2
0
        private static bool CompleteAgainstStatementFlags(Ast scriptAst, Ast lastAst, Token token, out TokenKind kind)
        {
            Func <Ast, bool> predicate = null;

            kind = TokenKind.Unknown;
            ErrorStatementAst ast = lastAst as ErrorStatementAst;

            if (((ast != null) && (ast.Kind != null)) && (ast.Kind.Kind == TokenKind.Switch))
            {
                kind = TokenKind.Switch;
                return(true);
            }
            ScriptBlockAst ast2 = scriptAst as ScriptBlockAst;

            if (((token != null) && (token.Kind == TokenKind.Minus)) && (ast2 != null))
            {
                Tuple <Token, Ast> tuple;
                if (predicate == null)
                {
                    predicate = a => IsCursorBeforeExtent(token.Extent.StartScriptPosition, a.Extent);
                }
                Ast parent = AstSearcher.FindAll(ast2, predicate, true).LastOrDefault <Ast>();
                ast = null;
                while (parent != null)
                {
                    ast = parent as ErrorStatementAst;
                    if (ast != null)
                    {
                        break;
                    }
                    parent = parent.Parent;
                }
                if ((((ast != null) && (ast.Kind != null)) && ((ast.Kind.Kind == TokenKind.Switch) && (ast.Flags != null))) && (ast.Flags.TryGetValue("--%", out tuple) && IsTokenTheSame(tuple.Item1, token)))
                {
                    kind = TokenKind.Switch;
                    return(true);
                }
            }
            return(false);
        }
 public object VisitErrorStatement(ErrorStatementAst errorStatementAst)
 {
     throw PSTraceSource.NewArgumentException("ast");
 }
示例#4
0
 public override StatementAst VisitErrorStatement(ErrorStatementAst errorStatementAst)
 => VisitStatement(base.VisitErrorStatement(errorStatementAst));
示例#5
0
 public override AstVisitAction VisitErrorStatement(ErrorStatementAst ast)
 {
     return(DoNextAction(ast));
 }
 public override AstVisitAction VisitErrorStatement(ErrorStatementAst errorStatementAst)
 {
     return(Visit(errorStatementAst));
 }
示例#7
0
 public override AstVisitAction VisitErrorStatement(ErrorStatementAst errorStatementAst)
 {
     Console.WriteLine("Visited an ErrorStatementAst.");
     Console.WriteLine("    " + errorStatementAst.ToString().Replace(Environment.NewLine, Environment.NewLine + "    "));
     return(AstVisitAction.Continue);
 }
 public object VisitErrorStatement(ErrorStatementAst errorStatementAst)
 {
     // TODO: why is there no public constructor for ast with nested asts?
     return(errorStatementAst.Copy());
 }
 public static ErrorStatementAst Update(this ErrorStatementAst ast)
 {
     return(ast.Clone());
 }
示例#10
0
 public override AstVisitAction VisitErrorStatement(ErrorStatementAst errorStatementAst)
 {
     // SKIP
     AstExplainer(errorStatementAst);
     return(base.VisitErrorStatement(errorStatementAst));
 }
示例#11
0
 public object VisitErrorStatement(ErrorStatementAst errorStatementAst)
 {
     throw new UnexpectedElementException();
 }
 object ICustomAstVisitor.VisitErrorStatement(ErrorStatementAst errorStatementAst)
 => ProcessRewriter(VisitErrorStatement, errorStatementAst);
 public virtual StatementAst VisitErrorStatement(ErrorStatementAst errorStatementAst)
 {
     return((ErrorStatementAst)errorStatementAst.Copy());
 }
 public virtual TResult VisitErrorStatement(ErrorStatementAst errorStatementAst) => default(TResult);
 object ICustomAstVisitor.VisitErrorStatement(ErrorStatementAst errorStatementAst) => VisitErrorStatement(errorStatementAst);
示例#16
0
 /// <summary/>
 public virtual AstVisitAction VisitErrorStatement(ErrorStatementAst errorStatementAst) => DefaultVisit(errorStatementAst);
 public object VisitErrorStatement(ErrorStatementAst errorStatementAst) => null;
示例#18
0
 public object VisitErrorStatement(ErrorStatementAst errorStatementAst)
 {
     throw new NotImplementedException();
 }
示例#19
0
 public object VisitErrorStatement(ErrorStatementAst errorStatementAst)
 {
     Console.WriteLine("Visited an ErrorStatementAst.");
     return(errorStatementAst);
 }
示例#20
0
 public override AstVisitAction VisitErrorStatement(ErrorStatementAst ast)
 {
     return(AstVisitAction.Continue);
 }
 public virtual object VisitErrorStatement(ErrorStatementAst errorStatementAst)
 {
     return(errorStatementAst);
 }
示例#22
0
 public override AstVisitAction VisitErrorStatement(ErrorStatementAst ast)
 {
     return(Check(ast));
 }
示例#23
0
 public object VisitErrorStatement(ErrorStatementAst errorStatementAst)
 {
     return(false);
 }
示例#24
0
 public override AstVisitAction VisitErrorStatement(ErrorStatementAst errorStatementAst) => VisitAst(errorStatementAst);