~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to external/nrefactory/ICSharpCode.NRefactory.VB/Ast/VBTokenNode.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
Import upstream version 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

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