1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
|
/*
* Created by SharpDevelop.
* User: Siegfried
* Date: 11.04.2011
* Time: 20:44
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
namespace ICSharpCode.NRefactory.VB.Ast
{
/// <summary>
/// Description of VBTokenNode.
/// </summary>
public class VBTokenNode : AstNode
{
public static new readonly VBTokenNode Null = new NullVBTokenNode();
class NullVBTokenNode : VBTokenNode
{
public override bool IsNull {
get {
return true;
}
}
public NullVBTokenNode() : base (TextLocation.Empty, 0)
{
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return default (S);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
return other == null || other.IsNull;
}
}
TextLocation startLocation;
public override TextLocation StartLocation {
get {
return startLocation;
}
}
protected int tokenLength = -1;
TextLocation endLocation;
public override TextLocation EndLocation {
get {
return tokenLength < 0 ? endLocation : new TextLocation(startLocation.Line, startLocation.Column + tokenLength);
}
}
public VBTokenNode(TextLocation location, int tokenLength)
{
this.startLocation = location;
this.tokenLength = tokenLength;
}
public VBTokenNode(TextLocation startLocation, TextLocation endLocation)
{
this.startLocation = startLocation;
this.endLocation = endLocation;
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitVBTokenNode(this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
var node = other as VBTokenNode;
return node != null && !node.IsNull;
}
public override string ToString ()
{
return string.Format ("[VBTokenNode: StartLocation={0}, EndLocation={1}, Role={2}]", StartLocation, EndLocation, Role);
}
}
}
|