Exemplo n.º 1
0
        public IEnumerable <AstNode> GetNodesBetween(AstLocation start, AstLocation end)
        {
            AstNode node = this;

            while (node != null)
            {
                AstNode next;
                if (start <= node.StartLocation && node.EndLocation <= end)
                {
                    // Remember next before yielding node.
                    // This allows iteration to continue when the caller removes/replaces the node.
                    next = node.NextSibling;
                    yield return(node);
                }
                else
                {
                    if (node.EndLocation < start)
                    {
                        next = node.NextSibling;
                    }
                    else
                    {
                        next = node.FirstChild;
                    }
                }

                if (next != null && next.StartLocation > end)
                {
                    yield break;
                }
                node = next;
            }
        }
Exemplo n.º 2
0
 public Identifier(string name, AstLocation location)
 {
     if (name == null)
     {
         throw new ArgumentNullException("name");
     }
     this.Name          = name;
     this.startLocation = location;
 }
Exemplo n.º 3
0
 public LocalLookupVariable(string name, AstType typeRef, AstLocation startPos, AstLocation endPos, bool isConst, bool isLoopVariable, Expression initializer, Expression parentLambdaExpression, bool isQueryContinuation)
 {
     this.Name                   = name;
     this.TypeRef                = typeRef;
     this.StartPos               = startPos;
     this.EndPos                 = endPos;
     this.IsConst                = isConst;
     this.IsLoopVariable         = isLoopVariable;
     this.Initializer            = initializer;
     this.ParentLambdaExpression = parentLambdaExpression;
     this.IsQueryContinuation    = isQueryContinuation;
 }
Exemplo n.º 4
0
        public void AddVariable(AstType typeRef, string name,
                                AstLocation startPos, AstLocation endPos, bool isConst,
                                bool isLoopVariable, Expression initializer,
                                Expression parentLambdaExpression,
                                bool isQueryContinuation)
        {
            if (name == null || name.Length == 0)
            {
                return;
            }
            List <LocalLookupVariable> list;

            if (!variables.ContainsKey(name))
            {
                variables [name] = list = new List <LocalLookupVariable> ();
            }
            else
            {
                list = (List <LocalLookupVariable>)variables [name];
            }
            list.Add(new LocalLookupVariable(name, typeRef, startPos, endPos, isConst, isLoopVariable, initializer, parentLambdaExpression, isQueryContinuation));
        }
Exemplo n.º 5
0
        public AstNode GetNodeAt(AstLocation location)
        {
            AstNode node = this;

            while (node.FirstChild != null)
            {
                var child = node.FirstChild;
                while (child != null)
                {
                    if (child.StartLocation <= location && location < child.EndLocation)
                    {
                        node = child;
                        break;
                    }
                    child = child.NextSibling;
                }
                // found no better child node - therefore the parent is the right one.
                if (child == null)
                {
                    break;
                }
            }
            return(node);
        }
Exemplo n.º 6
0
 public EmptyExpression(AstLocation location)
 {
     this.location = location;
 }
Exemplo n.º 7
0
 public CSharpModifierToken(AstLocation location, Modifiers modifier) : base(location, 0)
 {
     this.Modifier = modifier;
 }
Exemplo n.º 8
0
 public IdentifierExpression(string identifier, AstLocation location)
 {
     SetChildByRole(Roles.Identifier, new Identifier(identifier, location));
 }
Exemplo n.º 9
0
 public CSharpTokenNode(AstLocation location, int tokenLength)
 {
     this.startLocation = location;
     this.tokenLength   = tokenLength;
 }
Exemplo n.º 10
0
 public Comment(CommentType commentType, AstLocation startLocation, AstLocation endLocation)
 {
     this.CommentType   = commentType;
     this.startLocation = startLocation;
     this.endLocation   = endLocation;
 }
Exemplo n.º 11
0
 public PrimitiveType(string keyword, AstLocation location)
 {
     this.Keyword  = keyword;
     this.Location = location;
 }
Exemplo n.º 12
0
 public PrimitiveExpression(object value, AstLocation startLocation, int length)
 {
     this.Value         = value;
     this.startLocation = startLocation;
     this.length        = length;
 }
Exemplo n.º 13
0
 public SimpleType(string identifier, AstLocation location)
 {
     SetChildByRole(Roles.Identifier, new Identifier(identifier, location));
 }