1
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
2
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
5
using System.Collections.Generic;
7
namespace ICSharpCode.NRefactory.VB.Ast
9
public class CompilationUnit : AstNode
11
public static readonly Role<AstNode> MemberRole = new Role<AstNode>("Member", AstNode.Null);
13
public CompilationUnit ()
17
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
19
CompilationUnit o = other as CompilationUnit;
20
return o != null && GetChildrenByRole(MemberRole).DoMatch(o.GetChildrenByRole(MemberRole), match);
23
public AstNode GetNodeAt (int line, int column)
25
return GetNodeAt (new TextLocation (line, column));
28
public AstNode GetNodeAt (TextLocation location)
31
while (node.FirstChild != null) {
32
var child = node.FirstChild;
33
while (child != null) {
34
if (child.StartLocation <= location && location < child.EndLocation) {
38
child = child.NextSibling;
40
// found no better child node - therefore the parent is the right one.
47
public IEnumerable<AstNode> GetNodesBetween (int startLine, int startColumn, int endLine, int endColumn)
49
return GetNodesBetween (new TextLocation (startLine, startColumn), new TextLocation (endLine, endColumn));
52
public IEnumerable<AstNode> GetNodesBetween (TextLocation start, TextLocation end)
55
while (node != null) {
57
if (start <= node.StartLocation && node.EndLocation <= end) {
58
// Remember next before yielding node.
59
// This allows iteration to continue when the caller removes/replaces the node.
60
next = node.NextSibling;
63
if (node.EndLocation < start) {
64
next = node.NextSibling;
66
next = node.FirstChild;
70
if (next != null && next.StartLocation > end)
76
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
78
return visitor.VisitCompilationUnit (this, data);