Example #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;
            }
        }
Example #2
0
 public Identifier(string name, AstLocation location)
 {
     if (name == null)
     {
         throw new ArgumentNullException("name");
     }
     this.Name          = name;
     this.startLocation = location;
 }
Example #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;
 }
Example #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));
        }
Example #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);
        }
Example #6
0
 public EmptyExpression(AstLocation location)
 {
     this.location = location;
 }
Example #7
0
 public CSharpModifierToken(AstLocation location, Modifiers modifier) : base(location, 0)
 {
     this.Modifier = modifier;
 }
Example #8
0
 public IdentifierExpression(string identifier, AstLocation location)
 {
     SetChildByRole(Roles.Identifier, new Identifier(identifier, location));
 }
Example #9
0
 public CSharpTokenNode(AstLocation location, int tokenLength)
 {
     this.startLocation = location;
     this.tokenLength   = tokenLength;
 }
Example #10
0
 public Comment(CommentType commentType, AstLocation startLocation, AstLocation endLocation)
 {
     this.CommentType   = commentType;
     this.startLocation = startLocation;
     this.endLocation   = endLocation;
 }
Example #11
0
 public PrimitiveType(string keyword, AstLocation location)
 {
     this.Keyword  = keyword;
     this.Location = location;
 }
Example #12
0
 public PrimitiveExpression(object value, AstLocation startLocation, int length)
 {
     this.Value         = value;
     this.startLocation = startLocation;
     this.length        = length;
 }
Example #13
0
 public SimpleType(string identifier, AstLocation location)
 {
     SetChildByRole(Roles.Identifier, new Identifier(identifier, location));
 }