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